diff options
Diffstat (limited to 'tmux-tsunami/modules/common/defaultGlobalKeys.nix')
| -rw-r--r-- | tmux-tsunami/modules/common/defaultGlobalKeys.nix | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tmux-tsunami/modules/common/defaultGlobalKeys.nix b/tmux-tsunami/modules/common/defaultGlobalKeys.nix new file mode 100644 index 0000000..fc3c669 --- /dev/null +++ b/tmux-tsunami/modules/common/defaultGlobalKeys.nix @@ -0,0 +1,66 @@ +{ + pkgs, + tsunamiLib, + ... +}: let + inherit (tsunamiLib) scriptPath; +in { + tsunami.scripts."split" = '' + width=$(tmux display -p "#{pane_width}") + height=$(tmux display -p "#{pane_height}") + + if (( $(echo "$width / $height > 2.5" | ${pkgs.bc}/bin/bc -l) )); then + tmux split-window -h "$@" + else + tmux split-window -v "$@" + fi + ''; + + tsunami.scripts."clean-sessions" = '' + current="$(tmux display -p '#{session_name}')" + + tmux list-sessions -F '#{session_name}' | while read -r line; do + if [[ "$line" != "$current" && "$line" =~ ^[[:digit:]]+$ ]]; then + tmux kill-session -t "$line" + fi + done + ''; + + tsunami.keys.global = [ + { + key = "C-w"; + exec = "kill-pane"; + } + { + key = "M-z"; + exec = "resize-pane -Z"; + } + { + key = "C-Enter"; + exec = ''run-shell "${scriptPath "split"} -c '#{?@default-path,#{@default-path},#{pane_current_path}}'"''; + } + { + key = "C-t"; + exec = "new-window -c '#{?@default-path,#{@default-path},#{pane_current_path}}'"; + } + { + key = "C-Tab"; + exec = "next-window"; + } + { + key = "C-S-Tab"; + exec = "previous-window"; + } + ]; + + tsunami.confs."windows" = '' + unbind -n MouseDown3Pane + set -g allow-rename on + set -g automatic-rename off + set -g renumber-windows on + set -g base-index 1 + + set-hook -ag client-detached 'run-shell ${scriptPath "clean-sessions"}' + set-hook -ag client-session-changed 'run-shell ${scriptPath "clean-sessions"}' + ''; +} |
