Advertisement
msjche

~/.tmux.conf

Jul 29th, 2013
898
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.50 KB | None | 0 0
  1. #-------- Common Settings {{{
  2. #------------------------------------------------------
  3. # how to use tmux demo video: http://www.youtube.com/watch?v=ZNM1KfqpyGo
  4. # https://gist.github.com/1147532
  5. # http://crunchbanglinux.org/forums/post/236199/
  6. # https://gist.github.com/adinapoli/4723872
  7.  
  8. # change prefix key to Ctrl-a; like GNU Screen
  9. unbind-key C-b
  10. set-option -g prefix C-a
  11.  
  12. # goto last used window
  13. bind-key C-a last-window
  14.  
  15. # Nested Tmux Session
  16. # send to tmux session within another tmux session; like screen
  17. bind-key a send-prefix
  18.  
  19. # Lowers the delay time between the prefix key and other keys - fixes pausing in vim
  20. set-option -sg escape-time 0
  21.  
  22. # reload .tmux.conf
  23. # killall tmux ; sometimes reloading config wont do shit
  24. bind-key r source-file ~/.tmux.conf \; display-message "Configuration reloaded"
  25.  
  26. # history size
  27. set-option -g history-limit 10000
  28.  
  29. # enable shell hotkeys C-left/C-right
  30. # http://sigizmund.com/tmux-and-c-leftc-right/
  31. # set-window-option -g xterm-keys on
  32.  
  33. # enable 256 color terminal
  34. # http://blog.sanctum.geek.nz/256-colour-terminals/
  35. set-option -g default-terminal "screen-256color"
  36.  
  37. # start panes at 1 instead of 0
  38. set-window-option -g pane-base-index 1
  39.  
  40. # pane divider color; non active pane
  41. set-option -g pane-border-fg green
  42. set-option -g pane-border-bg black
  43.  
  44. # pane divider color; active pane
  45. # helps when you have more than two panes.
  46. # version 1.8 makes it easy to see 2 panes now
  47. set-option -g pane-active-border-fg white
  48. set-option -g pane-active-border-bg yellow
  49.  
  50. # renumber windows sequentially after closing any of them
  51. # https://github.com/thoughtbot/dotfiles/blob/master/tmux.conf
  52. set-option -g renumber-windows on
  53.  
  54. # renumber windows manually
  55. # https://github.com/jasoncodes/dotfiles/blob/master/config/tmux.conf
  56. bind-key R set renumber-windows on\; new-window\; kill-window\; set renumber-windows off\; display 'Renumbered'
  57.  
  58.  
  59. # set auto rename of windows base on command
  60. #set-window-option -g automatic-rename on
  61. # note: ohmyzsh users commet out DISABLE_AUTO_TITLE=true from zshrc to disable autorename
  62. # http://superuser.com/questions/306028/tmux-and-zsh-custom-prompt-bug-with-window-name
  63.  
  64. #}}}
  65. #-------- Keybinding (Vim Style) {{{
  66. #------------------------------------------------------
  67. # vim keys in command prompt
  68. set-option -g status-keys vi
  69.  
  70. # unicode
  71. set-window-option -g utf8 on
  72.  
  73. # select panes
  74. bind-key k select-pane -U
  75. bind-key h select-pane -L
  76. bind-key j select-pane -D
  77. bind-key l select-pane -R
  78.  
  79. # cycle windows/panes (no prefix)
  80. bind-key -n M-k select-pane -t :.- # prev pane
  81. bind-key -n M-j select-pane -t :.+ # next pane
  82. bind-key -n M-h select-window -t :- # previous window
  83. bind-key -n M-l select-window -t :+ # next window
  84.  
  85. # resize panes
  86. bind-key -r J resize-pane -D 1
  87. bind-key -r K resize-pane -U 1
  88. bind-key -r H resize-pane -L 1
  89. bind-key -r L resize-pane -R 1
  90.  
  91. # better pane split bindings
  92. bind-key \ split-window -h # vertical split
  93. bind-key - split-window -v # horizontal split
  94.  
  95.  
  96. # no confirmation when killing window/pane; by default is set to ask
  97. # http://unix.stackexchange.com/a/30283
  98. bind-key & kill-window
  99. bind-key x kill-pane
  100.  
  101.  
  102. # Sync panes - send what you're typing to other panes.
  103. bind-key C-s set-window-option synchronize-panes
  104.  
  105. #}}}
  106. #-------- Copy Mode (Vim Style) {{{
  107. #------------------------------------------------------
  108. # This section of hotkeys mainly work in copy mode and no where else
  109.  
  110. # vim keys in copy or choice mode
  111. set-window-option -g mode-keys vi
  112.  
  113. # copying selection vim style
  114. # http://jasonwryan.com/blog/2011/06/07/copy-and-paste-in-tmux/
  115. # https://github.com/myfreeweb/dotfiles/blob/master/tmux.conf
  116. bind-key Escape copy-mode # enter copy mode; default [
  117. bind-key p paste-buffer # paste; default ]
  118. bind-key -t vi-copy v begin-selection # begin visual mode
  119. bind-key -t vi-copy V select-line # visual line
  120. bind-key -t vi-copy y copy-selection # yank
  121. bind-key -t vi-copy r rectangle-toggle # visual block toggle
  122. bind-key -t vi-copy Escape cancel # exit copy mode; or hit q
  123.  
  124. # clear scrollback buffer
  125. # demo video: http://www.youtube.com/watch?v=xUB-quCdun0
  126. # http://stackoverflow.com/a/10553992
  127. # hit ctrl+l then ctrl+k
  128. bind-key -n C-k clear-history
  129.  
  130. #}}}
  131. #-------- Mouse {{{
  132. #------------------------------------------------------
  133. # mouse to highlight and copy; to paste use prefix + ]
  134. # http://awhan.wordpress.com/2012/04/18/tmux-copy-paste-with-mouse/
  135. # use shift + mouse to bypass to use system highlighting mode
  136.  
  137. # http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/
  138. # Toggle mouse on
  139. bind-key m \
  140. set-option -g mode-mouse on \;\
  141. set-option -g mouse-resize-pane on \;\
  142. set-option -g mouse-select-pane on \;\
  143. set-option -g mouse-select-window on \;\
  144. display-message 'Mouse: ON'
  145.  
  146. # Toggle mouse off
  147. bind-key M \
  148. set-option -g mode-mouse off \;\
  149. set-option -g mouse-resize-pane off \;\
  150. set-option -g mouse-select-pane off \;\
  151. set-option -g mouse-select-window off \;\
  152. display-message 'Mouse: OFF'
  153.  
  154. # mouse wheel scrolling -- whole window not individual panes
  155. #set-option -g terminal-overrides 'xterm*:smcup@:rmcup@'
  156.  
  157. # }}}
  158. #-------- Window / Pane Settings {{{
  159. #------------------------------------------------------
  160. # start window index on 1 instead of 0
  161. set-option -g base-index 1
  162.  
  163. # start panes at 1 instead of 0
  164. set-window-option -g pane-base-index 1
  165.  
  166. # pane divider color; non active pane
  167. set-option -g pane-border-fg green
  168. set-option -g pane-border-bg black
  169.  
  170. # pane divider color; active pane
  171. # helps when you have more than two panes.
  172. # version 1.8 makes it easy to see 2 panes now
  173. set-option -g pane-active-border-fg white
  174. set-option -g pane-active-border-bg yellow
  175.  
  176. # renumber windows sequentially after closing any of them
  177. # https://github.com/thoughtbot/dotfiles/blob/master/tmux.conf
  178. set-option -g renumber-windows on
  179.  
  180. # renumber windows manually
  181. # https://github.com/jasoncodes/dotfiles/blob/master/config/tmux.conf
  182. bind-key R set renumber-windows on\; new-window\; kill-window\; set renumber-windows off\; display 'Renumbered'
  183.  
  184.  
  185. # set auto rename of windows base on command
  186. #set-window-option -g automatic-rename on
  187. # note: ohmyzsh users commet out DISABLE_AUTO_TITLE=true from zshrc to disable autorename
  188. # http://superuser.com/questions/306028/tmux-and-zsh-custom-prompt-bug-with-window-name
  189.  
  190. #}}}
  191. #-------- Statusbar {{{
  192. #------------------------------------------------------
  193. # UTF-8 character support in the status bar
  194. set-option -g status-utf8 on
  195.  
  196. # refresh the status bar every 1 second.
  197. set-option -g status-interval 1000
  198.  
  199. # Time messages remain in the status bar. Lower this number
  200. # if this is too distracting.
  201. set-option -g display-time 4000
  202.  
  203. # command/message line colors
  204. set-option -g message-fg white
  205. set-option -g message-bg black
  206. set-option -g message-attr bright
  207.  
  208. # CENTER {{{
  209. # window notifications; display activity on other window
  210. set-window-option -g monitor-activity on
  211. set-option -g visual-activity on
  212.  
  213. # statusbar colors
  214. set-option -g status-fg white
  215. set-option -g status-bg black
  216. set-option -g status-attr default
  217.  
  218. # window title colors; non active
  219. set-window-option -g window-status-fg cyan
  220. set-window-option -g window-status-bg default
  221. set-window-option -g window-status-attr dim
  222.  
  223. # window title colors; active
  224. set-window-option -g window-status-current-fg white #font
  225. set-window-option -g window-status-current-bg red #boarder
  226. set-window-option -g window-status-current-attr bright
  227.  
  228.  
  229. #}}}
  230. # LEFT SIDE {{{
  231. # in the status bar.
  232. set-option -g status-justify centre
  233. set-option -g status-left-length 40
  234. set-option -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
  235.  
  236. #}}}
  237. # RIGHT SIDE {{{
  238. # use "man date" to set the clock to your liking
  239. set-option -g status-right "#[fg=blue]#(~/battery Discharging) | #[fg=cyan]%a %D %l:%M:%p"
  240.  
  241. #}}}
  242.  
  243.  
  244. #}}}
  245. #-------- External Scripts {{{
  246. #------------------------------------------------------
  247. # default shell
  248. set-option -g default-command /bin/zsh
  249. set-option -g default-shell /bin/zsh
  250.  
  251. # Run command on idle; screensaver
  252. # demo video: http://www.youtube.com/watch?v=s0T82aJn1DQ
  253. #set-option -g lock-after-time 10
  254. #set-option -g lock-command "/usr/bin/cmatrix -C blue"
  255.  
  256. #}}}
  257. #-------- Layout {{{
  258. #------------------------------------------------------
  259. # demo video: http://www.youtube.com/watch?v=sxw-n5Du600
  260. # http://amjith.blogspot.com/2011/08/scripting-tmux-layouts.html
  261. # http://unix.stackexchange.com/a/17118
  262. # -v = split horizontal
  263. # -h = split veritical
  264.  
  265. # work
  266. bind-key M-w new-window -n work -c $HOME \; \
  267. send-keys 'sudo su' 'Enter' \; \
  268. split-window -h -p 50 -t 1 \; \
  269. select-pane -t 1
  270.  
  271. # chat
  272. bind-key M-c new-window -n chat -c $HOME \; \
  273. send-keys 'irc' 'Enter' \; \
  274. select-pane -t 1
  275.  
  276. # torrent
  277. bind-key M-t new-window -n torrent -c $HOME \; \
  278. send-keys 'clear && figlet Torrentz EU && ~/Scripts/torrentzeu.sh' 'Enter' \; \
  279. split-window -v -p 50 -t 1 \; \
  280. send-keys 'clear && tpbs ' \; \
  281. split-window -h -p 60 -t 1 \; \
  282. send-keys 'cd /media/data/.blackbox/ && ranger' 'Enter' \; \
  283. split-window -h -p 60 -t 2 \; \
  284. send-keys '~/Scripts/blocklist.sh && transmission-daemon && sleep 3 && transmission-remote-cli' 'Enter' \; \
  285. select-pane -t 2
  286.  
  287. # music
  288. bind-key M-m new-window -n music -c $HOME \; \
  289. send-keys 'ncmpcpp' 'Enter' \; \
  290. split-window -v -p 50 -t 1 \; \
  291. send-keys 'clear && cd ~/Music && spotify-cli' 'Enter' \; \
  292. split-window -h -p 50 -t 2 \; \
  293. send-keys 'clear && pandora-cli' 'Enter' \; \
  294. select-pane -t 1
  295.  
  296. # fap
  297. bind-key M-f new-window -n fap -c $HOME \; \
  298. send-keys 'ranger ~/Storage/.blackbox' 'Enter' \; \
  299. split-window -v -p 50 -t 1 \; \
  300. send-keys 'clear && figlet Search Skeet CMX' 'Enter' \; \
  301. split-window -h -p 50 -t 1 \; \
  302. send-keys 'reddit_top -s pornvids' 'Enter' \; \
  303. split-window -h -p 50 -t 2 \; \
  304. send-keys 'clear && figlet Discover' 'Enter' \; \
  305. select-pane -t 2
  306.  
  307. # stats
  308. bind-key M-s new-window -n stats -c $HOME \; \
  309. send-keys 'htop' 'Enter' \; \
  310. split-window -v -p 50 -t 1 \; \
  311. send-keys 'clear && figlet Freespace' 'Enter' \; \
  312. split-window -h -p 50 -t 1 \; \
  313. send-keys 't lsp | less' 'Enter' \; \
  314. split-window -h -p 50 -t 2 \; \
  315. send-keys 'df' 'Enter' \; \
  316. select-pane -t 2
  317.  
  318. # news
  319. bind-key M-n new-window -n news -c $HOME \; \
  320. send-keys 'cortex linux' 'Enter' \; \
  321. split-window -h -p 50 -t 1 \; \
  322. send-keys 'newsbeuter' 'Enter' \; \
  323. split-window -v -p 50 -t 2 \; \
  324. send-keys 'pods' 'Enter' \; \
  325. split-window -h -p 50 -t 3 \; \
  326. send-keys 'cd Podcasts && ranger' 'Enter' \; \
  327. select-pane -t 1
  328.  
  329. # video
  330. bind-key M-v new-window -n video -c $HOME \; \
  331. send-keys 'ranger ~/Videos' 'Enter' \; \
  332. split-window -v -p 50 -t 1 \; \
  333. send-keys 'clear && figlet youtube-viewer' 'Enter' \; \
  334. split-window -h -p 50 -t 1 \; \
  335. send-keys 'clear && figlet rtmpdump' 'Enter' \; \
  336. split-window -h -p 50 -t 2 \; \
  337. send-keys 'clear && figlet Freespace' 'Enter' \; \
  338. select-pane -t 2
  339.  
  340. #}}}
  341. #-------- Zooming {{{
  342. #------------------------------------------------------
  343. # v1.8 comes with zooming already (prefix + z)
  344. # demo video: http://www.youtube.com/watch?v=6HesFWUpU18
  345.  
  346.  
  347. # this is for older version of tmux
  348.  
  349. # Zoom Script (by jipumarino)
  350. # demo video: http://www.youtube.com/watch?v=gZ0NoRROxvo
  351. # https://github.com/jipumarino/tmux-zoom
  352. # if you use a different starting number in your window/pane
  353. # then change the number 0 to match it
  354. # $old_zoom_window.0 and $new_zoom_window.0
  355. bind-key -r Z run-shell "~/.scripts/tmux-zoom.sh"
  356.  
  357. # Zoom Toggle Key ( modified by Gnomeye )
  358. # demo video: http://www.youtube.com/watch?v=6_PVJQvhBeI
  359. # https://github.com/gotbletu/shownotes/blob/master/tmux_maximize_pane.txt
  360. # if you use a different starting number in your window/pane
  361. # then change the number 0 to match it
  362. # bind-key } run-shell "if [[ $(tmux list-window) =~ tmux-zoom ]]; then tmux last-window; tmux swap-pane -s tmux-zoom.0; tmux kill-window -t tmux-zoom; else tmux new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read'; tmux swap-pane -s tmux-zoom.0; tmux select-window -t tmux-zoom;fi"
  363.  
  364. # http://pempek.net/articles/2013/04/14/maximizing-tmux-pane-new-window/
  365. # }}}
  366. #-------- Link Grabber {{{
  367. #------------------------------------------------------
  368. # This section is for grabbing links on the current pane/window without the mouse
  369. # and launching it with GUI or CLI browser
  370.  
  371. # urlview; extract links and launch it
  372. # demo video: http://www.youtube.com/watch?v=guB4WuVFhtY
  373. # https://wiki.archlinux.org/index.php/Tmux#Browsing_URL.27s
  374. bind-key u capture-pane \; save-buffer /tmp/tmux-buffer \; \
  375. new-window -n "urlview" '$SHELL -c "urlview < /tmp/tmux-buffer"'
  376. # http://does-not-exist.org/mail-archives/mutt-users/msg18479.html
  377. # to set default browser add to ~/.urlview
  378. # COMMAND exec >> /tmp/urlview.out 2>&1; set -x; $BROWSER
  379.  
  380. # urlscan context view and url view
  381. # demo video: http://www.youtube.com/watch?v=c-3IdFufY5Q
  382.  
  383. # compact view; show links only
  384. bind-key y capture-pane \; save-buffer /tmp/tmux-buffer \; \
  385. new-window -n "urlscan" '$SHELL -c "urlscan -c < /tmp/tmux-buffer"'
  386. # context view; show dialog near links
  387. bind-key Y capture-pane \; save-buffer /tmp/tmux-buffer \; \
  388. new-window -n "urlscan" '$SHELL -c "urlscan < /tmp/tmux-buffer"'
  389.  
  390. # w3m context view
  391. # demo video: http://www.youtube.com/watch?v=C7YPjbrTeCs
  392. # http://www.mail-archive.com/mutt-users@mutt.org/msg09657.html
  393.  
  394. bind-key g capture-pane \; save-buffer /tmp/tmux-buffer \; \
  395. new-window -n "w3m" '$SHELL -c "w3m < /tmp/tmux-buffer"'
  396. # hit : to activate links
  397. # hit Esc then Shift+M to open GUI browser
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement