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 a171107f582d9fcb0cfa2d6a1538a74609e3b372
parent c55641f94096ea064c59066db80600b9cf05dcfc
Author: Anders Damsgaard Christensen <adc@geo.au.dk>
Date:   Thu, 10 Nov 2016 19:19:37 -0800

add tmux config

Diffstat:
A.tmux.conf | 187+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 187 insertions(+), 0 deletions(-)

diff --git a/.tmux.conf b/.tmux.conf @@ -0,0 +1,187 @@ +#set-option -g prefix C-Space # C-SPC as tmux key +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 +#set-option -g prefix C-b +#bind-key C-w last-window # Go to last window with C-b C-w +#bind-key C-b last-pane # Go to last pane with C-b C-b + +# enable reattach-to-user-namespace which fixes pasteboard access and launchctl +# inside tmux +#set-option -g default-command "reattach-to-user-namespace -l zsh" +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 p paste-buffer +bind-key -t vi-copy 'v' begin-selection +#bind-key -t vi-copy 'y' copy-selection + +# Copy +if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind-key -t vi-copy y copy-pipe "DISPLAY=:0 xclip -i -sel clipboard"' +if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind-key -t vi-copy y copy-pipe "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"' + + +# vi-like movement +#bind-key k select-pane -U +#bind-key j select-pane -D +#bind-key h select-pane -L +#bind-key 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 + +# traditional navigation +bind -r h select-pane -L +bind -r j select-pane -D +bind -r k select-pane -U +bind -r l select-pane -R + +# Smart pane switching with awareness of vim splits +#is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"' +#bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +#bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +#bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +#bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" +#bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" +#bind h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L" +#bind j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" +#bind k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U" +#bind l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" +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" + +# Copy mode with <C-Space><Space> +bind Space copy-mode +bind C-Space copy-mode + +# zoom pane +bind -r z resize-pane -Z + +# 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 utf8 on +#setw -g status-utf8 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 status bar on bottom for OSX, on top for Linux +set -g status-position bottom +#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-right "#[fg=green]#H" +set -g status-left-length 40 +set -g status-left "#[fg=red]#(hostname|sed \"s/\\\\..*$//\") #[fg=green]s:#S #[fg=yellow]w:#I #[fg=cyan]p:#P" +set -g status-right-length 60 +#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/ $//;') #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=green]%d %b %R" +#set -g status-right "#[fg=cyan]#(~/bin/battery) #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=green]%d %b %R" +# +#set -g status-right "#[fg=cyan]#(~/bin/battery) #[fg=yellow]#(uptime|awk '{print \$NF;}') #[fg=green]%d %b %R" +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) #[fg=red]M: #(find ~/Mail/*/INBOX/new -type f | wc -l | sed 's/ *//') #[fg=yellow]#(uptime|sed 's/.* //') #[fg=green]%Y-%m-%d %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/ $//;') #[fg=red]M: #(find ~/Mail/*/INBOX/new -type f | wc -l | sed 's/ *//') #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=green]%Y-%m-%d %R\"" +set -g status-justify centre +#set -g status-bg default +#set -g status-fg cyan +#set -g status-interval 4 +#set -g status-left '' +#set -g status-right '' +#set -g status-left '#[fg=white,bold]#S#[fg=cyan] | #[fg=white,bold]#(echo $USER) ' +#set -g status-right '#[fg=white]#H#[fg=cyan] | #[fg=white]#(uname -r)#[default]' + +# Timeout for pane-numbering in milliseconds +set-option -g display-panes-time 3000 + +# Speed up commands +set-option -sg escape-time 0 + +# Highlight active window +#setw -g window-status-fg cyan +#setw -g window-status-bg default +#setw -g window-status-attr dim +#setw -g window-status-current-fg white +#setw -g window-status-current-bg default +#setw -g window-status-current-attr bright + +#setw -g monitor-activity on + +# Highlighting the active window in status bar +setw -g window-status-current-bg default +setw -g window-status-current-fg default +setw -g window-status-bg default +setw -g window-status-fg white +setw -g window-status-activity-attr blink +setw -g window-status-activity-bg default +setw -g window-status-activity-fg default +setw -g window-status-bell-attr blink +setw -g window-status-bell-bg default +setw -g window-status-bell-fg default +#setw -g window-status-format '#[fg=default]#[bg=default] #I #[bg=default]#[fg=black,bold] #W ' +setw -g window-status-format '#[fg=green]#[bg=default] #I #[bg=default]#[fg=green]#W ' +setw -g window-status-current-format '#[fg=red]#[bg=default] #I #[fg=red,bg=default]#W ' +# + +# Inactive panes +set -g pane-border-fg colour238 +#set -g pane-border-bg black + +# Active panes +set -g pane-active-border-fg colour247 +#set -g pane-active-border-bg yellow + +# Status messages +set -g message-fg yellow +set -g message-bg black +set -g message-attr bright + +# use urlview to follow URLs +bind-key u capture-pane \; save-buffer /tmp/active_tmux_buffer \; new-window -n urlview '$SHELL -c "urlview < /tmp/active_tmux_buffer && rm /tmp/active_tmux_buffer"' + +bind-key -r n next-window +bind-key -r N previous-window + +# 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