dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 41036aa9c401d98b8188da4183cffd316bc426bb
parent c35f5df69c545bb026e35d0a45139fa22a0a7e86
Author: Anders Damsgaard <andersd@riseup.net>
Date:   Sun,  5 Nov 2017 09:23:51 -0500

clean-up tmux configuration

Diffstat:
Mlinks/.tmux.conf | 229++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 109 insertions(+), 120 deletions(-)

diff --git a/links/.tmux.conf b/links/.tmux.conf @@ -1,102 +1,30 @@ -set-option -g prefix C-a -bind-key C-s last-window # Go to last window with C-SPC C-s -bind-key C-a last-pane # Go to last pane with C-SPC C-a +### GENERAL -# enable reattach-to-user-namespace which fixes pasteboard access and launchctl -if-shell 'uname | grep -qi Darwin' 'set-option -g default-command "reattach-to-user-namespace -l zsh"' - -set -g default-terminal "screen-256color" -setw -g mode-keys vi - -set -g history-limit 10000 - -# vi-like text yanking in copy mode -unbind [ -bind Escape copy-mode -unbind p -bind-key -T copy-mode-vi v send-keys -X begin-selection - -# Copy -if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "DISPLAY=:0 xclip -i -sel clipboard"' -if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"' - -# Paste -if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind p run "DISPLAY=:0 xclip -o | tmux load-buffer - ; tmux paste-buffer"' -if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind p run "reattach-to-user-namespace pbpaste | tmux load-buffer - ; tmux paste-buffer"' +set-option -g prefix C-a # Set prefix to <C-a> +bind-key C-s last-window # Go to last window with <C-a><C-s> +bind-key C-a last-pane # Go to last pane with <C-a><C-a> +bind-key a send-prefix # Send <C-a> with <C-a>a -# vi-like movement and resize -bind -r h select-pane -L -bind -r j select-pane -D -bind -r k select-pane -U -bind -r l select-pane -R -bind -r K resize-pane -U 5 -bind -r J resize-pane -D 5 -bind -r H resize-pane -L 5 -bind -r L resize-pane -R 5 +bind R source-file ~/.tmux.conf \; display "tmux config reloaded" -# Smart pane switching with awareness of vim splits -bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-h) || tmux select-pane -L" -bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-j) || tmux select-pane -D" -bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-k) || tmux select-pane -U" -bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-l) || tmux select-pane -R" +set -g history-limit 10000 # lines to keep in hisoty +set-option -g display-panes-time 3000 # Timeout for pane-numbering in ms +set-option -sg escape-time 0 # speed up commands +set -g mouse on # enable mouse (tmux 2.1+) +set -g base-index 1 # start window numbering at 1 +set -g pane-base-index 1 # start pane numbering at 1 +set -g renumber-windows on # renumber remaining windows when a window is closed +setw -g automatic-rename on # rename window after process -# Copy mode with <C-Space><Space> -bind Space copy-mode -bind C-Space copy-mode -# zoom pane -bind -r z resize-pane -Z +#### APPEARANCE +set -g default-terminal "screen-256color" # resize window to smallest client actually viewing it setw -g aggressive-resize on -# list all clients with <prefix> D and deselect with <enter> - -bind R source-file ~/.tmux.conf \; display "Source file reloaded" - -set -g base-index 1 # start window numbering at 1 -set -g pane-base-index 1 # start pane numbering at 1 -set -g renumber-windows on # renumber remaining windows when a window is closed - -# mouse behavior (pre 2.1) -#setw -g mode-mouse on -#set -g mouse-select-pane on -#set -g mouse-resize-pane on -#set -g mouse-select-window on -# mouse behavior (2.1+) -set -g mouse on - -setw -g automatic-rename on - -# Allows us to use C-a a <command> to send commands to a TMUX session inside -# another TMUX session -bind-key a send-prefix - -# Color definitions; see list with following script: -# #!/bin/bash -# for i in {0..255} ; do -# printf "\x1b[38;5;${i}mcolour${i}\n" -# done - -set -g status-position top -#if-shell 'uname | grep -qi Linux > /dev/null' 'set -g status-position top' -set -g status-interval 5 -set -g status-bg default -set -g status-fg cyan -#set -g status-left-length 20 -#set -g status-left "#[fg=red]#(hostname|sed \"s/\\\\..*$//\") #[fg=green]s:#S #[fg=yellow]w:#I #[fg=cyan]p:#P" -set -g status-left "#[fg=#333333]s:#S #[fg=#999999]| " -set -g status-right-length 40 - -if-shell 'uname | grep -qi Darwin' "set -g status-right \"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//' | cut -c 1-22) #[fg=cyan]#(~/bin/battery-osx) #(~/bin/mailstatus.sh) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=#333333]%Y-%m-%d #[fg=#666666]%R\"" -if-shell 'uname | grep -qi Linux' "set -g status-right \"#[fg=cyan]#(acpi|sed 's/Battery//; s/0://; s/Discharging//; s/Full, //; s/remaining//; s/ , //; s/Charging, /+/; s/ until charged/ /; s/, / /; s/Unknown //; s/ $//;') #(~/bin/mailstatus.sh) #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=#333333]%Y-%m-%d #[fg=#666666]%R\"" -set -g status-justify left - -# Timeout for pane-numbering in milliseconds -set-option -g display-panes-time 3000 - -# Speed up commands -set-option -sg escape-time 0 +# zoom pane +bind -r z resize-pane -Z # Highlighting the active window in status bar setw -g window-status-current-bg default @@ -118,50 +46,111 @@ set -g pane-border-fg colour238 # Active panes set -g pane-active-border-fg colour247 -# Status messages +# Status bar +set -g status-position top # put status bar on top or bottom +set -g status-interval 5 # interval in s to update status bar text +set -g status-justify left # horizontal status alignment set -g message-style fg=white,bg=black set -g message-command-style fg=white,bg=default +set -g status-bg default +set -g status-fg cyan +set -g status-left "#[fg=#333333]s:#S #[fg=#999999]| " +set -g status-right-length 40 +if-shell 'uname | grep -qi Darwin' "set -g status-right \"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//' | cut -c 1-22) #[fg=cyan]#(~/bin/battery-osx) #(~/bin/mailstatus.sh) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=#333333]%Y-%m-%d #[fg=#666666]%R\"" +if-shell 'uname | grep -qi Linux' "set -g status-right \"#[fg=cyan]#(acpi|sed 's/Battery//; s/0://; s/Discharging//; s/Full, //; s/remaining//; s/ , //; s/Charging, /+/; s/ until charged/ /; s/, / /; s/Unknown //; s/ $//;') #(~/bin/mailstatus.sh) #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=#333333]%Y-%m-%d #[fg=#666666]%R\"" -# use urlview to follow URLs -bind-key u capture-pane -J \; \ - save-buffer "/tmp/active_tmux_buffer" \; \ - delete-buffer \; \ - split-window -l 10 "urlview '/tmp/active_tmux_buffer' && rm /tmp/active_tmux_buffer" +#### NAVIGATION -bind-key o split-window -p 25 '$SHELL -c "offlineimap -qf INBOX"' \; select-pane -l -bind-key O split-window -p 25 '$SHELL -c "offlineimap"' \; select-pane -l +setw -g mode-keys vi # Use vi-like keys for navigation +bind -r h select-pane -L # navigate left with <C-a>h +bind -r j select-pane -D # navigate down with <C-a>j +bind -r k select-pane -U # navigate up with <C-a>k +bind -r l select-pane -R # navigate right with <C-a>l +bind -r H resize-pane -L 5 # resize pane left with <C-a>H +bind -r J resize-pane -D 5 # resize pane down with <C-a>J +bind -r K resize-pane -U 5 # resize pane up with <C-a>K +bind -r L resize-pane -R 5 # resize pane right with <C-a>L -bind-key -r n next-window -bind-key -r p previous-window +# Smart pane switching with awareness of vim splits +bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-h) || tmux select-pane -L" +bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-j) || tmux select-pane -D" +bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-k) || tmux select-pane -U" +bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-l) || tmux select-pane -R" + +bind-key -r n next-window # next window with <C-a>n +bind-key -r p previous-window # previous window with <C-a>p -# cycle between preset layouts. select specific presets with select-layout <n> -bind-key -r y next-layout -bind-key -r Y previous-layout -bind-key -r r rotate-window -# new windows in same directory -#bind c new-window -c "#{pane_current_path}" +#### LAYOUT BINDINGS -# split panes in same directory +# create panes in same directory bind-key '"' split-window -c "#{pane_current_path}" bind-key '%' split-window -h -c "#{pane_current_path}" -# Launch things in new windows -bind-key W new-window -n weather "curl 'wttr.in/?m'; echo -e '\nPress <enter> to quit'; read -n 1 -s" -bind-key M new-window -n mutt "mutt" -bind-key E new-window -n vim "vim" -bind-key Enter new-window "tmux set status-right-length `echo $(tput cols)/3|bc|tr -d '\n'`; $SHELL" -#bind-key Enter new-window - -# Music control -bind-key V new-window -n vimpc "vimpc" -bind-key B new-window -n mpc "mpc prev" -bind-key N new-window -n mpc "mpc next" -bind-key P new-window -n mpc "mpc toggle" -bind-key S new-window -n mpc "mpc stop" +# cycle between preset layouts. select specific presets with select-layout <n> +bind-key -r y next-layout +bind-key -r Y previous-layout +bind-key -r r rotate-window #set-hook client-resized "tmux set status-right-length `echo $(tmux display -p '#{client_width}')/3|bc|tr -d '\n'`; tmux set status-left-length `echo $(tmux display -p '#{client_width}'put cols)/3|bc|tr -d '\n'`" #set-hook client-resized "display '#{client_width}'" #set-hook client-resized 'display "#(tmux display -p \'#{client_width}/3\'|bc|tr -d \'\n\')"' #set-hook client-resized "display '#(tmux display -p \'#{client_width}\'|tr -d \'\n\')'" + +#### CLIPBOARD + +# enable reattach-to-user-namespace which fixes pasteboard access and launchctl +if-shell 'uname | grep -qi Darwin' 'set-option -g default-command "reattach-to-user-namespace -l zsh"' +# vi-like text yanking in copy mode +bind Space copy-mode # enter copy mode with <C-a><Space> +bind-key -T copy-mode-vi v send-keys -X begin-selection # start "visual" with v + +# Copy (yank) with y +if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "DISPLAY=:0 xclip -i -sel clipboard"' +if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"' + +# Paste with p +if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind p run "DISPLAY=:0 xclip -o | tmux load-buffer - ; tmux paste-buffer"' +if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind p run "reattach-to-user-namespace pbpaste | tmux load-buffer - ; tmux paste-buffer"' + + +#### LAUNCH PROCESSES + +# use urlview to follow URLs +bind-key u capture-pane -J \; \ + save-buffer "/tmp/active_tmux_buffer" \; \ + delete-buffer \; \ + split-window -l 10 "urlview '/tmp/active_tmux_buffer' && rm /tmp/active_tmux_buffer" + +# Offlineimap +bind-key o split-window -p 25 '$SHELL -c "offlineimap -qf INBOX"' \; select-pane -l +bind-key O split-window -p 25 '$SHELL -c "offlineimap"' \; select-pane -l + +# Launch in new windows +bind l switchc -Tlaunch +bind -Tlaunch m new-window -n mutt "mutt" +bind -Tlaunch v new-window -n vim "vim" +bind -Tlaunch w new-window -n weather \ + "curl 'wttr.in/?m'; echo -e '\nPress <enter> to quit'; read -n 1 -s" + +# Open new window and resize status accordingly (should be a hook instead) +bind-key Enter new-window \ + "tmux set status-right-length `echo $(tput cols)/3|bc|tr -d '\n'`; $SHELL" +#bind-key Enter new-window + +# Use nested bindings (C-a m) for grouping music-control bindings +bind m switchc -Tmpd +bind -Tmpd v new-window -n vimpc "vimpc" +bind -Tmpd p new-window -n mpc "mpc toggle" +bind -Tmpd s new-window -n mpc "mpc stop" +bind -Tmpd n new-window -n mpc "mpc next" +bind -Tmpd b new-window -n mpc "mpc prev" + +# Use alternate prefix (C-b) for grouping music-control bindings +#bind -n C-b switchc -Tmoreprefix +#bind -n -Tmoreprefix v new-window -n vimpc "vimpc" +#bind -n -Tmoreprefix p new-window -n mpc "mpc toggle" +#bind -n -Tmoreprefix s new-window -n mpc "mpc stop" +#bind -n -Tmoreprefix n new-window -n mpc "mpc next" +#bind -n -Tmoreprefix b new-window -n mpc "mpc prev"