wezterm: add integrations for Bash and Zsh (#3934)

* wezterm: Add `enableBashIntegration` option

* wezterm: Add `enableZshIntegration` option
This commit is contained in:
Olmo Kramer 2023-06-05 22:46:18 +02:00 committed by GitHub
parent 607d8fad96
commit 24d590cc32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 118 additions and 0 deletions

View File

@ -7,6 +7,10 @@ let
cfg = config.programs.wezterm;
tomlFormat = pkgs.formats.toml { };
shellIntegrationStr = ''
source "${cfg.package}/etc/profile.d/wezterm.sh"
'';
in {
meta.maintainers = [ hm.maintainers.blmhemu ];
@ -79,6 +83,13 @@ in {
'';
};
enableBashIntegration = mkEnableOption "WezTerm's Bash integration." // {
default = true;
};
enableZshIntegration = mkEnableOption "WezTerm's Zsh integration." // {
default = true;
};
};
config = mkIf cfg.enable {
@ -99,5 +110,9 @@ in {
nameValuePair "wezterm/colors/${name}.toml" {
source = tomlFormat.generate "${name}.toml" { colors = value; };
}) cfg.colorSchemes;
programs.bash.initExtra =
mkIf cfg.enableBashIntegration shellIntegrationStr;
programs.zsh.initExtra = mkIf cfg.enableZshIntegration shellIntegrationStr;
};
}

View File

@ -0,0 +1,14 @@
{ ... }:
{
programs.bash.enable = true;
# Bash integration is enabled by default.
programs.wezterm.enable = true;
test.stubs.wezterm = { };
nmt.script = ''
assertFileContains home-files/.bashrc 'source "@wezterm@/etc/profile.d/wezterm.sh"'
'';
}

View File

@ -0,0 +1,16 @@
{ ... }:
{
programs.bash.enable = true;
programs.wezterm = {
enable = true;
enableBashIntegration = false;
};
test.stubs.wezterm = { };
nmt.script = ''
assertFileNotRegex home-files/.bashrc 'source "@wezterm@/etc/profile.d/wezterm.sh"'
'';
}

View File

@ -0,0 +1,16 @@
{ ... }:
{
programs.bash.enable = true;
programs.wezterm = {
enable = true;
enableBashIntegration = true;
};
test.stubs.wezterm = { };
nmt.script = ''
assertFileContains home-files/.bashrc 'source "@wezterm@/etc/profile.d/wezterm.sh"'
'';
}

View File

@ -1,4 +1,12 @@
{
wezterm-example-setting = ./example-setting.nix;
wezterm-empty-setting = ./empty-setting.nix;
wezterm-bash-integration-default = ./bash-integration-default.nix;
wezterm-bash-integration-disabled = ./bash-integration-disabled.nix;
wezterm-bash-integration-enabled = ./bash-integration-enabled.nix;
wezterm-zsh-integration-default = ./zsh-integration-default.nix;
wezterm-zsh-integration-disabled = ./zsh-integration-disabled.nix;
wezterm-zsh-integration-enabled = ./zsh-integration-enabled.nix;
}

View File

@ -0,0 +1,15 @@
{ ... }:
{
programs.zsh.enable = true;
# Zsh integration is enabled by default.
programs.wezterm.enable = true;
test.stubs.wezterm = { };
test.stubs.zsh = { };
nmt.script = ''
assertFileContains home-files/.zshrc 'source "@wezterm@/etc/profile.d/wezterm.sh"'
'';
}

View File

@ -0,0 +1,17 @@
{ ... }:
{
programs.zsh.enable = true;
programs.wezterm = {
enable = true;
enableZshIntegration = false;
};
test.stubs.wezterm = { };
test.stubs.zsh = { };
nmt.script = ''
assertFileNotRegex home-files/.zshrc 'source "@wezterm@/etc/profile.d/wezterm.sh"'
'';
}

View File

@ -0,0 +1,17 @@
{ ... }:
{
programs.zsh.enable = true;
programs.wezterm = {
enable = true;
enableZshIntegration = true;
};
test.stubs.wezterm = { };
test.stubs.zsh = { };
nmt.script = ''
assertFileContains home-files/.zshrc 'source "@wezterm@/etc/profile.d/wezterm.sh"'
'';
}