tb-dotfiles/chezmoi/dot_tmux.conf

124 lines
5.7 KiB
Text
Raw Normal View History

2022-04-22 16:21:40 -04:00
## General configuration {
set -g default-terminal "xterm-256color"
if 'infocmp -x tmux-256color > /dev/null 2>&1' 'set -g default-terminal "tmux-256color"'
setw -g xterm-keys on # tmux will generate xterm(1) -style function key sequences; these have a number included to indicate modifiers such as Shift, Alt or Ctrl.
set -s escape-time 10 # (default 500ms) Set the time in milliseconds for which tmux waits after an escape is input to determine if it is part of a function or meta key sequences.
set -sg repeat-time 600 # (default 500ms) Allow multiple commands to be entered without pressing the prefix-key again in the specified time milliseconds. Whether a key repeats may be set when it is bound using the -r flag to bind-key. Repeat is enabled for the default keys bound to the resize-pane command.
set -s focus-events on # When enabled, focus events are requested from the terminal if supported and passed through to applications running in tmux. Attached clients should be detached and attached again after changing this option.
setw -q -g utf8 on
set -g history-limit 100000 # increate the history
# edit config
bind e new-window -n "~/.tmux.conf" "\"\${EDITOR:-vim}\" ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display \"~/.tmux.conf sourced\""
# reload config
bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
## } General configuration
## Display {
set -g base-index 1 # start window numbering at 1 -- easier on the hands
setw -g pane-base-index 1 # make pane numbering consistent with windows
setw -g automatic-rename on # rename window to reflect current program
set -g renumber-windows on # renumber windows when a window is closed
set -g set-titles on # set terminal title
set -g display-panes-time 800 # slightly longer pane indicators display time
set -g display-time 1000 # slightly longer status messages display time
# clear both screen and history
bind -n C-l send-keys C-l \; run 'sleep 0.2' \; clear-history
# activity
set -g monitor-activity on
set -g visual-activity off
## Status line {
# move status line to the top
set -q -g status-utf8 on # expect UTF-8 on tmux < 2.2
set -g status-position top
set -g status-interval 10 # redraw status line every 10 seconds
set -g status-style 'bg=terminal, fg=terminal'
set -g window-status-style 'bg=terminal, fg=green'
set -g window-status-current-style 'bg=terminal, fg=green bright'
set -g status-left-length 20
set -g status-left-style 'bg=terminal, fg=white dim'
set -g status-left "[#S] > #(awk '{uptime=$1; days=int(uptime/86400); uptime-=86400*days; hours=int(uptime/3600); uptime-=hours*3600; minutes=int(uptime/60); printf \"%%dd %%dh %%dm\", days, hours, minutes}' /proc/uptime) > "
set -g status-right-length 100
set -g status-right-style 'bg=terminal, fg=green'
2022-04-22 16:24:56 -04:00
set -g status-right "#(acpi | tr -d , | awk 'NR==1{printf \"%%s %%s < \", $3, $4; exit}')%R < %F < #(echo \"$USER\") < #h"
2022-04-22 16:21:40 -04:00
## } Status line
## } Display
## Navigation {
# create session
bind C-c new-session
# find session
2022-05-13 12:09:18 -04:00
bind C-f new-window -n "session-switcher" "\
tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\
awk 'NF>0{print}' |\
fzf --print0 --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\
xargs -0 tmux switch-client -t"
bind C-n new-window -n "window-switcher" "\
tmux list-windows -F '#{?window_active,,#{session_id}:#{window_index} #{session_name} > #{window_name}}' |\
awk 'NF>0{print}' |\
fzf --reverse --header jump-to-window --preview \"tmux capture-pane -pt {1}\" |\
awk '{print $1}' |\
xargs tmux switch-client -t"
bind C-w new-window -n "global-window-switcher" "\
CURRENT_INFO=\"\$(tmux display-message -p '0:#{session_id}:#{window_index}')\";\
tmux list-windows -aF '#{window_last_flag}:#{session_id}:#{window_index} #{session_name} > #{window_name}' |\
awk -v cur_info_raw=\"\$CURRENT_INFO\" 'BEGIN{split(cur_info_raw,cur_info,\":\")} {split($1,this_info,\":\"); if($1 == cur_info_raw || (this_info[1] && this_info[2] == cur_info[2])) next; print gensub(\"^[01]:\",\"\",1)}' |\
fzf --reverse --header global-jump-to-window --preview 'tmux capture-pane -pt {1}' |\
awk '{print $1}' |\
xargs tmux switch-client -t"
bind C-j new-window -n "pane-switcher" "\
tmux list-panes -sF '#{?#{&&:#{window_active},#{pane_active}},,#{session_id}:#{window_index}.#{pane_index} #{session_name} > #{window_name} > #{pane_title}}' |\
awk 'NF>0{print}' |\
fzf --reverse --header jump-to-pane --preview 'tmux capture-pane -pt {1}' |\
awk '{print $1}' |\
xargs tmux switch-client -t"
bind C-k new-window -n "global-pane-switcher" "\
CURRENT_INFO=\"\$(tmux display-message -p '0:#{pane_active}:#{session_id}:#{window_index}.#{pane_index}')\";\
tmux list-panes -aF '#{window_last_flag}:#{pane_active}:#{session_id}:#{window_index}.#{pane_index} #{session_name} > #{window_name} > #{pane_title}' |\
awk -v cur_info_raw=\"\$CURRENT_INFO\" 'BEGIN{split(cur_info_raw,cur_info,\":\")} {split($1,this_info,\":\"); if($1 == cur_info_raw || (this_info[1] && this_info[3] == cur_info[3] && this_info[2] == cur_info[2])) next; print gensub(\"^[01]:[01]:\",\"\",1)}' |\
fzf --reverse --header jump-to-pane --preview 'tmux capture-pane -pt {1}' |\
awk '{print $1}' |\
xargs tmux switch-client -t"
2022-04-22 16:21:40 -04:00
# pane navigation
bind -r h select-pane -L # move left
bind -r j select-pane -D # move down
bind -r k select-pane -U # move up
bind -r l select-pane -R # move right
bind > swap-pane -D # swap current pane with the next one
bind < swap-pane -U # swap current pane with the previous one
# pane resizing
bind -r H resize-pane -L 2
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r L resize-pane -R 2
bind P paste
## } Navigation