Skip to content

Instantly share code, notes, and snippets.

@grahams
Created March 21, 2023 16:22
Show Gist options
  • Save grahams/d3cbbfbc90f528adbf8218b8f5f98a50 to your computer and use it in GitHub Desktop.
Save grahams/d3cbbfbc90f528adbf8218b8f5f98a50 to your computer and use it in GitHub Desktop.
unbind C-b
set -g prefix C-a
bind -r a send-prefix
bind C-a last-window
# https://gist.github.com/admackin/4507371
# fix ssh agent when tmux is detached
# See .ssh/rc for socket linking
set -g update-environment -r
set-environment -g SSH_AUTH_SOCK $HOME/.ssh/agent.sock
# repeated space/backspace toggles windows forward/backwards
bind -r Space next-window
bind -r C-Space next-window
bind -r C-h previous-window
bind -r C-? previous-window
# Use vim bindings
setw -g mode-keys vi
# Set the title bar
set -g set-titles on
set -g set-titles-string '#h'
# renumber windows as they are created and destroyed
set-option -g renumber-windows on
# new windows should open in the cwd of the active pane
bind c new-window -c '#{pane_current_path}'
# move the current window left/right
bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
bind-key -n C-S-Right swap-window -t +1\; select-window -t +1
# create splits
bind '-' split-window -v -c '#{pane_current_path}'
bind '\' split-window -h -c '#{pane_current_path}'
# resize splits
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1
bind -n M-Left resize-pane -L 10
bind -n M-Right resize-pane -R 10
bind -n M-Down resize-pane -D 5
bind -n M-Up resize-pane -U 5
bind K unlink-window
# make prefix+S toggle status line visibility
bind S set -g status
# setup status bar
set -g status-bg colour8
set -g status-fg '#aaaaaa'
# pane movement
bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'"
set -g status-left-length 50
set -g status-left "#S %H:%M "
set -g status-right "#h: #(uptime |awk -F 'load average.*:' '{ print $2 }')"
set -w -g window-status-current-style bg=black,fg=white
# bind tree session switcher
#bind-key C-j choose-tree
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'christoomey/vim-tmux-navigator'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of
# tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment