-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
104 lines (75 loc) · 3.65 KB
/
.tmux.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Skip loading .profile files with new windows.tmux
BASH_CMD="bash --noprofile"
# For tmux-fzf, make the popup window larger than default
TMUX_FZF_OPTIONS="-p -w 80% -h 80% -m"
# remap prefix from 'C-b' to 'C-p'
unbind C-b
set-option -g prefix C-p
bind-key C-p send-prefix
# Next and previous window
bind p previous-window
bind n next-window
bind P paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
# Don't copy over any environment variables to new sessions. .bashrc will be sourced anyways.
# And the default behavior messes with how we autoamtically switch python venvs based on $PWD (look at .bashrc for that).
set -g update-environment ""
# fix ssh agent when tmux is detached
setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }
bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L'
bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D'
bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U'
bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R'
# split panes using vim keys
bind h split-window -h -c "#{pane_current_path}" -b $BASH_CMD
bind l split-window -h -c "#{pane_current_path}" $BASH_CMD
bind k split-window -v -c "#{pane_current_path}" -b $BASH_CMD
bind j split-window -v -c "#{pane_current_path}" $BASH_CMD
# Use tmux-fzf to ease:
# - switching between windows
bind w run-shell -b "~/.tmux/plugins/tmux-fzf/scripts/window.sh switch"
# - switching between sessions
bind s run-shell -b "~/.tmux/plugins/tmux-fzf/scripts/session.sh attach"
# New window in same directory
bind c new-window -c "#{pane_current_path}" $BASH_CMD
# New session
bind S new-session
# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf
bind C-q run-shell -b "toggle_tmux_sess ~/git/dotfiles/"
# Vi style navigation
set-window-option -g mode-keys vi
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'sainnhe/tmux-fzf'
# Enable mouse resize
set -g mouse on
# Copy to system clipboard
set set-clipboard on
# Initialize TMUX plugin manager (keep this line at the very bottom of
# tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
# Rename sess to curdir
bind e attach-session -t . -c "#{pane_current_path}" \; run-shell 'tmux rename-session -t . "$(basename $PWD)";'
# 24 bit terminal https://github.com/alacritty/alacritty/issues/109
set -g default-terminal "xterm-256color"
# Trying to get neovim colors to appear the same inside tmux as outside
# set -ag terminal-overrides ",tmux-256color:RGB"
set-option -ga terminal-overrides ",xterm-256color:Tc"
# source tmux theme
source ~/.config/tmux/theme.conf
# https://stackoverflow.com/a/18777877
# The history limit is a pane attribute that is fixed at the time of pane
# creation and cannot be changed for existing panes. The value is taken from
# the history-limit session option (the default value is 2000)
set-option -g history-limit 50000