From 6166d0e554e9276f2e2b593eeeeae926353bbfe3 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Mon, 31 Jul 2023 13:46:24 -0400 Subject: [PATCH] tmux: better dwm emulation --- src/.config/tmux/tmux.conf | 48 +++++++++++++++++++++++++++++++++----- src/.local/bin/dwm.tmux | 4 +++- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/.config/tmux/tmux.conf b/src/.config/tmux/tmux.conf index a533a44..e1cbdaa 100644 --- a/src/.config/tmux/tmux.conf +++ b/src/.config/tmux/tmux.conf @@ -1,6 +1,6 @@ -unbind C-b -set-option -g prefix C-a -bind-key C-a send-prefix +# unbind C-b +# set-option -g prefix C-a +# bind-key C-a send-prefix set -g default-shell "/bin/fish" @@ -30,7 +30,9 @@ set -g command-alias[108] layouttile='run-shell "dwm.tmux layouttile"' set -g command-alias[109] float='run-shell "dwm.tmux float"' set -g command-alias[110] incmfact='run-shell "dwm.tmux incmfact"' set -g command-alias[111] decmfact='run-shell "dwm.tmux decmfact"' -set -g command-alias[112] window0='run-shell "dwm.tmux window 0"' + +# count from 1 like real dwm +set -g base-index 1 set -g command-alias[113] window1='run-shell "dwm.tmux window 1"' set -g command-alias[114] window2='run-shell "dwm.tmux window 2"' set -g command-alias[115] window3='run-shell "dwm.tmux window 3"' @@ -40,15 +42,49 @@ set -g command-alias[118] window6='run-shell "dwm.tmux window 6"' set -g command-alias[119] window7='run-shell "dwm.tmux window 7"' set -g command-alias[120] window8='run-shell "dwm.tmux window 8"' set -g command-alias[121] window9='run-shell "dwm.tmux window 9"' +set -g command-alias[112] window10='run-shell "dwm.tmux window 10"' set-hook -g pane-exited 'run-shell "dwm.tmux layouttile"' # these keybinds are odd because vim already has ctrl-hjkl for buffers +# and i'm already running dwm outside bind e newpane bind w newpanecurdir -bind c killpane +bind c new-window bind j nextpane bind k prevpane -bind -n C-b zoom +bind -n C-a zoom bind h decmfact bind l incmfact +bind 1 window1 +bind 2 window2 +bind 3 window3 +bind 4 window4 +bind 5 window5 +bind 6 window6 +bind 7 window7 +bind 8 window8 +bind 9 window9 +bind 0 window10 + +# sane dwm emulation when not already in dwm +bind -n M-1 window1 +bind -n M-2 window2 +bind -n M-3 window3 +bind -n M-4 window4 +bind -n M-5 window5 +bind -n M-6 window6 +bind -n M-7 window7 +bind -n M-8 window8 +bind -n M-9 window9 +bind -n M-0 window10 +bind -n M-j nextpane +bind -n M-k prevpane +bind -n M-Enter zoom +# dwm binds unfortunately don't transmit over terminal (i think) +bind -n M-n newpane +bind -n C-M-n newpanecurdir + +bind -T copy-mode-vi v send -X begin-selection +bind -T copy-mode-vi V send -X select-line +bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' diff --git a/src/.local/bin/dwm.tmux b/src/.local/bin/dwm.tmux index b980b23..8fe4e79 100755 --- a/src/.local/bin/dwm.tmux +++ b/src/.local/bin/dwm.tmux @@ -77,7 +77,9 @@ decmfact() { window() { window=$1 - tmux selectw -t $window + if ! tmux selectw -t $window; then + tmux neww -t $window + fi } if [ $# -lt 1 ]; then