Skip to content

Instantly share code, notes, and snippets.

@gildas
Created June 22, 2021 22:36
Show Gist options
  • Save gildas/7316ca6b72138ea6ae1f6e349c6e2c95 to your computer and use it in GitHub Desktop.
Save gildas/7316ca6b72138ea6ae1f6e349c6e2c95 to your computer and use it in GitHub Desktop.
# set history
set -g history-limit 50000
# Messages will be displayed for 4 seconds
set -g display-time 4000
set -g default-terminal screen-256color
# Disable auto-renaming of windows
set -g allow-rename off
# enable wm window titles
set -g set-titles on
# wm window title string
set -g set-titles-string "#W [#S:#I]"
# Allow mouse
set -g mouse on
# Aggressive resize
setw -g aggressive-resize on
# Start copy mode when scrolling up
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# Use vim keybindings in copy mode
setw -g mode-keys vi
set -g mode-keys vi
# Do not wait after Esc key is pressed (When VIM goes to command mode)
set -s escape-time 0
set -g status-keys emacs
# force a reload of the config file
unbind r
bind r source-file $XDG_CONFIG_HOME/tmux/tmux.conf \; display "Reloaded tmux.conf!"
# Grab a pane and put it into the current window
bind-key @ command-prompt -p "create pane from: " "join-pane -s ':%%'"
# Open a man page in a new window
bind / command-prompt "split-window 'exec man %%'"
# Open a window with top
bind * split-window "exec top"
# Open a Web browser page with the web links found in the current pane
bind u capture-pane \; save-buffer /tmp/tmux-pane \; split-window "exec urlview < /tmp/tmux-pane"
# rebind clear screen with Ctrl-l
bind C-l send-keys 'C-l'
# splitting panes
bind | split-window -h -c "#{pane_current_path}"
bind \\ split-window -fh -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind _ split-window -fv -c "#{pane_current_path}"
# new window
bind c new-window -c "#{pane_current_path}"
# fast resizing (-r for repeatable)
bind -r h resize-pane -L 5
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r l resize-pane -R 5
# quick pane cycling
bind C-B select-pane -t :.+
# Create a new session from the current window
bind C-N run "S=$(tmux new -dP); tmux move-window -t$S"
# smart pane switching with awareness of vim splits
bind -n C-Left run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-Down run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-Up run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-Right run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
# smart window switching
bind -n C-Tab next-window
bind -n C-S-Tab previous-window
bind -n C-S-Left previous-window
bind -n C-S-Right next-window
bind -n M-S-Left swap-window -t -1\; select-window -t -1
bind -n M-S-Right swap-window -t +1\; select-window -t +1
# smart session switching
bind -n M-Left switch-client -p
bind -n M-Right switch-client -n
# Status bar
set -g status on
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-processes 'redis-cli ~watch ~ngrok'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'jonmosco/kube-tmux'
set -g @plugin 'tmux-plugins/tpm'
# Install Tmux Plugins Manager as needed
if "test ! -d $XDG_CONFIG_HOME/tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm $HOME/.tmux/plugins/tpm && $HOME/.tmux/plugins/tpm/bin/install_plugins'"
# Initialize Tmux Plugins Manager
run "$HOME/tmux/plugins/tpm/tpm"
@gildas
Copy link
Author

gildas commented Jun 22, 2021

curl -sSL -o ~/.tmux.conf https://tinyurl.com/gildas-tmux-conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment