summaryrefslogtreecommitdiff
path: root/modules/common/defaultGlobalKeys.nix
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-07-15 06:54:33 -0500
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-07-15 06:54:33 -0500
commit8b990276c5e9abccd772694b1f7232d8b49b634c (patch)
tree23f4c3713c538f435354270de2005475c50955d0 /modules/common/defaultGlobalKeys.nix
initial commit
Diffstat (limited to 'modules/common/defaultGlobalKeys.nix')
-rw-r--r--modules/common/defaultGlobalKeys.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/modules/common/defaultGlobalKeys.nix b/modules/common/defaultGlobalKeys.nix
new file mode 100644
index 0000000..fc3c669
--- /dev/null
+++ b/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"}'
+ '';
+}