Skip to content

Instantly share code, notes, and snippets.

@v-yarotsky
Created March 22, 2012 11:57
Show Gist options
  • Save v-yarotsky/2157908 to your computer and use it in GitHub Desktop.
Save v-yarotsky/2157908 to your computer and use it in GitHub Desktop.
Mac OS X tmux config
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH
#
#
# Usage:
# - Prefix is set to Ctrl-a (make sure you remapped Caps Lock to Ctrl)
# - All prefixed with Ctrl-a
# - Last used window: /
# - Last used pane: ;
# - Vertical split: v
# - Horizontal split: s
# - Previous window: [
# - Next window: ]
# - Choose session: Ctrl-s
# - Quick window: Ctrl-q
set-option -g default-command "reattach-to-user-namespace -l zsh"
### LOOK & FEEL ###
set -g default-terminal "xterm-256color"
# default statusbar colors
set-option -g status-bg colour235
set-option -g status-fg colour179
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg colour244
set-window-option -g window-status-bg default
# active window title colors
set-window-option -g window-status-current-fg colour166
set-window-option -g window-status-current-bg default
set-window-option -g window-status-current-attr bright
# pane border
set-option -g pane-border-fg colour235
set-option -g pane-active-border-fg colour240
# pane number display
set-option -g display-panes-active-colour colour33
set-option -g display-panes-colour colour166
# clock
set-window-option -g clock-mode-colour colour64
# status bar right contents
set -g status-right-length 65
set -g status-right "#[fg=colour187][#(itunesartist) - #(itunestrack)] #[fg=default][%H:%M %e-%b-%Y]"
set -g status-interval 5
set-option -g mouse-select-pane on
set-option -g mouse-select-window on
set-option -g mode-mouse on
set-window-option -g utf8 on
set-option -g status-keys vi
set-option -g mode-keys vi
#no command delay
set -sg escape-time 0
#count windows and panes from 1
set -g base-index 1
setw -g pane-base-index 1
### KEYS ###
#using C-a as prefix
unbind C-b
set-option -g prefix C-a
bind C-a send-prefix
unbind /
bind / last-window
unbind %
bind s split-window -v
unbind '"'
bind v split-window -h
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
unbind {
bind { swap-pane -D
unbind }
bind } swap-pane -U
unbind r
bind r source-file ~/.tmux.conf; display "Reloaded"
bind Escape copy-mode
bind p paste-buffer
unbind [
bind [ previous-window
unbind ]
bind ] next-window
unbind o
bind o select-pane -t :.-
bind C-q command-prompt -I "htop" -p "Quick window command: " "new-window '%%'"
bind -t vi-copy 'v' begin-selection
bind -t vi-copy 'y' copy-selection
bind C-c run "tmux save-buffer - | pbcopy"
bind C-v run "tmux set-buffer \"$(pbpaste)\"; tmux paste-buffer"
bind C-s choose-session
#!/usr/bin/osascript
on run
set info to ""
tell application "System Events"
set num to count (every process whose name is "iTunes")
end tell
if num > 0 then
tell application "iTunes"
if player state is playing then
set info to artist of current track
end if
end tell
end if
return info
end run
#!/usr/bin/osascript
on run
set info to ""
tell application "System Events"
set num to count (every process whose name is "iTunes")
end tell
if num > 0 then
tell application "iTunes"
if player state is playing then
set info to name of current track
else
set info to "Not Playing."
end if
end tell
end if
return info
end run
@siso
Copy link

siso commented Nov 23, 2013

Brilliant!

I commented out lines 25, 103 and 104 on OSX, as tmux exits immediately.

@dmonopoly
Copy link

There is a typo in the "reload" command:

bind r source-file ~/.tmux.conf; display "Reloaded"

The ";" should be escaped so it has a \ in front:

bind r source-file ~/.tmux.conf\; display "Reloaded"

Otherwise, on startup with "tmux", this actually tries to execute "display", resulting in a "can't establish current session" error message. This can be seen in the man page of tmux, if you search for "display-"

bind-key R source-file ~/.tmux.conf \; \
               display-message "source-file done"

@dmonopoly
Copy link

I have 2 questions:

What does the :.- mean? This part seems to have no effect -

unbind o
bind o select-pane -t :.-

Also, I don't understand what this quick window command is for:

bind C-q command-prompt -I "htop" -p "Quick window command: " "new-window '%%'"

Overall, thanks for sharing this config.

@danielo515
Copy link

The mouse configs are old.
Just use set-option -g mouse on

@lll-phill-lll
Copy link

iTunes track didn't work.
Changed #(itunesartist) - #(itunestrack) in line 57 to #(./itunesartist) - #(./itunestrack)
Added this scripts to System Preferences > security & privacy > privacy > Accessibility
Added x rights to script: chmod +x itunesartist and chmod +x itunestrack

@tomasero
Copy link

tomasero commented Feb 14, 2020

Updated itunesartist

#!/usr/bin/osascript
on run
	set info to ""
	tell application "System Events"
		set num to count (every process whose name is "Music")
	end tell
	if num > 0 then
		tell application "Music"
			if player state is playing then
				set info to artist of current track
			end if
		end tell
	end if
	return info
end run

@tomasero
Copy link

Updated itunestrack

#!/usr/bin/osascript
on run
	set info to ""
	tell application "System Events"
		set num to count (every process whose name is "Music")
	end tell
	if num > 0 then
		tell application "Music"
			if player state is playing then
				set info to name of current track
			else
				set info to "Not Playing."
			end if
		end tell
	end if
	return info
end run

@tomasero
Copy link

tomasero commented Feb 14, 2020

iTunes track didn't work.
Changed #(itunesartist) - #(itunestrack) in line 57 to #(./itunesartist) - #(./itunestrack)
Added this scripts to System Preferences > security & privacy > privacy > Accessibility
Added x rights to script: chmod +x itunesartist and chmod +x itunestrack

I saved my scripts inside /usr/local/bin, and added the scripts to accessibility and added x rights to the scripts, but didn't have to change line 57 from #(itunesartist) - #(itunestrack) to #(./itunesartist) - #(./itunestrack)

@naviat
Copy link

naviat commented Jul 29, 2020

This config is very old with the current tmux version, ex: unbind-key

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