mirror of
https://github.com/theniceboy/.config.git
synced 2025-12-26 14:44:57 +08:00
tmux wip
This commit is contained in:
parent
22d1b81734
commit
ee0575efd5
2 changed files with 225 additions and 6 deletions
229
.tmux.conf
229
.tmux.conf
|
|
@ -1,9 +1,226 @@
|
|||
set -g default-terminal "tmux-256color"
|
||||
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'
|
||||
# cat << EOF > /dev/null
|
||||
|
||||
# -- general
|
||||
set -g default-terminal 'tmux-256color'
|
||||
set -ga terminal-overrides ',xterm-256color:RGB'
|
||||
setw -g xterm-keys on
|
||||
set -s escape-time 100
|
||||
set -sg repeat-time 300
|
||||
set -s focus-events on
|
||||
set -g mouse on
|
||||
set -sg exit-empty on
|
||||
|
||||
set -q -g status-utf8 on
|
||||
setw -q -g utf8 on
|
||||
|
||||
set -g visual-activity off
|
||||
setw -g monitor-activity off
|
||||
setw -g monitor-bell off
|
||||
|
||||
set -g history-limit 10000
|
||||
|
||||
set-hook -g pane-focus-in "run -b 'sh ~/scripts/fzf_panes.tmux update_mru_pane_ids'"
|
||||
bind -n M-w run -b 'sh ~/scripts/fzf_panes.tmux new_window'
|
||||
|
||||
# reload configuration
|
||||
bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
|
||||
|
||||
set -ga update-environment '\
|
||||
DISPLAY DBUS_SESSION_BUS_ADDRESS \
|
||||
QT_IM_MODULE QT_QPA_PLATFORMTHEME \
|
||||
SESSION_MANAGER \
|
||||
XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME\
|
||||
XDG_MENU_PREFIX XDG_RUNTIME_DIR XDG_SESSION_CLASS \
|
||||
XDG_SESSION_DESKTOP XDG_SESSION_TYPE XDG_CURRENT_DESKTOP \
|
||||
XMODIFIERS \
|
||||
FZF_DEFAULT_OPTS \
|
||||
'
|
||||
set-hook -g client-attached 'run -b "cut -c3- ~/.tmux.conf | sh -s update_env_event"'
|
||||
|
||||
# -- prefix
|
||||
unbind C-b
|
||||
set -g prefix 'C-s'
|
||||
|
||||
# -- display
|
||||
set -g base-index 1
|
||||
set -sg escape-time 0
|
||||
setw -g pane-base-index 1
|
||||
|
||||
set -g status-interval 2
|
||||
set -g status-left "#S #[fg=green,bg=black]#(tmux-mem-cpu-load -q --interval 2)#[default]"
|
||||
set -g status-left-length 60
|
||||
setw -g automatic-rename on
|
||||
set -g renumber-windows on
|
||||
|
||||
set -g set-titles on
|
||||
|
||||
set -g display-panes-time 2000
|
||||
set -g display-time 2000
|
||||
|
||||
set -g status-interval 10
|
||||
|
||||
# -- navigation
|
||||
|
||||
# create session
|
||||
bind C-c new-session
|
||||
|
||||
# window management
|
||||
bind -n M-o new-window
|
||||
bind -n M-Q kill-pane
|
||||
|
||||
# window navigation
|
||||
unbind n
|
||||
unbind p
|
||||
unbind 1
|
||||
unbind 2
|
||||
unbind 3
|
||||
unbind 4
|
||||
unbind 5
|
||||
unbind 6
|
||||
unbind 7
|
||||
unbind 8
|
||||
unbind 9
|
||||
unbind 0
|
||||
bind -r C-p previous-window
|
||||
bind -r C-n next-window
|
||||
|
||||
bind s split-window -v
|
||||
bind v split-window -h
|
||||
|
||||
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
|
||||
|
||||
|
||||
# pane navigation
|
||||
bind 1 select-pane -t:.1
|
||||
bind 2 select-pane -t:.2
|
||||
bind 3 select-pane -t:.3
|
||||
bind 4 select-pane -t:.4
|
||||
bind 5 select-pane -t:.5
|
||||
bind 6 select-pane -t:.6
|
||||
bind 7 select-pane -t:.7
|
||||
bind 8 select-pane -t:.8
|
||||
bind 9 select-pane -t:.9
|
||||
bind 0 select-pane -t:.10
|
||||
bind -n M-n select-pane -L
|
||||
bind -n M-e select-pane -D
|
||||
bind -n M-u select-pane -U
|
||||
bind -n M-i select-pane -R
|
||||
bind > swap-pane -D
|
||||
bind < swap-pane -U
|
||||
bind | swap-pane
|
||||
|
||||
bind W choose-tree -Z
|
||||
bind S choose-tree 'move-pane -v -s "%%"'
|
||||
bind V choose-tree 'move-pane -h -s "%%"'
|
||||
|
||||
# pane resizing
|
||||
bind -r N resize-pane -L 2
|
||||
bind -r E resize-pane -D 2
|
||||
bind -r U resize-pane -U 2
|
||||
bind -r I resize-pane -R 2
|
||||
|
||||
set -g status-keys emacs
|
||||
set -g mode-keys vi
|
||||
|
||||
bind Enter copy-mode
|
||||
|
||||
bind -T copy-mode-vi v send-keys -X begin-selection
|
||||
bind -T copy-mode-vi C-v send-keys -X rectangle-toggle
|
||||
bind -T copy-mode-vi i send-keys -X select-word
|
||||
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
|
||||
|
||||
bind-key -T vi-copy v begin-selection
|
||||
bind-key -T vi-copy V select-line
|
||||
bind-key -T vi-copy r rectangle-toggle
|
||||
|
||||
|
||||
bind b list-buffers
|
||||
bind p paste-buffer
|
||||
|
||||
# -- toggle_syn_input
|
||||
bind C-g if-shell '[[ $(tmux showw synchronize-panes | cut -d\ -f2) == "on" ]]' \
|
||||
'setw synchronize-panes off; set -g pane-border-style fg=magenta' \
|
||||
'setw synchronize-panes on; set -g pane-border-style fg=red'
|
||||
|
||||
# -- toggle_status
|
||||
bind '#' if-shell '[[ $(tmux show -g status | cut -d\ -f2) == "on" ]]' \
|
||||
'set -g status off' \
|
||||
'set -g status on'
|
||||
|
||||
# -- fzf_url
|
||||
bind u run -b 'cut -c3- ~/.tmux.conf | sh -s fzf_url'
|
||||
|
||||
run 'cut -c3- ~/.tmux.conf | sh -s bind_with_sys_clipboard'
|
||||
|
||||
# -- theme
|
||||
set -g status off
|
||||
|
||||
# panes
|
||||
setw -g pane-border-status bottom
|
||||
setw -g pane-border-format '#[bold]#{?#{&&:#{pane_active},#{client_prefix}},#[underscore],}\
|
||||
#{?pane_active,❐ #S:#I/#{session_windows} ,}#{?window_zoomed_flag,⬢,❄} #P ⇒ #{pane_tty} #{pane_current_command}'
|
||||
set -g pane-active-border-style fg=brightblue
|
||||
set -g pane-border-style fg=magenta
|
||||
|
||||
# windows
|
||||
set -g status-justify 'centre'
|
||||
set -g status-left-length '80'
|
||||
set -g status-right-length '80'
|
||||
setw -g window-status-separator ''
|
||||
|
||||
# default statusbar colors
|
||||
set -g status-bg black
|
||||
set -g status-left ' #[fg=magenta,bold]❐ #S'
|
||||
set -g status-right '#[fg=brightyellow] #{?client_prefix,⌨ , } #[fg=magenta,bold] %Y-%m-%d %H:%M '
|
||||
setw -g window-status-format '#[fg=magenta,bold] #I #W '
|
||||
setw -g window-status-current-format '#[fg=brightblue,bold] #I #W:#F'
|
||||
setw -g window-status-activity-style bg=black
|
||||
setw -g window-status-bell-style bg=black
|
||||
|
||||
# EOF
|
||||
# bind_with_sys_clipboard() {
|
||||
# if [[ -x $(command -v xsel) ]]; then
|
||||
# cmd='xsel -i -b'
|
||||
# elif [[ -x $(command -v xclip) ]]; then
|
||||
# cmd='xclip -i -selection clipboard'
|
||||
# fi
|
||||
# if [[ -n $cmd ]]; then
|
||||
# while IFS= read -r line; do
|
||||
# [[ -z $line ]] && continue
|
||||
# bind_key=$(printf '%s' "$line" |
|
||||
# sed -E "s/copy-selection(-and-cancel)?$/copy-pipe\1 \"$cmd\"/g")
|
||||
# eval "tmux $bind_key"
|
||||
# done <<< $(tmux list-keys | grep -E 'copy-selection|copy-pipe')
|
||||
# fi
|
||||
# }
|
||||
#
|
||||
# fzf_url() {
|
||||
# local ip4_seg="(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
|
||||
# local path_set="[-a-zA-Z0-9@:%_\+\.~#?&//=]"
|
||||
# local url_re="(https?|ftp|file)://($path_set+|(($ip4_seg\.){3,3}$ip4_seg$path_set*))"
|
||||
# local -a url=($(tmux capture-pane -S - -Jp | grep -oE "$url_re"))
|
||||
# if [[ -z $url ]]; then
|
||||
# return 0
|
||||
# else
|
||||
# printf "%s\n" ${url[@]} |
|
||||
# sort -u |
|
||||
# nl -w3 -s ' ' |
|
||||
# fzf-tmux -d 25% --multi --exit-0 --cycle --reverse |
|
||||
# awk '{print $2}' |
|
||||
# xargs -I {} xdg-open {} &> /dev/null
|
||||
# fi
|
||||
# }
|
||||
#
|
||||
# update_env_event() {
|
||||
# local event='client-attached'
|
||||
# local event_dir=${TMUX%%,*}-event
|
||||
# mkdir -p $event_dir 2>/dev/null
|
||||
# rm $event_dir/$event-pane* 2>/dev/null
|
||||
# tmux list-panes -a -F '#D' | sed -E "s|^(.*)$|$event_dir/$event-pane-\1|g" | xargs touch
|
||||
# }
|
||||
#
|
||||
# "$@"
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ alias ac='sudo tlp ac'
|
|||
alias gy='git-yolo'
|
||||
alias nb='newsboat -r'
|
||||
alias nt="sh -c 'cd $(pwd); st' > /dev/null 2>&1 &"
|
||||
alias ta='tmux a'
|
||||
alias tm='tmux'
|
||||
|
||||
bindkey -v
|
||||
bindkey -M vicmd "k" vi-insert
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue