diff --git a/nix/home/opdavies/hosts/PW05CH3L.nix b/nix/home/opdavies/hosts/PW05CH3L.nix index 063122e..a2f8c14 100644 --- a/nix/home/opdavies/hosts/PW05CH3L.nix +++ b/nix/home/opdavies/hosts/PW05CH3L.nix @@ -2,6 +2,7 @@ features = { cli = { direnv.enable = true; + tmux-sessionizer.enable = true; }; desktop = { diff --git a/nix/home/opdavies/hosts/lemp11.nix b/nix/home/opdavies/hosts/lemp11.nix index 7b25100..bdabdaa 100644 --- a/nix/home/opdavies/hosts/lemp11.nix +++ b/nix/home/opdavies/hosts/lemp11.nix @@ -5,6 +5,7 @@ cli = { bluetuith.enable = true; direnv.enable = true; + tmux-sessionizer.enable = true; }; desktop = { diff --git a/nix/lib/shared/home-manager-packages.nix b/nix/lib/shared/home-manager-packages.nix index c9efbb5..38c4d29 100644 --- a/nix/lib/shared/home-manager-packages.nix +++ b/nix/lib/shared/home-manager-packages.nix @@ -17,7 +17,6 @@ let import ./scripts/export-video-list.nix { inherit pkgs username; } ); run = writeShellApplication (import ./scripts/run.nix { inherit pkgs; }); - t = writeShellApplication (import ./scripts/t.nix { inherit pkgs; }); timer = writeShellApplication (import ./scripts/timer.nix); in with pkgs; @@ -69,7 +68,6 @@ with pkgs; # Scripts. deliver run - t ] ++ pkgs.lib.optionals desktop [ # Scripts. diff --git a/nix/modules/home-manager/features/cli/default.nix b/nix/modules/home-manager/features/cli/default.nix index cd1c7e0..ccb0764 100644 --- a/nix/modules/home-manager/features/cli/default.nix +++ b/nix/modules/home-manager/features/cli/default.nix @@ -19,6 +19,15 @@ ; }) + (import ./tmux-sessionizer.nix { + inherit + config + lib + pkgs + self + ; + }) + ./bat.nix ./bin.nix ./bluetuith.nix diff --git a/nix/modules/home-manager/features/cli/tmux-sessionizer.nix b/nix/modules/home-manager/features/cli/tmux-sessionizer.nix new file mode 100644 index 0000000..17e71c5 --- /dev/null +++ b/nix/modules/home-manager/features/cli/tmux-sessionizer.nix @@ -0,0 +1,32 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + options.features.cli.tmux-sessionizer.enable = lib.mkEnableOption "Enable tmux-sessionizer"; + + config = lib.mkIf config.features.cli.tmux-sessionizer.enable { + home.packages = with pkgs; [ custom-tmux-sessionizer ]; + + home.file.".tmux-sessionizer".source = "${ + pkgs.writeShellApplication { + name = ".tmux-sessionizer"; + + runtimeInputs = with pkgs; [ + tmux + ]; + + text = '' + set +o nounset + + tmux new-window -d -n scratch + nvim + clear + ''; + } + }/bin/.tmux-sessionizer"; + }; +} diff --git a/nix/modules/home-manager/features/cli/tmux.nix b/nix/modules/home-manager/features/cli/tmux.nix index 9dd8a10..47b7055 100644 --- a/nix/modules/home-manager/features/cli/tmux.nix +++ b/nix/modules/home-manager/features/cli/tmux.nix @@ -72,8 +72,7 @@ in set-option -g pane-active-border-style "fg=#1f2335" set-option -g pane-border-style "fg=#1f2335" - bind-key -r f run-shell "tmux new-window t" - + bind-key -r f run-shell "tmux new-window custom-tmux-sessionizer" if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local' ''; diff --git a/nix/modules/home-manager/features/cli/zsh.nix b/nix/modules/home-manager/features/cli/zsh.nix index 3f7fbb3..d82fa13 100644 --- a/nix/modules/home-manager/features/cli/zsh.nix +++ b/nix/modules/home-manager/features/cli/zsh.nix @@ -56,7 +56,7 @@ zstyle ":completion:*" matcher-list "" "m:{a-zA-Z}={A-Za-z}" "r:|=*" "l:|=* r:|=*" autoload -Uz compinit && compinit - bindkey -s ^f "t\n" + bindkey -s ^f "custom-tmux-sessionizer\n" bindkey -s ^v "nvim\n" clear-ls-all() { diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix index e1aa504..3325e49 100644 --- a/nix/pkgs/default.nix +++ b/nix/pkgs/default.nix @@ -5,6 +5,7 @@ let in { build-glove80 = callPackage ./build-glove80.nix { }; + custom-tmux-sessionizer = callPackage ./tmux-sessionizer.nix { }; notify-battery = callPackage ./notify-battery.nix { }; vimPlugins = prev.vimPlugins // { diff --git a/nix/lib/shared/scripts/t.nix b/nix/pkgs/tmux-sessionizer.nix similarity index 89% rename from nix/lib/shared/scripts/t.nix rename to nix/pkgs/tmux-sessionizer.nix index 1daa2b4..2ba9374 100644 --- a/nix/lib/shared/scripts/t.nix +++ b/nix/pkgs/tmux-sessionizer.nix @@ -1,12 +1,14 @@ { pkgs }: -{ - name = "t"; +pkgs.writeShellApplication { + name = "custom-tmux-sessionizer"; runtimeInputs = with pkgs; [ tmux ]; text = '' - # https://github.com/ThePrimeagen/tmux-sessionizer. + set +o nounset + + # Based on https://github.com/ThePrimeagen/tmux-sessionizer. switch_to() { if [[ -z $TMUX ]]; then