From 323f5e5b1f3ea980eabf1f82cbc564225b2a1e2c Mon Sep 17 00:00:00 2001 From: alejandro-angulo Date: Sun, 6 Oct 2024 09:57:13 -0700 Subject: [PATCH] Added shortcut for lazygit in a popup --- modules/home/apps/tmux/default.nix | 38 ++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/modules/home/apps/tmux/default.nix b/modules/home/apps/tmux/default.nix index d974773..4ae44f4 100644 --- a/modules/home/apps/tmux/default.nix +++ b/modules/home/apps/tmux/default.nix @@ -58,21 +58,33 @@ in { tmuxPlugins.vim-tmux-navigator ]; - extraConfig = '' - # Scrolling with mouse wheel scrolls output instead of previous commands - setw -g mouse on + extraConfig = + '' + # Scrolling with mouse wheel scrolls output instead of previous commands + setw -g mouse on - # Open panes in the same directory - bind c new-window -c "#{pane_current_path}" - bind '"' split-window -c "#{pane_current_path}" - bind % split-window -h -c "#{pane_current_path}" + # Open panes in the same directory + bind c new-window -c "#{pane_current_path}" + bind '"' split-window -c "#{pane_current_path}" + bind % split-window -h -c "#{pane_current_path}" - # sessionizer - bind C-o display-popup -E "${pkgs.tmux-sessionizer}/bin/tms" - bind C-j display-popup -E "${pkgs.tmux-sessionizer}/bin/tms switch" - bind C-w display-popup -E "${pkgs.tmux-sessionizer}/bin/tms windows" - bind C-s command-prompt -p "Rename active session to:" "run-shell '${pkgs.tmux-sessionizer}/bin/tms rename %1'" - ''; + # sessionizer + bind C-o display-popup -E "${pkgs.tmux-sessionizer}/bin/tms" + bind C-j display-popup -E "${pkgs.tmux-sessionizer}/bin/tms switch" + bind C-w display-popup -E "${pkgs.tmux-sessionizer}/bin/tms windows" + bind C-s command-prompt -p "Rename active session to:" "run-shell '${pkgs.tmux-sessionizer}/bin/tms rename %1'" + + '' + + lib.strings.optionalString config.programs.lazygit.enable '' + # Open lazygit in a popup + # Spins up a new session with a '-lg' suffix (hitting the shortcut + # toggles between attaching and detaching) + bind C-g if-shell "[[ $(tmux display-message -p '#S') == *-lg ]]" { + detach-client + } { + display-popup -h 90% -w 90% -E "tmux new-session -A -s $(tmux display-message -p '#S')-lg ${pkgs.lazygit}/bin/lazygit" + } + ''; }; xdg.configFile."tms/config.toml".source = (pkgs.formats.toml {}).generate "tms-config" tmsConfig;