Last active
November 29, 2023 08:30
-
-
Save vincenthsu/6847a8f2a94e61735034e65d17ca0d66 to your computer and use it in GitHub Desktop.
Tmux version verification (works with v1.8 to v2.1 )
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
# Overwrite configs depending on version | |
run-shell "bash ~/.tmux/verify_tmux_version.sh" |
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
# User key bindings | |
# ^C - create new window | |
# c - create new window (default key) | |
# \ | % - vsplit | |
# - _ " - split | |
unbind ^C | |
bind ^C new-window; | |
bind \ split-window -h | |
bind | split-window -h | |
bind - split-window -v | |
bind _ split-window -v | |
# Mouse mode is off by default | |
# <prefix> M : to turn it off | |
# <prefix> m : to turn it on | |
unbind m | |
bind m set -g mode-mouse on \; set -g mouse-resize-pane on \; set -g mouse-select-pane on \; set -g mouse-select-window on \; display "Mouse ON" | |
bind M set -g mode-mouse off \; set -g mouse-resize-pane off \; set -g mouse-select-pane off \; set -g mouse-select-window off \; display "Mouse OFF" |
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
# User key bindings | |
# ^C - create new window | |
# c - create new window (default key) | |
# \ | % - vsplit | |
# - _ " - split | |
unbind ^C | |
bind ^C new-window; | |
bind \ split-window -h | |
bind | split-window -h | |
bind - split-window -v | |
bind _ split-window -v | |
# Mouse mode is off by default | |
# <prefix> M : to turn it off | |
# <prefix> m : to turn it on | |
unbind m | |
bind m set -g mode-mouse on \; set -g mouse-resize-pane on \; set -g mouse-select-pane on \; set -g mouse-select-window on \; display "Mouse ON" | |
bind M set -g mode-mouse off \; set -g mouse-resize-pane off \; set -g mouse-select-pane off \; set -g mouse-select-window off \; display "Mouse OFF" | |
# pass on focus events to vim inside of tmux | |
set -g focus-events on |
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
# User key bindings | |
# ^C - create new window | |
# c - create new window (default key) | |
# \ | % - vsplit | |
# - _ " - split | |
unbind c | |
bind c new-window -c "#{pane_current_path}" | |
bind ^C new-window -c "#{pane_current_path}" | |
bind \ split-window -h -c "#{pane_current_path}" | |
bind | split-window -h -c "#{pane_current_path}" | |
bind - split-window -v -c "#{pane_current_path}" | |
bind _ split-window -v -c "#{pane_current_path}" | |
# Mouse mode is off by default | |
# <prefix> M : to turn it off | |
# <prefix> m : to turn it on | |
set -g mouse-utf8 on | |
unbind m | |
bind m set -g mouse on \; display "Mouse ON" | |
bind M set -g mouse off \; display "Mouse OFF" | |
# pass on focus events to vim inside of tmux | |
set -g focus-events on | |
# List of plugins | |
set -g @plugin 'tmux-plugins/tpm' | |
# Restore tmux environment | |
set -g @plugin 'tmux-plugins/tmux-resurrect' | |
# Automatic restore | |
set -g @plugin 'tmux-plugins/tmux-continuum' | |
# Plugin settings | |
set -g @continuum-restore 'on' | |
# Initialize TMUX plugin manager (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
#!/bin/bash | |
verify_tmux_version () { | |
tmux_home=~/.tmux | |
tmux_version="$(tmux -V | cut -c 6-)" | |
if [[ $(echo "$tmux_version >= 2.1" | bc) -eq 1 ]] ; then | |
tmux source-file "$tmux_home/tmux_2.1_up.conf" | |
exit | |
elif [[ $(echo "$tmux_version >= 1.9" | bc) -eq 1 ]] ; then | |
tmux source-file "$tmux_home/tmux_1.9_to_2.1.conf" | |
exit | |
else | |
tmux source-file "$tmux_home/tmux_1.9_down.conf" | |
exit | |
fi | |
} | |
verify_tmux_version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using cut may result in issues in versions that have alphabets such as ‘3.3a’.
Running the script directly in the terminal will display an error message: ‘Parse error: bad expression’.
Therefore I replaced cut with sed (copy from https://stackoverflow.com/a/40902312).