ref(tmux): aliases

This commit is contained in:
thek4n 2024-06-04 08:34:19 +03:00
parent ac072c30de
commit 461f6c023d
4 changed files with 45 additions and 28 deletions

View File

@ -1,5 +1,38 @@
# vim: ft=tmux
set -g command-alias[101] kill='kill-session -t'
set -g command-alias[102] k='kill-session -t'
set -g command-alias[103] reload-config='source-file ~/.config/tmux/tmux.conf ; display-message "Config reloaded..."'
set -g command-alias[104] detect-panes='
set -g display-time $_tmux_display_panes_time
display-message
display-panes
set -g display-time $_tmux_display_time
'
set -g command-alias[105] stash-pane='if-shell "tmux join-pane -l $_tmux_main_pane_size -h -s stash" "" "break-pane -d -n stash"'
set -g command-alias[106] detach-other='if -F "#{session_many_attached}" {
confirm-before -p "Detach other clients? (y/n)" "detach -a"
} {
display "Session has only 1 client attached"
}'
set -g command-alias[107] toggle-synchronize-panes='
if -F "#{pane_synchronized}" "setw synchronize-panes off" "setw synchronize-panes on"
'
# Choose session with key index starting from 1
set -g command-alias[108] choose-tree-index="
choose-tree -ZsK '#{?#{e|<:#{line},9},#{e|+:1,#{line}},#{?#{e|<:#{line},35},M-#{a:#{e|+:97,#{e|-:#{line},9}}},}}'
"
set -g command-alias[109] toggle-zoom-pane='resize-pane -Z'
set -g command-alias[110] default-layout="
resize-pane -x $_tmux_main_pane_size
select-layout '6c98,213x55,0,0{72x55,0,0,72,140x55,73,0,73}'
"

View File

@ -22,8 +22,7 @@ bind -T off F12 {
bind F12 send-keys F12
# Choose session with key index starting from 1
bind s choose-tree -ZsK '#{?#{e|<:#{line},9},#{e|+:1,#{line}},#{?#{e|<:#{line},35},M-#{a:#{e|+:97,#{e|-:#{line},9}}},}}'
bind s choose-tree-index
# Switch new session
@ -42,12 +41,7 @@ bind C-q confirm-before -p "kill other windows? (y/n)" "kill-window -a"
bind d detach
bind D choose-client -Z
bind C-d if -F '#{session_many_attached}' {
confirm-before -p "Detach other clients? (y/n)" "detach -a"
} {
display "Session has only 1 client attached"
}
bind C-d detach-other
bind r command-prompt -I '#W' -p "New window name:" "rename-window '%%'"
bind R command-prompt -I '#S' -p "New session name:" "rename-session '%%'"
@ -59,7 +53,7 @@ bind H command-prompt -p "Remote host:" "new-session -s 'ssh-%1' -A ssh %1 \; se
bind ';' command-prompt
bind -n M-f resize-pane -Z
bind -n M-f toggle-zoom-pane
bind l choose-window -w -Z 'link-window -s "%%" -a'
@ -96,16 +90,11 @@ bind -n M-K swap-pane -d -Z -t '{up-of}'
# Sync panes
bind o if -F '#{pane_synchronized}' 'setw synchronize-panes off' 'setw synchronize-panes on'
bind o toggle-synchronize-panes
bind O setw synchronize-panes off
bind i {
set -g display-time $_tmux_display_panes_time
display-message
display-panes
set -g display-time $_tmux_display_time
}
bind i detect-panes
# Windows navigation
@ -136,9 +125,6 @@ bind -n 'M-(' if-shell 'tmux join-pane -d -h -t :9' '' 'break-pane -t 9 -d -n 9'
bind -n 'M-)' if-shell 'tmux join-pane -d -h -t :10' '' 'break-pane -t 10 -d -n 10'
_tmux_main_pane_size="66%"
_tmux_other_pane_size="34%"
set -g main-pane-width '$_tmux_other_pane_size'
set -g main-pane-height '100%'
@ -155,14 +141,9 @@ bind \\ split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Hide pane
bind -n M-q if-shell 'tmux join-pane -l $_tmux_main_pane_size -h -s stash' '' 'break-pane -d -n stash'
bind -n M-q stash-pane
# Default layout size
bind -n M-r {
resize-pane -x $_tmux_main_pane_size
select-layout '6c98,213x55,0,0{72x55,0,0,72,140x55,73,0,73}'
}
bind -n M-r default-layout
# Swap left pane
bind -n M-s swap-pane -t '{left-of}'

View File

@ -3,6 +3,9 @@
_tmux_display_panes_time=4000
_tmux_display_time=450
_tmux_main_pane_size="66%"
_tmux_other_pane_size="34%"
set -s exit-unattached off
set -s exit-empty off

View File

@ -9,7 +9,7 @@ WORKING_PROJECT="$HOME/dotfiles"
if ! tmux has-session -t "$SESSION"; then
tmux new-session -s "$SESSION" -d -n "$MAINW" -c "$WORKING_PROJECT"
tmux splitw -t "$SESSION:$MAINW" -d -b -h -l "$_tmux_new_pane_size" -c '#{pane_current_path}'
tmux splitw -t "$SESSION:$MAINW" -d -b -h -l "$_tmux_other_pane_size" -c '#{pane_current_path}'
tmux send-keys -t "$SESSION:$MAINW.1" "git pull" Enter
tmux send-keys -t "$SESSION:$MAINW.2" '$EDITOR' Enter
tmux send-keys -t "$SESSION:$MAINW.2" ':Telescope find_files' Enter