1{
2 config,
3 pkgs,
4 lib,
5 ...
6}:
7
8let
9 cfg = config.programs.git-worktree-switcher;
10
11 initScript =
12 shell:
13 if (shell == "fish") then
14 ''
15 ${lib.getExe pkgs.git-worktree-switcher} init ${shell} | source
16 ''
17 else
18 ''
19 eval "$(${lib.getExe pkgs.git-worktree-switcher} init ${shell})"
20 '';
21in
22{
23 options = {
24 programs.git-worktree-switcher = {
25 enable = lib.mkEnableOption "git-worktree-switcher, switch between git worktrees with speed.";
26 };
27 };
28
29 config = lib.mkIf cfg.enable {
30 environment.systemPackages = with pkgs; [ git-worktree-switcher ];
31
32 programs.bash.interactiveShellInit = initScript "bash";
33 programs.zsh.interactiveShellInit = lib.optionalString config.programs.zsh.enable (
34 initScript "zsh"
35 );
36 programs.fish.interactiveShellInit = lib.optionalString config.programs.fish.enable (
37 initScript "fish"
38 );
39 };
40}