When I switched from GNU Screen to Tmux, I was just jazzed that Tmux had a
status bar. To achieve that same effect in Screen I had a cryptic
hardstatus string that I copy–pasted from someplace
lost to the annals of the Internet Archive.
It wasn’t too long after I made the switch until I felt that old hacker itch and began scouring Github for Tmux tips.
You can view my complete
tmux.conf on my github
Tmux Tips for the Uninitiated
fMeta is for super stars
I used to always bind
ato Meta to make Tmux behave like Screen; however, when you use Screen inside Tmux (as I often do with our AWS servers), hitting
acan get pretty tiresome. Plus, you can’t use Readline very effectively without
unbind-key C-b #no more Ctrl-b # Switch me to ^f, thanks set-option -g prefix C-f bind-key f send-prefix
When I first started using Tmux I couldn’t stand the amount of time it took to enter copy-mode. Then I realized—I didn’t have to.
set-option -sg escape-time 0
One of the things I love about Vim splits is that you can hit
|to maximize the current pane and hit
=to bring it back to an even split. Bringing that functionality to Tmux is very powerful and super easy. This line will let you hit
|to maximize a single pane and then hit
|again to bring it back to the original split.
Warning: this is a tip that will only work with tmux 1.8+ (check your version via
bind-key | resize-pane -Z \; display-message "Zoom zoom zoom"
Vim-esque system clipboard copy–paste
Sometimes system clipboard support from Vim isn’t enough. It’s convenient to be able to pull whatever is in your Tmux buffer onto your system clipboard (preferably without having to memorize any new keybindings and without overwriting any existing keybindings).
First, I set the window mode-keys to use Vi bindings:
set-window-option -g mode-keys vi
Next, I bind
Meta Escto enter Tmux copy-mode:
unbind-key [ bind-key Escape copy-mode
After that, I bind visual-selection and copy keys inside vi-copy mode to their Vim equivalents:
bind-key -t vi-copy 'v' begin-selection bind-key -t vi-copy 'y' copy-selection
Finally, I bind
Meta yto execute a shell command. This should work on either Linux or OSX, although I’ve only tested this on OSX:
if-shell 'test "$(uname -s)" = "Darwin"' 'bind-key y run-shell "tmux show-buffer | pbcopy" \; display-message "Copied tmux buffer to system clipboard"' if-shell 'test "$(uname -s)" = "Linux"' 'bind-key y run-shell "tmux show-buffer | xclip -sel clip -i" \; display-message "Copied tmux buffer to system clipboard"'
OSX Specific Tmux file
Even though Tmux and Vim are really popular on OSX—they are, essentially, broken. You have to do the whole
reattach-to-user-namespacething to get Vim’s clipboard to play nicely inside Tmux. This mess makes your
tmux.conflook more cluttered and makes your dotfiles a little less portable. To fix this I keep an OSX Specific
#dumb osx if-shell 'test "$(uname)" = "Darwin"' 'source ~/.tmux-osx.conf'
Steve Losh’s Bad Wolf Status Bar
News Flash: Steve Losh makes cool looking stuff. In Steve’s version of this he uses a small script to get his unread email count from his local offlineimap folder. In the version below I use a little bash script I wrote to grab weather info (that I call weathermajig).
# Bad Wolf by Steve Losh # ===================== set -g status-fg white set -g status-bg colour234 # set -g status-bg default #set for transparent background set -g window-status-activity-attr bold set -g pane-border-fg colour245 set -g pane-active-border-fg colour39 set -g message-fg colour16 set -g message-bg colour221 set -g message-attr bold # Custom status bar # Powerline set -g status-left-length 32 set -g status-right-length 150 set -g status-interval 5 # Lets add the current weather to our status bar—why? Well Why the french-toast not? set -g status-left '#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour238,nobold]#[fg=colour15,bg=colour238,bold] #(weathermajig boulder --short) #[fg=colour238,bg=colour234,nobold]' set -g status-right '#[fg=colour245]❬ %R ❬ %d %b #[fg=colour254,bg=colour234,nobold]#(rdio-current-track-tmux)#[fg=colour16,bg=colour254,bold] #h ' set -g window-status-format "#[fg=white,bg=colour234] #I #W " set -g window-status-current-format "#[fg=colour234,bg=colour39]#[fg=colour16,bg=colour39,noreverse,bold] #I ❭ #W #[fg=colour39,bg=colour234,nobold]"
← View Weblog