-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
163 lines (117 loc) · 6.16 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# vim: ft=tmux
# General -------------------------------------------------------------
# Colors
if-shell '[[ ! $(tmux show-environment | grep THEME) =~ 'THEME=dark' ]]' 'source-file ~/tmux/light-theme'
# Use default $SHELL instead of a login shell
set -g default-command $SHELL
# Fix colors and enable true color support and italics
set -g default-terminal "tmux-256color"
# Tell Tmux that outside terminal supports true color
set-option -sa terminal-overrides ",xterm*:Tc"
# Start numbering at 1 for windows and panes
set -g base-index 1
setw -g pane-base-index 1
# Automatically rename windows based on the application within
setw -g automatic-rename on
# Shorter wait
set -sg escape-time 0
# Change the prefix key from ctrl-b to ctrl-s
unbind C-b
set -g prefix C-s
# Larger scrollback
set-option -g history-limit 100000
# On double ctrl-s we send it to the running process
bind-key -r C-s send-prefix
# Copy n paste
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
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
# Use ctrl-s + r to source the config file
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# Kill panes without confirmation
bind-key x kill-pane
# Create panes at the current panes path
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
# Split windows with \ -
bind-key - split-window -v -c '#{pane_current_path}'
bind-key \\ split-window -h -c '#{pane_current_path}'
# Send focus events to applications. This will be used to toggle colors in vim
set -g focus-events on
# Smart pane switching with awareness of Vim splits, the -n flag indicates we dont want to use the prefix
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
bind-key -T copy-mode-vi C-\\ select-pane -l
# Resize panes, shift arrow keys for smaller increments and control arrow key for larger
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 C-Left resize-pane -L 10
bind -n C-Right resize-pane -R 10
bind -n C-Down resize-pane -D 5
bind -n C-Up resize-pane -U 5
# Prompted join-pane
bind-key j command-prompt -p "join pane from: " "join-pane -h -s '%%'"
# Easily swap a pane (targeted by pane number) with the current pane
bind-key s display-panes\; command-prompt -p "pane #: " "swap-pane -t '%%'"
# Windows -------------------------------------------------------------
# New windows opens at the path of the pane
bind c new-window -c '#{pane_current_path}'
# Dont index windows from 0, start at 1
set-option -g base-index 1
# Renumber windows if others are closed
set-option -g renumber-windows on
# Move current pane to a new window but keep focus on this window
bind-key b break-pane -d
# Sessions ------------------------------------------------------------
# Create a new TMUX session
bind-key w display-popup -h 70% -w 85% -E '~/bin/tmux-sessionizer'
# Use fzf to display a list of all sessions and then open the selected session in a new window
bind C-j display-popup -E "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
# Choose tree lets us switch between sessions, o for open-session
# bind C-o choose-session
bind C-o split-window -v "cat ~/.z | sort -t '|' -k 2 -n -r | awk -F'|' '{print $1}' | awk -F/ '{print$NF}' | fzf | while read -r i; do z '$i'; done; tat;"
# This quits the current session and breaks out to a new one
bind-key C-b send-keys 'tat && exit' 'C-m'
# This kills the current session and switches to a previous one, if there are no more sessions it exits to the shell
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
bind-key -T prefix v switch-client -T prefix_v
bind-key -T prefix_v G split-window -v -c '#{pane_current_path}'
# Plugins -------------------------------------------------------------
tmux_plugins_dir="~/.tmux/plugins"
set-environment -g TMUX_PLUGIN_MANAGER_PATH "$tmux_plugins_dir"
set -g @plugin 'tmux-plugins/tpm' # Plugin Manager
set -g @plugin 'tmux-plugins/tmux-cpu' # Display CPU performance
set -g @plugin 'tmux-plugins/tmux-open' # Open links from tmux - Select path and press o
set -g @plugin 'tmux-plugins/tmux-yank' # Copy to system clipboard
set -g @plugin 'tmux-plugins/tmux-battery' # Battery status in tmux
set -g @plugin 'tmux-plugins/tmux-sensible' # Sensible defaults
set -g @plugin 'olimorris/tmux-pomodoro-plus' # Pomodoro timer in tmux
set -g @plugin 'tmux-plugins/tmux-resurrect' # Restore tmux sessions
set -g @plugin 'MunifTanjim/tmux-mode-indicator' # Display current tmux mode
set -g @plugin 'tmux-plugins/tmux-online-status' # Are we connected to the internet?!
set -g @plugin 'tmux-plugins/tmux-continuum' # Continuous saving of tmux environment - MUST BE LAST
## Plugin options
set -g @resurrect-dir "$tmux_dir/resurrect"
set -g @resurrect-save 'S' # Save the session
set -g @resurrect-restore 'R' # Reload the session
set -g @continuum-restore 'off' # Last saved session is always restored
# set -g @pomodoro_toggle 'p'
# set -g @pomodoro_cancel 'P'
set -g @pomodoro_repeat 'off'
set -g @pomodoro_notifications 'on'
# set -g @pomodoro_notifications 'off'
set -g @pomodoro_sound 'Pop'
set -g @yank_with_mouse on # Just select with the mouse to copy
# Run the plugins
run "$tmux_plugins_dir/tpm/tpm"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'