Skip to content

Instantly share code, notes, and snippets.

@suewonjp
Last active December 17, 2022 19:35
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suewonjp/171bc15bd81f434df3397140015c8eee to your computer and use it in GitHub Desktop.
Save suewonjp/171bc15bd81f434df3397140015c8eee to your computer and use it in GitHub Desktop.
My .tmux.conf ( usable across multi-platforms including OS X | Linux | Cygwin )
set-option -g default-terminal "xterm-256color"
set-window-option -g xterm-keys on
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
setw -g mode-keys vi
unbind C-b
# remap prefix to Control + Space
set -g prefix C-Space
# bind 'C-Space C-Space' to type 'C-Space'
bind C-Space send-prefix
# set small delay for each command
set -sg escape-time 1
set -g display-panes-time 4000
bind \ split-window -h -c '#{pane_current_path}'
bind - split-window -v -c '#{pane_current_path}'
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
bind @ respawn-pane -k
bind C-b copy-mode
bind -T copy-mode-vi v send-keys -X begin-selection
# To prevent some garbage characters from being printed to screen after copying or selecting something
# See https://www.reddit.com/r/tmux/comments/2xgrf8/garbage_characters_printed_to_screen_after_a/
set -g set-clipboard off
setw -g mouse on
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
#set -g mouse-select-window on
# set color of active pane
if-shell -b '[ `echo "$(tmux -V | grep -o "[2-9]\.[0-9]\+") >= 2.8" | bc` -eq 1 ]' \
'set -g pane-border-style bg=black,fg=white; set -g pane-active-border-style bg=black,fg=green' \
'set -g pane-border-fg colour235; set -g pane-border-bg black; set -g pane-active-border-fg green; set -g pane-active-border-bg black'
# color status bar
#set -g status-bg colour235
#set -g status-fg white
# disable status bar
set -g status off
if-shell 'uname | grep -q Darwin' \
'source-file ~/.tmux.conf.osx' \
'if-shell "uname | grep -q CYGWIN" "source-file ~/.tmux.conf.cygwin" "source-file ~/.tmux.conf.linux"'
# Copy the current buffer to system clipboard
bind C-c run "tmux save-buffer - | cat >/dev/clipboard" \
# Copy system clipboard to the current buffer and then paste the content
bind C-v run "cat /dev/clipboard | tmux load-buffer - && tmux paste-buffer" \
# Copy selection using a vi-like command; also copy it to system clipboard
if-shell -b '[ `echo "$(tmux -V | grep -o "[2-9]\.[0-9]\+") >= 2.4" | bc` -eq 1 ]' \
'bind -T copy-mode-vi y send-keys -X copy-pipe "cat >/dev/clipboard"' \
'bind -t vi-copy y copy-pipe "cat >/dev/clipboard"'
# If you prefer xclip, use :
# bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
# bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
# Copy the current buffer to system clipboard
bind C-c run "tmux save-buffer - | xsel --clipboard --input"
# Copy system clipboard to the current buffer and then paste the content
bind C-v run "xsel --clipboard --output | tmux load-buffer - && tmux paste-buffer"
# Copy selection using a vi-like command; also copy it to system clipboard
if-shell -b '[ `echo "$(tmux -V | grep -o "[2-9]\.[0-9]\+") >= 2.4" | bc` -eq 1 ]' \
'bind -T copy-mode-vi y send-keys -X copy-pipe "cat | xsel --clipboard --input"' \
'bind -t vi-copy y copy-pipe "cat | xsel --clipboard --input"'
# Copy selection using a vi-like command; also copy it to system clipboard
bind -T copy-mode-vi y send-keys -X copy-pipe "pbcopy"
@groundnuty
Copy link

please include which tmux version it's compatible with

@suewonjp
Copy link
Author

suewonjp commented Oct 4, 2017

This configuration is compatible with tmux 2.2

@modestotech
Copy link

Any updates for version 2.9A?

@suewonjp
Copy link
Author

Configuration is now compatible with 2.9A. Also it'll work with older versions. (but not too older)

And it works with Windows Subsystem for Linux on Windows 10.

@modestotech
Copy link

Thanks!

@suewonjp
Copy link
Author

suewonjp commented Nov 1, 2019

-if-shell -b '[ "$(echo "${TMUX_VERSION:0:3} >= 2.8" | bc)" = 1 ]' \
+if-shell -b '[ `echo "$(tmux -V | grep -o "[2-9]\.[0-9]\+") >= 2.8" | bc` -eq 1 ]' \

Shell syntax for if-shell should conform to POSIX on some system. (E.g., Ubuntu)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment