-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reduce duplication in tmux conf files
- Loading branch information
1 parent
406d3ab
commit 654f141
Showing
4 changed files
with
118 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Use <ctrl-a> for prefix rather than <ctrl-b>. The '-g' option sets it globally | ||
# Unbinding commands isn't neccesary | ||
unbind C-b | ||
set -g prefix C-a | ||
bind C-a send-prefix | ||
|
||
set -g allow-rename off | ||
# Use 256 colors | ||
set -g default-terminal "tmux-256color" | ||
|
||
# Use zsh as default shell | ||
set -g default-shell $SHELL | ||
|
||
# Prevent Vim mode switching delay (https://superuser.com/a/252717/65504) | ||
set -sg escape-time 0 | ||
|
||
# Increase scrollback history above the default of 2000 | ||
set -g history-limit 50000 | ||
|
||
# Limit size of window in session by smallest client only when both viewing the same window. By defaul all windows are limited | ||
setw -g aggressive-resize on | ||
|
||
# Style status line | ||
set -g status-style fg=green,bold,bg=black | ||
set -g status-left-length 20 | ||
# set -g status-right 'Continuum status: #{continuum_status}' | ||
setw -g window-status-style fg=blue,bold,bg=default | ||
setw -g window-status-current-style fg=white,bold,bg=red | ||
|
||
# Style message line | ||
set -g message-style fg=white,bold,bg=black | ||
|
||
# Style active pane | ||
setw -g pane-active-border-style fg=green,bg=default | ||
|
||
# Enable activity alerts and set style | ||
set -g visual-activity on | ||
setw -g monitor-activity on | ||
setw -g window-status-activity-style bg=white | ||
|
||
# Setup 'v' to begin selection as in Vim | ||
bind-key -T copy-mode-vi v send-keys -X begin-selection | ||
|
||
# Make window and pane index start with 1, by default it would be 0 which is a bigger stretch on the keyboard | ||
set -g base-index 1 | ||
setw -g pane-base-index 1 # setw is used for setting options on the window, the long form is 'set-window-option' | ||
|
||
# Reload config file. '\;' separates commands | ||
bind r source-file ~/.tmux.conf \; display "Config Reloaded!" | ||
|
||
# Quickly open a new window. The default is 'prefix c' | ||
bind N new-window | ||
|
||
# Split window and fix path for tmux 1.9 | ||
# Split window vertically, default is 'prefix %' | ||
bind | split-window -h -c "#{pane_current_path}" | ||
# Split window horizontally, default is 'prefix "' | ||
bind - split-window -v -c "#{pane_current_path}" | ||
|
||
# Synchronize all panes in a window, toggles | ||
bind C-a setw synchronize-panes | ||
|
||
# Cycle through windows via ctrl-h and ctrl-l | ||
bind -r C-h select-window -T -t :- | ||
bind -r C-l select-window -T -t :+ | ||
|
||
# Resize panes using H,J,K,L. Using -r option to make the command repeatable | ||
bind -r H resize-pane -L 10 | ||
bind -r J resize-pane -D 10 | ||
bind -r K resize-pane -U 10 | ||
bind -r L resize-pane -R 10 | ||
|
||
# Enable mouse support. Use sparingly. Most useful to select text and copy into the clipboard. | ||
set -g mouse on | ||
|
||
# Use Vim keybindings in Copy mode | ||
setw -g mode-keys vi | ||
|
||
# More settings to make copy-mode more Vim-like | ||
unbind [ # Prefix [ is the default for Copy mode | ||
bind Escape copy-mode | ||
unbind p # Prefix p is previous window by default | ||
bind p paste-buffer | ||
|
||
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage" | ||
bind-key -T copy-mode-vi PPage send-keys -X page-up | ||
bind-key -T copy-mode-vi NPage send-keys -X page-down | ||
|
||
bind -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "select-pane -t =; send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M" | ||
bind -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "select-pane -t =; send-keys -M" "select-pane -t =; send-keys -M" | ||
bind-key -T copy-mode-vi WheelUpPane send-keys -X halfpage-up | ||
bind-key -T copy-mode-vi WheelDownPane send-keys -X halfpage-down | ||
|
||
# Smart pane switching with awareness of Vim splits | ||
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-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" | ||
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-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" | ||
|
||
# Tmux PLugin Manager config | ||
set -g @plugin 'tmux-plugins/tpm' # https://github.com/tmux-plugins/tpm | ||
set -g @plugin 'tmux-plugins/tmux-continuum' # https://github.com/tmux-plugins/tmux-continuum | ||
set -g @plugin 'tmux-plugins/tmux-resurrect' # https://github.com/tmux-plugins/tmux-resurrect | ||
# set -g @plugin 'tmux-plugins/tmux-yank' # https://github.com/tmux-plugins/tmux-yank | ||
|
||
# Continually save tmux environment (using tmux-continuum) | ||
set -g @continuum-restore 'on' | ||
# Restore vim sessions | ||
set -g @resurrect-strategy-vim 'session' | ||
|
||
# Include WSL specific stuff | ||
if-shell "test $OSTYPE = linux-gnu && test -n $WSL_DISTRO_NAME" 'source-file ~/.wsl.tmux.conf' 'source-file ~/.macos.tmux.conf' | ||
|
||
# Initialize TPM (keep this line at the very bottom of tmux.conf) | ||
run '~/.tmux/plugins/tpm/tpm' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,3 @@ | ||
# Use <ctrl-a> for prefix rather than <ctrl-b>. The '-g' option sets it globally | ||
# Unbinding commands isn't neccesary | ||
unbind C-b | ||
set -g prefix C-a | ||
bind C-a send-prefix | ||
|
||
set -g allow-rename off | ||
# Use 256 colors | ||
set -g default-terminal "tmux-256color" | ||
|
||
# Use zsh as default shell | ||
set -g default-shell $SHELL | ||
|
||
# Prevent Vim mode switching delay (https://superuser.com/a/252717/65504) | ||
set -sg escape-time 0 | ||
|
||
# Increase scrollback history above the default of 2000 | ||
set -g history-limit 50000 | ||
|
||
# Limit size of window in session by smallest client only when both viewing the same window. By defaul all windows are limited | ||
setw -g aggressive-resize on | ||
|
||
# Style status line | ||
set -g status-style fg=green,bold,bg=black | ||
set -g status-left-length 20 | ||
# set -g status-right 'Continuum status: #{continuum_status}' | ||
setw -g window-status-style fg=blue,bold,bg=default | ||
setw -g window-status-current-style fg=white,bold,bg=red | ||
|
||
# Style message line | ||
set -g message-style fg=white,bold,bg=black | ||
|
||
# Style active pane | ||
setw -g pane-active-border-style fg=green,bg=default | ||
|
||
# Enable activity alerts and set style | ||
set -g visual-activity on | ||
setw -g monitor-activity on | ||
setw -g window-status-activity-style bg=white | ||
|
||
# Copy-paste integration for WSLENV | ||
if-shell -b 'test -n "$WSLENV"' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel clip.exe' | ||
if-shell -b 'test -n "$WSLENV"' 'bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel clip.exe' | ||
# Setup 'v' to begin selection as in Vim | ||
bind-key -T copy-mode-vi v send-keys -X begin-selection | ||
|
||
# Make window and pane index start with 1, by default it would be 0 which is a bigger stretch on the keyboard | ||
set -g base-index 1 | ||
setw -g pane-base-index 1 # setw is used for setting options on the window, the long form is 'set-window-option' | ||
|
||
# Reload config file. '\;' separates commands | ||
bind r source-file ~/.tmux.conf \; display "Config Reloaded!" | ||
|
||
# Quickly open a new window. The default is 'prefix c' | ||
bind N new-window | ||
|
||
# Split window and fix path for tmux 1.9 | ||
# Split window vertically, default is 'prefix %' | ||
bind | split-window -h -c "#{pane_current_path}" | ||
# Split window horizontally, default is 'prefix "' | ||
bind - split-window -v -c "#{pane_current_path}" | ||
|
||
# Synchronize all panes in a window, toggles | ||
bind C-a setw synchronize-panes | ||
|
||
# Cycle through windows via ctrl-h and ctrl-l | ||
bind -r C-h select-window -T -t :- | ||
bind -r C-l select-window -T -t :+ | ||
|
||
# Resize panes using H,J,K,L. Using -r option to make the command repeatable | ||
bind -r H resize-pane -L 10 | ||
bind -r J resize-pane -D 10 | ||
bind -r K resize-pane -U 10 | ||
bind -r L resize-pane -R 10 | ||
|
||
# Enable mouse support. Use sparingly. Most useful to select text and copy into the clipboard. | ||
set -g mouse on | ||
|
||
# Use Vim keybindings in Copy mode | ||
setw -g mode-keys vi | ||
|
||
# More settings to make copy-mode more Vim-like | ||
unbind [ # Prefix [ is the default for Copy mode | ||
bind Escape copy-mode | ||
unbind p # Prefix p is previous window by default | ||
bind p paste-buffer | ||
|
||
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage" | ||
bind-key -T copy-mode-vi PPage send-keys -X page-up | ||
bind-key -T copy-mode-vi NPage send-keys -X page-down | ||
|
||
bind -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "select-pane -t =; send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M" | ||
bind -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "select-pane -t =; send-keys -M" "select-pane -t =; send-keys -M" | ||
bind-key -T copy-mode-vi WheelUpPane send-keys -X halfpage-up | ||
bind-key -T copy-mode-vi WheelDownPane send-keys -X halfpage-down | ||
|
||
#Buffers to/from Mac clipboard, yay tmux book from pragprog | ||
# bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy" | ||
# bind C-v run "tmux set-buffer $(reattach-to-user-namespace pbpaste); tmux paste-buffer" | ||
|
||
# Smart pane switching with awareness of Vim splits | ||
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-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" | ||
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-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" | ||
|
||
# Tmux PLugin Manager config | ||
set -g @plugin 'tmux-plugins/tpm' # https://github.com/tmux-plugins/tpm | ||
set -g @plugin 'tmux-plugins/tmux-continuum' # https://github.com/tmux-plugins/tmux-continuum | ||
set -g @plugin 'tmux-plugins/tmux-resurrect' # https://github.com/tmux-plugins/tmux-resurrect | ||
# set -g @plugin 'tmux-plugins/tmux-yank' # https://github.com/tmux-plugins/tmux-yank | ||
|
||
# Continually save tmux environment (using tmux-continuum) | ||
set -g @continuum-restore 'on' | ||
# Restore vim sessions | ||
set -g @resurrect-strategy-vim 'session' | ||
|
||
# Initialize TPM (keep this line at the very bottom of tmux.conf) | ||
run '~/.tmux/plugins/tpm/tpm' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters