tmux: added dwm-like binds
This commit is contained in:
parent
32727866bd
commit
ee61c33b95
@ -2,16 +2,47 @@ unbind C-b
|
|||||||
set-option -g prefix C-a
|
set-option -g prefix C-a
|
||||||
bind-key C-a send-prefix
|
bind-key C-a send-prefix
|
||||||
|
|
||||||
bind u split-window -h
|
|
||||||
bind i split-window -v
|
|
||||||
unbind '"'
|
|
||||||
unbind %
|
|
||||||
|
|
||||||
bind h select-pane -L
|
|
||||||
bind l select-pane -R
|
|
||||||
bind j select-pane -D
|
|
||||||
bind k select-pane -U
|
|
||||||
|
|
||||||
set -g status off
|
set -g status off
|
||||||
|
|
||||||
set escape-time 20
|
set escape-time 20
|
||||||
|
|
||||||
|
# https://github.com/saysjonathan/dwm.tmux
|
||||||
|
# dwm-like binds for tmux
|
||||||
|
setenv -g tmuxdwm_version 0.1.0
|
||||||
|
setenv -g killlast 0 # Toggle killing last pane
|
||||||
|
setenv -g mfact 50 # Main pane area factor
|
||||||
|
|
||||||
|
set -g command-alias[100] newpane='run-shell "dwm.tmux newpane"'
|
||||||
|
set -g command-alias[101] newpanecurdir='run-shell "dwm.tmux newpanecurdir"'
|
||||||
|
set -g command-alias[102] killpane='run-shell "dwm.tmux killpane"'
|
||||||
|
set -g command-alias[103] nextpane='run-shell "dwm.tmux nextpane"'
|
||||||
|
set -g command-alias[104] prevpane='run-shell "dwm.tmux prevpane"'
|
||||||
|
set -g command-alias[105] rotateccw='run-shell "dwm.tmux rotateccw"'
|
||||||
|
set -g command-alias[106] rotatecw='run-shell "dwm.tmux rotatecw"'
|
||||||
|
set -g command-alias[107] zoom='run-shell "dwm.tmux zoom"'
|
||||||
|
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"'
|
||||||
|
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"'
|
||||||
|
set -g command-alias[116] window4='run-shell "dwm.tmux window 4"'
|
||||||
|
set -g command-alias[117] window5='run-shell "dwm.tmux window 5"'
|
||||||
|
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-hook -g pane-exited 'run-shell "dwm.tmux layouttile"'
|
||||||
|
|
||||||
|
# these keybinds are odd because vim already has ctrl-hjkl for buffers
|
||||||
|
bind -n C-e newpane
|
||||||
|
bind -n C-w newpanecurdir
|
||||||
|
bind -n C-c killpane
|
||||||
|
bind -n C-u nextpane
|
||||||
|
bind -n C-i prevpane
|
||||||
|
bind -n C-Enter zoom
|
||||||
|
bind h decmfact
|
||||||
|
bind l incmfact
|
||||||
|
114
src/.local/bin/dwm.tmux
Executable file
114
src/.local/bin/dwm.tmux
Executable file
@ -0,0 +1,114 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# https://github.com/saysjonathan/dwm.tmux
|
||||||
|
|
||||||
|
window_panes=
|
||||||
|
killlast=
|
||||||
|
mfact=
|
||||||
|
|
||||||
|
newpane() {
|
||||||
|
tmux \
|
||||||
|
split-window -t :.0\; \
|
||||||
|
swap-pane -s :.0 -t :.1\; \
|
||||||
|
select-layout main-vertical\; \
|
||||||
|
resize-pane -t :.0 -x ${mfact}%
|
||||||
|
}
|
||||||
|
|
||||||
|
newpanecurdir() {
|
||||||
|
tmux \
|
||||||
|
split-window -t :.0 -c "#{pane_current_path}"\; \
|
||||||
|
swap-pane -s :.0 -t :.1\; \
|
||||||
|
select-layout main-vertical\; \
|
||||||
|
resize-pane -t :.0 -x ${mfact}%
|
||||||
|
}
|
||||||
|
|
||||||
|
killpane() {
|
||||||
|
if [ $window_panes -gt 1 ]; then
|
||||||
|
tmux kill-pane -t :.\; \
|
||||||
|
select-layout main-vertical\; \
|
||||||
|
resize-pane -t :.0 -x ${mfact}%
|
||||||
|
else
|
||||||
|
if [ $killlast -ne 0 ]; then
|
||||||
|
tmux kill-window
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nextpane() {
|
||||||
|
tmux select-pane -t :.+
|
||||||
|
}
|
||||||
|
|
||||||
|
prevpane() {
|
||||||
|
tmux select-pane -t :.-
|
||||||
|
}
|
||||||
|
|
||||||
|
rotateccw() {
|
||||||
|
tmux rotate-window -U\; select-pane -t 0
|
||||||
|
}
|
||||||
|
|
||||||
|
rotatecw() {
|
||||||
|
tmux rotate-window -D\; select-pane -t 0
|
||||||
|
}
|
||||||
|
|
||||||
|
zoom() {
|
||||||
|
tmux swap-pane -s :. -t :.0\; select-pane -t :.0
|
||||||
|
}
|
||||||
|
|
||||||
|
layouttile() {
|
||||||
|
tmux select-layout main-vertical\; resize-pane -t :.0 -x ${mfact}%
|
||||||
|
}
|
||||||
|
|
||||||
|
float() {
|
||||||
|
tmux resize-pane -Z
|
||||||
|
}
|
||||||
|
|
||||||
|
incmfact() {
|
||||||
|
fact=$((mfact + 5))
|
||||||
|
if [ $fact -le 95 ]; then
|
||||||
|
tmux \
|
||||||
|
setenv mfact $fact\; \
|
||||||
|
resize-pane -t :.0 -x ${fact}%
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
decmfact() {
|
||||||
|
fact=$((mfact - 5))
|
||||||
|
if [ $fact -ge 5 ]; then
|
||||||
|
tmux \
|
||||||
|
setenv mfact $fact\; \
|
||||||
|
resize-pane -t :.0 -x ${fact}%
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
window() {
|
||||||
|
window=$1
|
||||||
|
tmux selectw -t $window
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "dwm.tmux.sh [command]"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
command=$1;shift
|
||||||
|
args=$*
|
||||||
|
set -- $(echo $(tmux display -p "#{window_panes}\n#{killlast}\n#{mfact}"))
|
||||||
|
window_panes=$1
|
||||||
|
killlast=$2
|
||||||
|
mfact=$3
|
||||||
|
|
||||||
|
case $command in
|
||||||
|
newpane) newpane;;
|
||||||
|
newpanecurdir) newpanecurdir;;
|
||||||
|
killpane) killpane;;
|
||||||
|
nextpane) nextpane;;
|
||||||
|
prevpane) prevpane;;
|
||||||
|
rotateccw) rotateccw;;
|
||||||
|
rotatecw) rotatecw;;
|
||||||
|
zoom) zoom;;
|
||||||
|
layouttile) layouttile;;
|
||||||
|
float) float;;
|
||||||
|
incmfact) incmfact;;
|
||||||
|
decmfact) decmfact;;
|
||||||
|
window) window $args;;
|
||||||
|
*) echo "unknown command"; exit 1;;
|
||||||
|
esac
|
Loading…
Reference in New Issue
Block a user