set -g default-command "if [ \"$(uname)\" = 'Darwin' ]; then exec reattach-to-user-namespace $SHELL; else exec $SHELL; fi" set -g history-limit 32000 set -g update-environment "DISPLAY WINDOWID SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION SSH_CLIENT SSH_TTY KRB5CCNAME Apple_PubSub_Socket_Render Apple_Ubiquity_Message" # Reset SHLVL (otherwise it is 2 inside tmux) setenv -g SHLVL 0 # Send esc faster so that neovim won't get so laggy # https://github.com/neovim/neovim/issues/2093 set -g escape-time 100 # Disable paste detection set -g assume-paste-time 0 # Titles and window names set -g set-titles on set -g set-titles-string "#T" # Make it not so annoying/sticky to switch windows set -g repeat-time 170 # Don't deattach me when a session ends set -g detach-on-destroy off # Make shift+keys work setw -g xterm-keys on # Prefix set -g prefix ^A unbind ^B bind ^A send-prefix bind a send-prefix # Last window bind ^a last # Next & prev bind ' ' next bind '^ ' next bind ^p prev # Status set -g status off # Need more (cow)bells! set -g bell-action any set -g bell-on-alert on # Detach bind ^d detach # Control the a tmux in a tmux bind A send-prefix \; send-prefix bind C send-prefix \; send-keys c bind n send-prefix \; send-keys ' ' bind bspace send-prefix \; send-keys p bind '#' send-prefix \; send-keys '"' # Other key bindings. bind ^r command-prompt "find-window '%%'" bind '"' choose-tree -w bind w split-window bind W split-window -c "#{pane_current_path}" bind ^w split-window bind I list-windows bind i list-windows bind D neww 'if who | grep -q "$USER.* via mosh"; then tmux lsc -F "#{client_activity} #{client_tty}" | sort | head -n -1 | awk "{print \$2}" | xargs -n1 tmux detach -t; else for i in $(tmux lsc | cut -d: -f1 | grep -v "^$SSH_TTY$"); do tmux detach -t $i; done; fi' bind S neww -t 999 'window=`tmux display -p "#{pane_title}"`; i=0; tmux list-windows | cut -d: -f1 | while read j; do if [ $j != $i ]; then tmux move-window -s $j -t $i; fi; i=$(($i+1)); done' # ; tmux find-window -T "$window" bind ^s command-prompt "rename-session '%%'" # Make the default HOME always ~ bind c neww -c ~ bind ^c new -c ~ bind escape copy-mode # Copy to the OS clipboard bind -T copy-mode-vi y send -X copy-pipe-and-cancel "if [ \"$(uname)\" = 'Darwin' ]; then reattach-to-user-namespace pbcopy; else xclip; fi" bind j command-prompt "join-pane -s '%%'" bind ! break-pane -d bind - command-prompt "move-pane -t '%%'" # Makes `tmux a` work even when there isn't a session going on new-session -A -c ~