From ce441aebb784766b3c577991e210452d2a13b004 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 23 Jan 2023 21:25:01 +0200 Subject: Fixed formatting --- .config/tmux/tmux.conf | 391 +++++++++++++++++++------------------------------ 1 file changed, 154 insertions(+), 237 deletions(-) diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index b93a0fd..76d1203 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -4,127 +4,144 @@ # ██║ ██║╚██╔╝██║██║ ██║ ██╔██╗ # ██║ ██║ ╚═╝ ██║╚██████╔╝██╔╝ ██╗ # ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ -#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― -# Setting the prefix from C-b to C-s +#―――――――――――――――――――――――――――――――――――――――――― + +### Options ### + +# Setting the Prefix from Ctrl+b to Ctrl+s unbind C-b set -g prefix C-s -# Ensure that we can send Ctrl-S to other apps -bind C-s send-prefix #set -g prefix M-Space -#set -g prefix C-Space -#setting the delay between prefix and command -set-option -sg escape-time 10 -#set -s escape-time 0 -# Vi mode in tmux, can confirm this working by pressing :list-keys -T copy-mode-vi -# [ to enter copy-mode to allow copying text or view history buffer, including search with / and ?. Screenwise vertical movemont with or -set-window-option -g mode-keys vi -# Reload the file with Prefix r + +# Ensure that we can send Ctrl+s to other apps +bind C-s send-prefix + +# Setting the delay between Prefix and Command +set -sg escape-time 10 +#set-option -sg escape-time 10 + +# Reload tmux with r #bind r source-file ~/.tmux.conf \; display "Reloaded!" bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!" + +# Use Ctrl+l to clear terminal +bind C-l send-keys 'C-l' + +# Scrollback #set -g history-limit 10000 -# use the mouse -#set-window-option -g mode-mouse on +# Mouse +set -g mouse on #set -g mouse-select-pane on #set -g mouse-resize-pane on #set -g mouse-select-window on -# pane movement -bind-key j command-prompt -p "send pane to:" "join-pane -t '%%'" +# Focus events, allow supported requests from applications to passthrough/run in tmux +set-option -g focus-events on + +# Aggresive resizing, useful when using "grouped sessions" and multi-monitor setup +setw -g aggressive-resize on + +# Update the TERM variable of terminal emulator when creating a new session or attaching a existing session +set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM' + +## Popup scratch session +#bind -n M-g display-popup -E "tmux new-session -A -s scratch" -# Pane resizing, default is D,U,L,R +## Toggle popup scratch session +bind-key -n M-g if-shell -F '#{==:#{session_name},scratch}' { +detach-client +} { +display-popup -E "tmux new-session -A -s scratch" +} + +# Non-popup +#bind C-k new-window -n "session-switcher" "\ +# tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ +# sed '/^$/d' |\ +# fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ +# xargs tmux switch-client -t" + +# Popup +bind -n M-f display-popup -E "\ + tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ + sed '/^$/d' |\ + fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ + xargs tmux switch-client -t" + +# Quick window select +bind -n M-? list-keys +bind -n M-1 select-window -t :=1 +bind -n M-2 select-window -t :=2 +bind -n M-3 select-window -t :=3 +bind -n M-4 select-window -t :=4 +bind -n M-5 select-window -t :=5 +bind -n M-6 select-window -t :=6 +bind -n M-7 select-window -t :=7 +bind -n M-8 select-window -t :=8 +bind -n M-9 select-window -t :=9 +bind -n M-0 select-window -t :=0 + + +#―――――――――――――――――――――――――――――――――――――――――― + +### Pane Movement/Control ### + +# Smart pane switching with awareness of Vim splits. +# See: https://github.com/christoomey/vim-tmux-navigator +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'" +bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' +bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' +bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' +bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' +tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' +if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" +if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" + +bind-key -T copy-mode-vi 'C-h' select-pane -L +bind-key -T copy-mode-vi 'C-j' select-pane -D +bind-key -T copy-mode-vi 'C-k' select-pane -U +bind-key -T copy-mode-vi 'C-l' select-pane -R +bind-key -T copy-mode-vi 'C-\' select-pane -l +# Change horizontal split % and Vertical split " to h and v respectively and change current working directory +bind v split-window -h -c "#{pane_current_path}" +bind h split-window -v -c "#{pane_current_path}" + +# Pane resizing, then shift + vi-directional keys, default is D,U,L,R bind -r H resize-pane -L 20 bind -r J resize-pane -D 20 bind -r K resize-pane -U 20 bind -r L resize-pane -R 20 +# Pane resizing, then alt + vi-directional keys bind-key M-j resize-pane -D 5 bind-key M-k resize-pane -U 5 bind-key M-h resize-pane -L 5 bind-key M-l resize-pane -R 5 -# Hide a pane and bring it back with ! and @ respectively +# Hide a pane and bring it back with ! and @ respectively bind-key ! break-pane -d -n _hidden_pane bind-key @ join-pane -s $.0 -# enable activity alerts -#setw -g monitor-activity on -#set -g visual-activity on - -# Update the status bar every sixty seconds -#set -g status-interval 60 - -# set colors for the active window -#setw -g window-status-current-fg white -#setw -g window-status-current-bg red -#setw -g window-status-current-attr bright -#set -g status-style fg="#000000",bg="#53E2AE" -#set -g pane-active-border-style bg=default,fg="#fe8019" -#set -g pane-border-style fg="#53E2AE" - -## COLOUR (Solarized light) - -## default statusbar colors -#set-option -g status-bg default -#set-option -g status-fg green -#set-option -g status-attr default -# -## default window title colors -#set-window-option -g window-status-fg magenta -#set-window-option -g window-status-bg default -#set-window-option -g window-status-attr dim -# -#set -g status-left-length 85 -#set -g status-left "#[fg=yellow bg=default]#h #[fg=blue] #S #[fg=yellow] #I " -#set -g window-status-current-format "#[fg=black,bold bg=default]│#[fg=white bg=cyan]#W#[fg=black,bold bg=default]│" -#set -g status-right "#[fg=magenta] #[bg=gray] %b %d %Y %l:%M %p" -#set -g status-justify centre - - -# active window title colors -#set-window-option -g window-status-current-fg cyan -#set-window-option -g window-status-current-bg default -#set-window-option -g window-status-current-attr bright - - -# pane border -# set-option -g pane-border-fg black -# set-option -g pane-border-bg black -# set-option -g pane-active-border-fg red -# set-option -g pane-active-border-bg default -# allow 'autoread' to work in neovim by focus events -# focus events enabled for terminals that support them -set-option -g focus-events on - -# super useful when using "grouped sessions" and multi-monitor setup -setw -g aggressive-resize on - - - -set -g mouse on - -# Vi mode in tmux, can confirm this working by pressing :list-keys -T copy-mode-vi -# [ to enter copy-mode to allow copying text or view history buffer, including search with / and ?. Screenwise vertical movemont with or -set-window-option -g mode-keys vi +# Send Pane to another session/window +bind-key j command-prompt -p "send pane to:" "join-pane -t '%%'" -# change selection and enter to vi keybinding -#bind-key -T copy-mode-vi 'v' send -X begin-selection -#bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel -# X clipboard integration -# Vim style -#bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -sel clip > /dev/null" +#―――――――――――――――――――――――――――――――――――――――――― -#for copying to sys clipboard -#bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard" -#bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard" -#bind -T copy-mode-vi C-c send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard" +### Copy/Paste ### -# map copy mode to ctrl+alt+v -bind-key -n 'M-v' copy-mode +# Set Vi copy mode, use [ to enter copy mode +setw -g mode-keys vi # `:list-keys -T copy-mode-vi` to confirm -bind-key -T copy-mode-vi v send -X begin-selection +# Change selection and enter to vi keybinding +bind-key -T copy-mode-vi 'v' send -X begin-selection +bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel +# Copy to system clipboard (requires xclip) if-shell -b 'echo $XDG_SESSION_TYPE | grep -q x11' "\ bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \ bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \ @@ -140,79 +157,13 @@ if-shell -b 'echo $XDG_SESSION_TYPE | grep -q wayland' "\ bind-key C-M-v run 'cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer'" +#―――――――――――――――――――――――――――――――――――――――――― +### Colors ### -# Vim style copy to clipboard -#bind-key p run "xclip -o -sel clip | tmux load-buffer - ; tmux paste-buffer" - - -# Change split % and " to h and v and change current working directory -bind v split-window -h -c "#{pane_current_path}" -bind h split-window -v -c "#{pane_current_path}" - - -# smart pane switching with awareness of vim splits -bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L" -bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" -bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U" -bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" -#bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l" - -# use prefix + l to clear terminal -bind C-l send-keys 'C-l' -## set the default TERM -#set-option -g default-terminal "screen-256color" -#set-option -g default-terminal "tmux-256color" -#set -g default-terminal screen -# update the TERM variable of terminal emulator when creating a new session or attaching a existing session -#set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM' -# determine if we should enable 256-colour support -#if "[[ ${TERM} =~ 256color || ${TERM} == fbterm ]]" 'set -g default-terminal screen-256color' -#set -g default-terminal "tmux-256color" -#set -ga terminal-overrides ",xterm-256color:Tc" -#set-option -g default-terminal "tmux-256color" +# Set 256 color terminal set-option -sa terminal-overrides ",tmux-256color:Tc" -#set-option -sa terminal-overrides ",xterm*:Tc" -set-option -sa terminal-overrides ",xterm*:Tc,alacritty*:Tc" -# Enable RGB colour if running in xterm(1) -#set-option -sa terminal-overrides ",xterm*:Tc" -#set -ga terminal-overrides ",*256col*:Tc" - -## Detach from current session -#bind -n M-d detach-client -# -## Popup scratch session -#bind -n M-g display-popup -E "tmux new-session -A -s scratch" -# -## non-popup -#bind C-j new-window -n "session-switcher" "\ -# tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ -# sed '/^$/d' |\ -# fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ -# xargs tmux switch-client -t" -## popup -#bind C-j display-popup -E "\ -# tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ -# sed '/^$/d' |\ -# fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ -# xargs tmux switch-client -t" -#bind -n M-f display-popup -E "\ -# tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ -# sed '/^$/d' |\ -# fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ -# xargs tmux switch-client -t" -# -#bind -n M-? list-keys -#bind -n M-1 select-window -t :=1 -#bind -n M-2 select-window -t :=2 -#bind -n M-3 select-window -t :=3 -#bind -n M-4 select-window -t :=4 -#bind -n M-5 select-window -t :=5 -#bind -n M-6 select-window -t :=6 -#bind -n M-7 select-window -t :=7 -#bind -n M-8 select-window -t :=8 -#bind -n M-9 select-window -t :=9 -#bind -n M-0 select-window -t :=0 +#set-option -sa terminal-overrides ",xterm*:Tc,alacritty*:Tc" # Colors for pane borders(default) setw -g pane-border-style fg=white @@ -223,110 +174,76 @@ setw -g window-style fg=colour240 setw -g window-active-style fg=white -#set -g focus-events on -#set -g status-style bg=default -# Set the position of window lists -#set -g status-justify centre -# Set the status bar position +#―――――――――――――――――――――――――――――――――――――――――― + +### Status ### + set -g status-position bottom # [top, bottom] set -g status on set -g status-interval 1 - - -#set-option -g status-style bg=default set -g status-style fg=#50fa7b,bg=default -#set -g status-style fg=DeepSkyBlue1,bg=black -#set -g status-style fg=black,bg=gray - -#set -g status-left-style default -# Display the session name -#set -g status-left "#[fg=green] ❐ #S #[default]" ## Left -#set -g status-left '' +#set -g status-left "" set -g status-left-length 60 -#set -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" -#bind o run-shell "tmux-toggle-option.sh set-option status-left on off" -#bind o set-option -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" \; display-message 'Status-left #{?status,off,on}' -#set set-option status-left -#bind o set-option status-left "#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" # toggle left-status script off -#bind o run-shell "if [[ `tmux show-option -w status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" ]]; then set -g status-left "#[bg=50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" else set -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" fi -#bind C-o set-option status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" # toggle left status script on -#bind -T root o \ -# set-option status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" \;\ # toggle left status script on -# -#bind -T off o \ -# set-option status-left "#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" \;\ # toggle left-status script off - -#bind Space if -F '#{==:#{@lastlayout},eh}' 'selectl even-vertical; set -w @lastlayout ev' 'selectl even-horizontal; set -w @lastlayout eh' - -#set -g status-left - -set -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" -#bind -Troot o set-g status-left "#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" -#bind -Tempty o set-g status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" -#set-hook -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]" -#bind o if -F '#{==:#{@set -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]"}' 'set -g status-left "#[bg=#50fa7b,fg=black] ❐ #S #( ~/.config/tmux/left-status.sh ) #[fg=#50fa7b,bg=default]"' -#set-hook -g after-select-layout "set -Fw @lastlayout '#{hook_argument_0}'" -#bind o if -F '#{==:#{@lastlayout},even-horizontal}' 'selectl even-vertical' 'selectl even-horizontal' - - -#set -g status-left "#[fg=DeepSkyBlue1] ❐ #S #( ~/.config/tmux/left-status.sh )" -#set -g status-left "#[fg=black] ❐ #S #( ~/.config/tmux/left-status.sh )" - -# Highlight the current window. -setw -g window-status-current-style fg=#50fa7b,bg=default,bright -#setw -g window-status-current-style fg=DeepSkyBlue1,bg=black,bright -#setw -g window-status-current-style fg=color235,bg=silver,bright -set -g window-status-current-format ' #I:#W ' -#set -g status-format[0] '#[align=left] ❐ #S #( ~/.config/tmux/left-status.sh )#[align=absolute-centre]#[list=on] #I #W #[nolist]#[align=right] %H:%M %d-%m-%Y #H ' +set -g status-left "#[fg=#50fa7b,bg=default]#[bg=#50fa7b,fg=black] ❐ #S #[fg=#50fa7b,bg=default]" + +## Centre +set -g window-status-current-format "#[bg=default,fg=#50fa7b]#[fg=black,bg=#50fa7b] #I:#W #[bg=default,fg=#50fa7b]" set -g status-justify absolute-centre + ## Right -# Set right side status bar length and style set-option -g status-right "" set -g status-right-length 60 -#set -g status-right-length 140 -#set -g status-right-style default -#set -ag status-right "#[fg=black] %H:%M %d-%m-%Y #H " -set -g status-right "#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[bg=default,fg=#50fa7b]#[bg=#50fa7b,fg=black]#( ~/.config/tmux/right-status.sh ) %H:%M | %d-%b-%y " +set -g status-right "#[fg=#50fa7b,bg=default] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #[bg=default,fg=#50fa7b]#[bg=#50fa7b,fg=black] %H:%M #[bg=default,fg=#50fa7b]" + +## Reload Status with IP addr, Cpu, Mem and Date bind a run-shell ~/.config/tmux/tmux-toggle-option.sh -#set -g status-right "#(vmstat -SM 1 2 | awk 'END {print \"cpu:\"100-$15\"%\" \" mem:\"512-$4-$5-$6\"M\"}')#[default] %R" -#set -g status-right "#[fg=green] #22T | #(top -l 2 -FR -n 0 | egrep 'CPU|PhysMem' | awk 'FNR==3{print $8+$10}FNR==4{print $8}' ORS=%%/ | sed 's/..$//')/#(du -hs /var/vm | awk '{print $1}') | %a %b %d %Y %H:%M" -#set -ag status-right "#[fg=DeepSkyBlue1] #( ~/.config/tmux/right-status.sh ) %H:%M %d-%m-%Y #H " -#set -ag status-right "#[fg=black] #( ~/.config/tmux/right-status.sh ) %H:%M %d-%m-%Y #H " +## Reload Config/Status silently +bind b source-file ~/.config/tmux/tmux.conf + + +#―――――――――――――――――――――――――――――――――――――――――― + +### list of plugins ### -# list of plugins -set -g @plugin 'tmux-plugins/tpm' -#set -g @plugin 'tmux-plugins/tmux-sensible' -set -g @plugin 'tmux-plugins/tmux-resurrect' -set -g @plugin 'tmux-plugins/tmux-continuum' -set -g @plugin 'christoomey/vim-tmux-navigator' -#set -g @plugin 'tmux-plugins/tmux-yank' +set -g @plugin "tmux-plugins/tpm" +#set -g @plugin "tmux-plugins/tmux-sensible" +set -g @plugin "tmux-plugins/tmux-resurrect" +set -g @plugin "tmux-plugins/tmux-continuum" +set -g @plugin "christoomey/vim-tmux-navigator" +#set -g @plugin "tmux-plugins/tmux-yank" -# Plugins settings +#―――――――――――――――――――――――――――――――――――――――――― + +### Plugins settings ### + # Plugin to save and restore tmux sessions after restart # * Save with: prefix + Ctrl-s # * Restore with: prefix + Ctlr-r # restore vim and nvim sessions as well # for vim - set -g @resurrect-strategy-vim 'session' + set -g @resurrect-strategy-vim "session" # for neovim - set -g @resurrect-strategy-nvim 'session' + set -g @resurrect-strategy-nvim "session" # Automatic restore - set -g @continuum-restore 'on' + set -g @continuum-restore "on" # Change default save and restore keybindings - set -g @resurrect-save 'W' - set -g @resurrect-restore 'E' -# set -g @continuum-boot 'on' + set -g @resurrect-save "W" + set -g @resurrect-restore "E" +#set -g @continuum-boot "on" ## Restore Panes -# set -g @resurrect-capture-pane-contents 'on' + set -g @resurrect-capture-pane-contents "on" # This a hook for tmux-resurrect which tells it to kill session 0 before restoring the panels -set -g @resurrect-hook-pre-restore-pane-processes 'tmux switch-client -n && tmux kill-session -t=0' +set -g @resurrect-hook-pre-restore-pane-processes "tmux switch-client -n && tmux kill-session -t=0" # plugin uninstall # Delete or comment out the plugin in .tmux.conf. # Press + alt + u to remove the plugin. # TMUX plugin manager (keep at the bottom of tmux.conf) -#run -b '~/.tmux/plugins/tpm/tpm' -run -b '~/.config/tmux/plugins/tpm/tpm' +#run -b "~/.tmux/plugins/tpm/tpm" +run -b "~/.config/tmux/plugins/tpm/tpm" + + +#―――――――――――――――――――――――――――――――――――――――――― -- cgit v1.2.3