theniceboy/.tmux.conf
2020-05-07 13:42:03 -04:00

266 lines
7.8 KiB
Bash

# 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 0
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 'bash ~/.config/tmux/fzf_panes.tmux update_mru_pane_ids'"
bind -n M-w run -b 'bash ~/.config/tmux/fzf_panes.tmux new_window'
# reload configuration
bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
bind-key -n 'M-`' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate / | fzf -m | paste -sd\\ -)\"'"
bind-key -n 'M-h' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate ~/ | fzf -m | paste -sd\\ -)\"'"
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
setw -g pane-base-index 1
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 1
# -- navigation
# create session
bind C-c new-session
# window management
bind -n M-o new-window -c "#{pane_current_path}"
bind -n M-O break-pane
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 u split-window -vb -c "#{pane_current_path}"
bind e split-window -v -c "#{pane_current_path}"
bind n split-window -hb -c "#{pane_current_path}"
bind i split-window -h -c "#{pane_current_path}"
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-! join-pane -t :1
bind -n M-@ join-pane -t :2
bind -n 'M-#' join-pane -t :3
bind -n 'M-$' join-pane -t :4
bind -n M-% join-pane -t :5
bind -n M-^ join-pane -t :6
bind -n M-& join-pane -t :7
bind -n M-* join-pane -t :8
bind -n M-( join-pane -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 -n M-Space next-layout
bind W choose-tree -Z
bind S choose-tree 'move-pane -v -s "%%"'
bind V choose-tree 'move-pane -h -s "%%"'
# pane resizing
bind -n M-N resize-pane -L 3
bind -n M-E resize-pane -D 3
bind -n M-U resize-pane -U 3
bind -n M-I resize-pane -R 3
set -g status-keys emacs
set -g mode-keys vi
bind -n M-v 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 n send-keys -X cursor-left
bind -T copy-mode-vi i send-keys -X cursor-right
bind -T copy-mode-vi u send-keys -X cursor-up
bind -T copy-mode-vi e send-keys -X cursor-down
bind -T copy-mode-vi h send-keys -X next-word-end
bind -T copy-mode-vi U send-keys -N 5 -X cursor-up
bind -T copy-mode-vi E send-keys -N 5 -X cursor-down
bind -T copy-mode-vi N send-keys -X start-of-line
bind -T copy-mode-vi I send-keys -X end-of-line
bind -T copy-mode-vi Y send-keys -X copy-end-of-line
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
bind -T copy-mode-vi = send-keys -X search-again
bind -T copy-mode-vi = send-keys -X search-reverse
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 s if-shell '[[ $(tmux show -g status | cut -d\ -f2) == "on" ]]' \
'set -g status off' \
'set -g status on'
# -- fzf_url
bind l 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 90
set -g status-right-length 140
setw -g window-status-separator ''
# default statusbar colors
set -g status-bg black
#set -g status-left ' #[fg=magenta,bold]❐ #S'
#set -g status-left '#[fg=brightyellow] #{?client_prefix,⌨ , } #[fg=magenta,bold] %Y-%m-%d %H:%M '
#set -g status-right '#(rainbarf --battery --remaining --bolt --tmux --rgb)'
#set -g status-left "#[fg=magenta,bold] %Y-%m-%d %H:%M | #[fg=brightblue]#(curl icanhazip.com) #(ifconfig en0 | grep 'inet ' | awk '{print \"en0 \" $2}') #(ifconfig en1 | grep 'inet ' | awk '{print \"en1 \" $2}') #(ifconfig en3 | grep 'inet ' | awk '{print \"en3 \" $2}') #(ifconfig tun0 | grep 'inet ' | awk '{print \"vpn \" $2}') "
setw -g window-status-format '#[fg=brightblue] #I #W '
setw -g window-status-current-format '#[fg=magenta,bold] #I #W:#F'
setw -g window-status-activity-style bg=black
setw -g window-status-bell-style bg=black
#set-window-option -g window-status-current-format "#[fg=colour235, bg=colour27]⮀#[fg=colour255, bg=colour27] #I ⮁ #W #[fg=colour27, bg=colour235]⮀"
set-option -g status-left "#(~/.config/tmux/tmux-powerline/powerline.sh left)"
set-option -g status-right "#(~/.config/tmux/tmux-powerline/powerline.sh right)"
run-shell ~/.config/tmux/extrakto/extrakto.tmux
#set-option -g status-utf8 on
#set -g status-left '#(rainbarf --battery --remaining --bolt --rgb)'
set-option default-path "$PWD"
# 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
# }
#
# "$@"