Skip to content

Commit

Permalink
git-worktree-switcher: remove shell integrations
Browse files Browse the repository at this point in the history
They're redundant, given that the packages already install the
completion files through `installShellCompletion`.
  • Loading branch information
ambroisie committed Feb 12, 2025
1 parent 83bd3a2 commit 1dcb400
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions modules/programs/git-worktree-switcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,23 @@ let
inherit (lib) mkEnableOption mkPackageOption optionalString;

cfg = config.programs.git-worktree-switcher;

initScript = shell:
if (shell == "fish") then ''
${lib.getExe pkgs.git-worktree-switcher} init ${shell} | source
'' else ''
eval "$(${lib.getExe pkgs.git-worktree-switcher} init ${shell})"
'';
in {
meta.maintainers = with lib.maintainers; [ jiriks74 mateusauler ];

imports = lib.flip builtins.map [ "Bash" "Fish" "Zsh" ]
(shell: mkRemovedOptionModule [
"programs"
"git-worktree-switcher"
"enable${shell}Integration"
] ''
The completion files for `git-worktree-switcher` are already installed in
the package, and should be installed alongside it.
'');

options.programs.git-worktree-switcher = {
enable = mkEnableOption "git-worktree-switcher";
package = mkPackageOption pkgs "git-worktree-switcher" { };
enableBashIntegration =
lib.hm.shell.mkBashIntegrationOption { inherit config; };

enableFishIntegration =
lib.hm.shell.mkFishIntegrationOption { inherit config; };

enableZshIntegration =
lib.hm.shell.mkZshIntegrationOption { inherit config; };
};

config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
programs.bash.initExtra =
optionalString cfg.enableBashIntegration (initScript "bash");
programs.fish.interactiveShellInit =
optionalString cfg.enableFishIntegration (initScript "fish");
programs.zsh.initExtra =
optionalString cfg.enableZshIntegration (initScript "zsh");
};
config = lib.mkIf cfg.enable { home.packages = [ cfg.package ]; };
}

0 comments on commit 1dcb400

Please sign in to comment.