Skip to content

Instantly share code, notes, and snippets.

@currenthandle
Created April 6, 2023 01:51
Embed
What would you like to do?
# Set custom prefix key binding
unbind C-b
set-option -g prefix C-Space
set-option -g prefix2 C-a
# Bind r to reload .tmux.conf
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
# Enable mouse
set -g mouse on
# Split panes with |, -, h, v
# v, h, |, and - are not binded by default, but we never know in the next versions...
unbind v
unbind h
unbind |
unbind -
# Unbind default keys
unbind % # Split vertically
unbind '"' # Split horizontally
# Bind custom pane-split keys
bind v split-window -h -c "#{pane_current_path}"
bind | split-window -h -c "#{pane_current_path}"
bind h split-window -v -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Pane navigation
bind -n C-h select-pane -L
bind -n C-j select-pane -D
bind -n C-k select-pane -U
bind -n C-l select-pane -R
# More History
set -g history-limit 100000
# Create new window / Rename current Window
unbind n #DEFAULT KEY: Move to next window
unbind w #DEFAULT KEY: change current window interactively
bind n command-prompt "rename-window '%%'"
bind w new-window -c "#{pane_current_path}"
# Begin Window and Pane idexing at 1
set -g base-index 1
set-window-option -g pane-base-index 1
# Bind alt+j to previous-window nav function
bind -n M-j previous-window
# Bind alt+k to next-window nav function
bind -n M-k next-window
# Vim keybindings for Copy mode
#setw -g mode-keys vi
# set-window-option -g mode-keys vi
set -g status-keys vi
set -g mode-keys vi
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode-vi 'r' send-keys -X rectangle-toggle
# smart pane switching with awareness of vim splits
bind -n C-h if -F '#{m:*vim*,#{pane_current_command}}' 'send c-h' 'selectp -L'
bind -n C-j if -F '#{m:*vim*,#{pane_current_command}}' 'send c-j' 'selectp -D'
bind -n C-k if -F '#{m:*vim*,#{pane_current_command}}' 'send c-k' 'selectp -U'
bind -n C-l if -F '#{m:*vim*,#{pane_current_command}}' 'send c-l' 'selectp -R'
bind -n C-\\ if -F '#{m:*vim*,#{pane_current_command}}' 'send c-\\' 'selectp -l'
# Automatic tpm installation
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
# Powerline
if "test ! -d ~/.tmux/powerline" \
"run 'git clone https://github.com/erikw/tmux-powerline ~/.tmux/powerline'"
set-option -g status on
set-option -g status-interval 2
set-option -g status-justify "centre"
set-option -g status-left-length 60
set-option -g status-right-length 90
# set-option -g status-left "#(~/.tmux/powerline/powerline.sh left)"
# set-option -g status-right "#(~/.tmux/powerline/powerline.sh right)"
set-hook -g session-created 'run-shell "~/.tmux/powerline/powerline.sh init"' # prettifies the window-status segments
PROMPT="$PROMPT"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#D" | tr -d %) "$PWD")'
# Plugins
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'seebi/tmux-colors-solarized'
set -g @plugin 'laktak/extrakto'
set -g @colors-solarized 'dark'
# enable 256-colors
set -g default-terminal "screen-256color"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment