Skip to content

Instantly share code, notes, and snippets.

@adgaudio
Last active October 3, 2015 04:48
Show Gist options
  • Save adgaudio/2393599 to your computer and use it in GitHub Desktop.
Save adgaudio/2393599 to your computer and use it in GitHub Desktop.
# Tmux Configuration
# By Alex Gaudio
# April 15, 2012
# HACKS
#######
#######
## Unfortunately, the osx system clipboard integration sucks. But there's a well documented workaround.
# OS X: pbcopy and pbpaste workaround from ChrisJohnsen
# code available at: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git
#set-option -g default-command "reattach-to-user-namespace -l bash" # makes pbcopy and pbpaste work
# paste clipboard into tmux buffer
#bind V run-shell "reattach-to-user-namespace -l zsh -c 'tmux set-buffer \"$(pbpaste)\"; tmux paste-buffer'"
# put tmux buffer into system clipboard
#bind y run-shell "reattach-to-user-namespace -l zsh -c 'tmux show-buffer | pbcopy'"
# Linux/Unix (untested) http://unix.stackexchange.com/questions/15715/getting-tmux-to-copy-a-buffer-to-the-clipboard
# move x clipboard into tmux paste buffer
#bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
# move tmux copy buffer into x clipboard
#bind C-y run "tmux show-buffer | xclip -i"
##########
# End Hacks
###########
# Use C-p prefix to issue tmux cmds and C-p C-p to send prefix to nested tmux session
unbind C-b
set -g prefix C-o
bind C-o send-prefix
set -g prefix2 C-b
bind C-b send-prefix -2
# Command Prompt
unbind \;
bind \; command-prompt # colon also works
# Help screen: rebind list-keys window into a new pane
bind ? split-window -h 'exec tmux list-keys | less'
# Client/Session handling
bind -r N switch-client -n # next session
bind -r P switch-client -p # prev session
bind L switch-client -l # last session
bind C command-prompt -p "new-session params" "new-session %%"
bind K command-prompt -p "kill-session params" "kill-session %%"
# Window handling
bind -r n next-window
bind -r p previous-window
bind -r u command-prompt -p "link-window <params>" "link-window %%"
bind -r C-u unlink-window
# Pane handling
bind -r o select-pane -t :.+ # next pane
bind -r C-o select-pane -t :.- # prev pane
bind -r C-h join-pane -s :. -t :- # push current pane to the left
bind -r C-l join-pane -s :. -t :+ # push current pane to the right
bind -r M-L join-pane -s :+ -t :. # pull right window's pane into current window
bind -r M-H join-pane -s :- -t :. # pull left window's pane into current window
bind -r Left resize-pane -L 5
bind -r Right resize-pane -R 5
bind -r Up resize-pane -U 5
bind -r Down resize-pane -D 5
bind -r | split-window -h
bind -r _ split-window -v
bind k last-pane
bind S setw synchronize-panes # Toggle synchronized input to all panes in current window
bind -r Space next-layout
# Buffer handling # Integrating buffers with system clipboard is hack section at top.
# Buffers are very useful and very pain in the ass
bind -r - delete-buffer
bind = list-buffers
bind b command-prompt -p "buffer id?" "paste-buffer -b %%"
#bind-key C-P pipe-pane -o 'cat >>~/tmuxout.`date +%H:%M:%S`.#S-#I-#P' # log pane's output. Not necessary if you use the
automated session backup program provided in the tmux src.
unbind ]
bind v paste-buffer
# Window Monitoring
set -g visual-content on
set -g visual-silence on
setw -g monitor-activity on # Notify when activity in another window
bind C-M command-prompt -p "monitor-content <params>" "setw monitor-content %%"
#bind C-m command-prompt -p "monitor-silence interval?" "monitor-silence %%""
# Reload key
bind r source-file ~/.tmux.conf
# open a man page in new pane
bind m command-prompt -p "man page:" "split-window -h 'exec man %%'"
# Mouse Handling # Warning: surprising results on some terminals,
# but super useful when works!
set -g mouse-select-window on
set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mode-mouse on # mouse scrolling through history buffer
# History buffer limit
set -g history-limit 5000
# Set status bar colors
#set -g status-bg black
#set -g status-fg white
#set -g status-left '#[fg=red][#S]'
#set -g status-left-length 100
# Clock Settings
set -g clock-mode-style 12
# Vi or emacs style keys...
setw -g mode-keys vi
# Tmux messages have longer timeout
set -g display-time 2000
# Start new windows at index=1 (rather than 0)
set -g base-index 1
# Change window size to fit window width as often as possible
# if 2 clients see the same window, window is size of smallest client's window width
setw -g aggressive-resize on
# Enable multiple cmds entered simultaneously w/o prefix key
setw -g repeat-time 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment