groundnuty
3/26/2017 - 9:11 AM

My .tmux.conf ( usable across multi-platforms including OS X | Linux | Cygwin )

My .tmux.conf ( usable across multi-platforms including OS X | Linux | Cygwin )

# Bash 4.x uses GPLv3 license, and that's why Apple is sticking to 3.2.x. 
# Apple highly likely won't upgrade its bash version to 4.0 in the future. 
# So we need to install it on our own in order to use bash 4.x on OS X.

# $ brew install bash bash-completion

# $ sudo -i
# Password:  
#
# # echo "$(brew --prefix)/bin/bash" >> /etc/shells
# # exit
# Now let's change our login shell to the new version of Bash:
#
# $ chsh -s $(brew --prefix)/bin/bash
# Most likely, the new bash will be installed at /usr/local/bin/bash
#
# http://blog.bennycornelissen.nl/bash-4-x-on-osx-the-bash-that-apple-wont-ship/

# The following setting assumes that you use Bash 4.x on OS X.
set -g default-command "reattach-to-user-namespace -l /usr/local/bin/bash"
#set -g default-command "reattach-to-user-namespace -l /bin/bash" # Using the default Bash

# Copy the current buffer to system clipboard
bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy"

# Copy system clipboard to the current buffer and then paste the content
bind C-v run "tmux set-buffer $(reattach-to-user-namespace pbpaste); tmux paste-buffer"

# Copy selection using a vi-like command; also copy it to system clipboard
bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# 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
bind -t vi-copy y copy-pipe "cat | xsel --clipboard --input"
# 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
bind -t vi-copy y copy-pipe "cat >/dev/clipboard"
set-option -g default-terminal "xterm-256color"
set-window-option -g xterm-keys on

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 C-b copy-mode

bind -t vi-copy 'v' 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
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

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"'