Skip to content

Commit

Permalink
feat: simplify tmux configs
Browse files Browse the repository at this point in the history
  • Loading branch information
st3v3nhunt committed Jul 21, 2020
1 parent 87d9d52 commit 326c8a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 9 additions & 10 deletions dotfiles/.tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,20 @@ setw -g window-status-activity-style bg=white

# Setup 'v' to begin selection as in Vim
bind -T copy-mode-vi 'v' send-keys -X begin-selection
# The action for copying differs between WSL and macOS, check out the OS specific tmux files for the details

# 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'
setw -g pane-base-index 1

# 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 %'
# Better shortcuts for window splits
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
Expand Down Expand Up @@ -94,10 +93,10 @@ bind -T copy-mode-vi WheelUpPane send-keys -X halfpage-up
bind -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"
# 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
Expand All @@ -110,8 +109,8 @@ set -g @continuum-restore 'on'
# Restore vim sessions
set -g @resurrect-strategy-vim 'session'

# Include WSL specific stuff - this might be a bit flaxy depending on distro
if-shell "test $OSTYPE = linux-gnu && test -n $WSL_DISTRO_NAME" 'source-file ~/.tmux.wsl.conf' 'source-file ~/.tmux.macos.conf'
# Source wsl tmux conf if $WSLENV is not empty
if-shell 'test -n "$WSLENV"' 'source-file ~/.tmux.wsl.conf' 'source-file ~/.tmux.macos.conf'

# Initialize TPM (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
6 changes: 3 additions & 3 deletions dotfiles/.tmux.wsl.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copy-paste integration for WSLENV
if-shell -b 'test -n "$WSLENV"' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel clip.exe'
if-shell -b 'test -n "$WSLENV"' 'bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel clip.exe'
# Copy-paste integration
bind -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel clip.exe
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel clip.exe

0 comments on commit 326c8a3

Please sign in to comment.