# This is a tangled file. Do not make any changes here. All changes should preferably be made in the original Org file.
# Use =org-babel-tangle-jump-back-to-org= to jump back to it from any code block.
# If any changes are made here, use =org-babel-detangle= to add it back to the original Org mode file.
tmux man page To show options:
tmux show-options -g [option_name]
Show global option/show all if none specifiedtmux show-options -w [option_name]
Show window option/show all if none specifiedtmux show-options -s [option_name]
Show server option/show all if none specified
C-b
is a pain to use when in copy mode as to scroll-up a full screen, we’ve to press C-b
twice since upon the first press it’s interpreted as a prefix.
Thus change it to C-Space
. C-a
is the default prefix used by screen but it collides with emacs readline
unbind C-b
unbind C-Space
unbind -T copy-mode 'C-Space'
set -g prefix C-Space
# For nested Tmux sessions
# bind C-Space send-prefix
Unbind that everywhere as well
unbind -T copy-mode 'C-Space'
Disable wait for escape sequence to enable faster command sequence
set -sg escape-time 0
set -sg repeat-time 600
Disable mouse support. I’d rather use mouse to scroll in vim
set -g mouse off
Set bash as the default shell
set -g default-shell /tool/pandora64/bin/bash
vi-mode for copy-paste
setw -g mode-keys vi
Set the default terminal mode to 256color mode
set -g default-terminal "xterm-256color"
Sane scrolling (http://superuser.com/a/314620) 24-bit color support (https://www.reddit.com/r/emacs/comments/8ndm2x/gnu_emacs_261_24bit_colors_suckless_st_terminal/dzwh4vv/)
set -ga terminal-overrides ',xterm*:smcup@:rmcup@,*256col*:Tc'
set -g history-limit 10000
setw -g alternate-screen on
To allow FocusGained
and FocusLost
autocmds to work in vim (https://github.com/tmux-plugins/vim-tmux-focus-events)
set -g focus-events on
set -g status on
Use emacs keybindings in tmux’s command prompt. Emacs is the default but if I don’t set this explicitly, it gets set to vi as my $VISUAL and $EDITOR are set to gvim and vim respectively.
set -g status-keys emacs
Left-justify the window list
set -g status-justify left
Colors!
set -g status-style fg=colour7,bg=colour18
#set -g status-left-style fg=white,bg=colour25
set -g message-style fg=colour7,bg=colour0,bright
Increase the time between refresh (Default=15)
set -g status-interval 60
On the left we have the Session information
set -g status-left-length 50
set -g status-left ' #[fg=colour1,bold]#S#[fg=colour7] #[fg=colour20]•'
On the right I have information about running jobs, both local and on LSF and the clock
set -g status-right-length 60
set -g status-right "#[fg=colour20]•#[fg=colour4] JOBS: #(command jobs -r 2>/dev/null | wc -l)r #(command jobs -s 2> /dev/null | wc -l)s #[fg=colour20]•#[fg=colour4] LSF: #(command lsf_bjobs -sum | tail -n1 | command awk '{print $1\"r \"$5\"p\"}') #[fg=colour20]• #[fg=colour3]%b %d, %a %H:%M "
Enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
Attempt to set the window title using the \e]2;...\007
xterm code if the terminal appears to be an xterm
Since I’m using xterm in full-screen mode, I don’t bother with the title anymore
set -g set-titles on
# set -g set-titles-string '#H #S'
Set the starting pane index to 1
setw -g pane-base-index 1
Make the active pane stand-out visually
set -g pane-border-style fg=colour0
set -g pane-active-border-style fg=colour19
Set the starting window index to 1
set -g base-index 1
Make active pane stand out
setw -g window-active-style 'bg=#272822' # bg color of active pane
setw -g window-style 'bg=#272822' # bg color of inactive panes
Status Bar display
setw -g window-status-format "#[fg=colour20] #I:#W "
setw -g window-status-style bright
setw -g window-status-current-format "#[attr=bright]#[fg=colour5] #I:#W "
setw -g window-status-current-style bright
Blink the pane tab in case of any activity
setw -g window-status-activity-style blink
Window is only constrained in size if a smaller client is actively looking at it
setw -g aggressive-resize on
Mostly, there’s a method to the keybinding madness
- I use as many as vim’s bindings as possible. Since I use evil in emacs I only end up having to learn one set of bindings that I can use everywhere
- Pane and Window bindings use similar suffix for related behavior eg.
h
to go to the ‘left’ one. I differentiate between them depending on the prefix. eg. Ctrl is used for panes while Meta (Alt) is used for window bindings.
-r
indicates that the binding is repeatable i.e. the prefix need not be pressed again to use it
Reload tmux.conf
unbind r
bind r source-file ~/.tmux.conf \; refresh-client -S\; display-message " Config reloaded".
unbind C-r
bind C-r source-file ~/.tmux.conf \; refresh-client -S\; display-message " Config reloaded".
Remove suspend-client binding
unbind C-z
Allows fast scrolling through a pane’s history. -e specifies that scrolling to the bottom exits copy-mode
bind PageUp copy-mode -eu
copy-paste.
Use prefix+]
to paste. prefix+p
would be the logical choice for paste but it’s better used in next/previous context
bind -T copy-mode-vi 'v' send -X begin-selection
bind -T copy-mode-vi 'V' send -X select-line
bind -T copy-mode-vi 'C-v' send -X rectangle-toggle
bind -T copy-mode-vi 'y' send -X copy-selection-and-cancel
bind -T copy-mode-vi 'Y' send -X copy-pipe-and-cancel
Use fzf to select and switch sessions. prefix+s
is tmux’s way of doing it (using choose-tree
)
So I’m binding this one to prefix+S
bind S split-window -l 12 'bash -ci fzf-tmux-select-session > /dev/null'
I tried to use this as a repeatable binding (by using -r
) but most of the time it hinders rather than helps.
I never use more than 2 panes vertically and/or horizontally so most of the time I’m just 1 prefix away.
Making this repeatable means that once I’m in my target pane tmux is still in repeatable binding mode so I’ve to explicitly press Escape to get out of it.
bind C-w last-pane
Use h-j-k-l instead of arrow keys
unbind Up
unbind Down
unbind Left
unbind Right
bind C-h select-pane -L
bind C-j select-pane -D
bind C-k select-pane -U
bind C-l select-pane -R
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
Kill pane without confirmation
bind c kill-pane
bind C-o kill-pane -a
Create Panes. Use vim’s bindings to create splits here. It’s more intuitive
bind -r C-s split-window -v -c '#{pane_current_path}'
bind -r C-v split-window -h -c '#{pane_current_path}'
Goto Pane bind C-g display-panes
bind C-g display-panes
Resize Panes
bind -r M-Up resize-pane -U 6
bind -r M-Down resize-pane -D 6
bind -r M-Left resize-pane -L 24
bind -r M-Right resize-pane -R 24
Swap panes. These are the default bindings
bind -r { swap-pane -U
bind -r } swap-pane -D
Move pane to new Window, move existing window to pane (Not using presently)
bind C-b break-pane
bind C-f command-prompt -p "Join pane from:" "join-pane -s ':%%'"
bind M-8 run-shell 'bash -ci "tmux_pp select-layout work-lp" > /dev/null'
bind M-9 run-shell 'bash -ci "tmux_pp select-layout work-pc" > /dev/null'
bind -r M-h previous-window
bind -r M-l next-window
bind -r M-q last-window
bind -r M-n new-window
Kill window without confirmation, kill other windows
bind M-c kill-window
bind M-o kill-window -a
Move window left
bind -r M-{ swap-window -t -1
bind -r M-} swap-window -t +1
bind M-j command-prompt -p "Join pane to:" "join-pane -t ':%%'"
bind M-g command-prompt -p "Goto Window:" "select-window -t '%%'"
Use add-file-local-variable
or add-file-local-variable-prop-line
instead of adding these manually