.tmux.conf (7376B)
1 # GENERAL 2 3 set-option -g prefix C-a # Set prefix to <C-a> 4 bind a send-prefix # Send <C-a> with <C-a>a 5 6 bind R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded" 7 8 #set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' # fix escape sequences 9 10 set -g history-limit 10000 # lines to keep in hisoty 11 set-option -g display-panes-time 3000 # Timeout for pane-numbering in ms 12 set-option -sg escape-time 0 # speed up commands 13 set -g mouse on # enable mouse (tmux 2.1+) 14 set -g base-index 1 # start window numbering at 1 15 set -g pane-base-index 1 # start pane numbering at 1 16 set -g renumber-windows on # renumber windows automatically 17 setw -g automatic-rename on # rename window after process 18 19 # Clear window name before renaming 20 bind , rename-window "" \; command-prompt "rename-window '%%'" 21 22 #### APPEARANCE 23 24 set -g default-terminal "tmux" 25 #set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' # fix escape sequences 26 setw -g aggressive-resize on # resize window to smallest client 27 28 set -g pane-border-style fg="#333333" # border color for inactive panes 29 set -g pane-active-border-style fg="#999999" # border color for active panes 30 31 # Status bar colors and format 32 set -g window-status-format ' #I #W ' 33 set -g window-status-style 'fg=colour8' 34 set -g window-status-current-format '[#I #W]' 35 set -g window-status-current-style 'fg=default' 36 set -g window-status-separator '' 37 set -g status-style bg=default # background color for status bar 38 set -g status-position bottom # put status bar on top or bottom 39 set -g status-interval 5 # interval in s to update status 40 set -g status-justify left # horizontal alignment 41 set -g message-style fg=default,bg=default # appearance of status messages 42 set -g message-command-style fg=default # appearance of status message cmds 43 44 # Left section of status bar 45 set -g status-left "" 46 47 # Toggle bar visibility 48 bind -r t set -g status 49 50 # Hide status bar if there is only one window 51 if -F "#{==:#{session_windows},1}" "set -g status off" "set -g status on" 52 set-hook -g window-linked 'if -F "#{==:#{session_windows},1}" "set status off" "set status on"' 53 set-hook -g window-unlinked 'if -F "#{==:#{session_windows},1}" "set status off" "set status on"' 54 55 # Right section of status bar 56 #if-shell 'uname | grep -qi Darwin' "set -g status-right \"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//') #[fg=cyan]#(~/.local/bin/battery-osx) #(~/.local/bin/mailstatus) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=#666666]%F #[fg=#bababa]%R\"" 57 #if-shell 'uname | grep -qi Linux' "set -g status-right \"#[fg=7]#(sysstatus)\"" 58 set -g status-right "" 59 60 # Scaling of status-bar sections 61 set -g status-right-length 0 62 63 64 #### NAVIGATION 65 66 # With C-a prefix 67 bind h select-pane -L # navigate left with <C-a>h 68 bind j select-pane -D # navigate down with <C-a>j 69 bind k select-pane -U # navigate up with <C-a>k 70 bind l select-pane -R # navigate right with <C-a>l 71 bind -r H resize-pane -L 5 # resize pane left with <C-a>H 72 bind -r J resize-pane -D 5 # resize pane down with <C-a>J 73 bind -r K resize-pane -U 5 # resize pane up with <C-a>K 74 bind -r L resize-pane -R 5 # resize pane right with <C-a>L 75 76 bind C-s last-window # go to last window with <C-a><C-s> 77 bind C-a last-pane # go to last pane with <C-a><C-a> 78 bind -n M-Tab last-window # go to last pane with M-Tab 79 bind -n M-s last-pane # go to last pane with M-s 80 bind -r n next-window # next window with <C-a>n 81 bind -r b previous-window # next window with <C-a>p 82 bind -n -r M-n next-window # next window with <M-n> 83 bind -n -r M-b previous-window # previous window with <M-n> 84 85 86 #### LAYOUT CHANGING BINDINGS 87 88 # create panes in same directory 89 bind '"' split-window -c "#{pane_current_path}" 90 bind '%' split-window -h -c "#{pane_current_path}" 91 92 bind W break-pane 93 94 bind -r z resize-pane -Z # toggle pane zoom with <C-a>z 95 bind -r y next-layout # cycle to next pane layout with <C-a>y 96 bind -r Y previous-layout # cycle to previous pane layout with <C-a>Y 97 bind -r r rotate-window # rotate panes with <C-a>r 98 99 bind -r B swap-window -t -1 # Swap window left 100 bind -r N swap-window -t +1 # Swap window right 101 102 #### CLIPBOARD 103 104 # enable reattach-to-user-namespace which fixes pasteboard access and launchctl 105 bind Space copy-mode # enter copy mode with <C-a><Space> 106 bind -T copy-mode-vi v send -X begin-selection # start "visual" with v 107 108 # Copy (yank) with y 109 bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "DISPLAY=:0 xclip -i" 110 bind -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel "DISPLAY=:0 xclip -i -selection clipboard" 111 bind -T copy-mode-vi c send-keys -X copy-pipe-and-cancel "cclip" 112 if-shell 'uname | grep -qi Darwin' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"' 113 if-shell 'uname | grep -qi Cygwin' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "cat > /dev/clipboard"' 114 115 # Paste with C-a p or M-p 116 bind p run "DISPLAY=:0 xclip -o | tmux load-buffer - ; tmux paste-buffer" 117 bind P run "DISPLAY=:0 xclip -selection clipboard -o | tmux load-buffer - ; tmux paste-buffer" 118 bind C-p run "DISPLAY=:0 cclip -o -n | tmux load-buffer - ; tmux paste-buffer" 119 if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"' 120 if-shell 'uname | grep -qi Cygwin' 'bind p run "cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer"' 121 122 bind -T copy-mode-vi o send-keys -X copy-pipe-and-cancel "plumb >~/.cache/plumb.log 2>&1" 123 bind -T copy-mode-vi u send-keys -X copy-pipe-and-cancel "youtube-dl-music -t -a -m -q >~/.cache/youtube-dl-music.log 2>&1" 124 125 126 #### LAUNCH PROCESSES 127 128 # use urlview to follow URLs in current pane 129 bind u capture-pane -J \; \ 130 save-buffer "/tmp/active_tmux_buffer" \; \ 131 delete-buffer \; \ 132 split-window -l 10 "urlview '/tmp/active_tmux_buffer' && rm /tmp/active_tmux_buffer" 133 134 bind -n C-M-e new-window -n edit "$EDITOR" 135 bind -n C-M-w new-window -n weather \ 136 "curl 'wttr.in/?m'; echo -e '\nPress <enter> to quit'; read -n 1 -s" 137 138 # Open new window and resize status accordingly (should be a hook instead) 139 bind Enter new-window -c "#{pane_current_path}" \ 140 "tmux set status-right-length `echo $(tput cols)/2|bc|tr -d '\n'`; $SHELL" 141 142 # Use nested bindings (<C-a>m) for grouping music-control bindings 143 bind m switchc -Tmpd 144 bind -Tmpd v new-window -n mpc "ncmpc" 145 bind -Tmpd p display "#(mpc toggle | tr '\n' ' ')" 146 bind -Tmpd s display "#(mpc stop | tr '\n' ' ')" 147 bind -Tmpd n display "#(mpc next | tr '\n' ' ')" 148 bind -Tmpd b display "#(mpc prev | tr '\n' ' ')" 149 bind -Tmpd r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')" 150 151 # Change to the previous pane, repeat the last command, change back 152 bind ! last-pane \; send-keys "fc -s" C-m \; last-pane