tmux.conf 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. ##### My (demuredemeanor) tmux config, a work in progress
  2. # Uses tabstop=4; shiftwidth=4 tabs; foldmarker={{{,}}};
  3. # https://notabug.org/demure/dotfiles/
  4. # legacy repo http://github.com/demure/dotfiles
  5. #
  6. # Note to self: set=set-option; setw=set-window-option; setenv=set-environment;
  7. ### Main Settings ### {{{
  8. ## Fix glitch with underlined text in Terminal.app and hanging Prompt (iOS)
  9. ## From https://github.com/terlar/dotfiles/blob/master/tmux.conf
  10. ## Assume http://sourceforge.net/mailarchive/message.php?msg_id=30825085 is origin
  11. set -ag terminal-overrides ",*:XT@"
  12. #new-session ## tmux attach makes new, if not running
  13. set -ga update-environment 'DISPLAY' # Maybe fix DISPLAY?
  14. set -g base-index 1 ## Window numbering starts at 1
  15. set -g pane-base-index 1 ## Pane numbering starts at 1
  16. setw -g automatic-rename on ## Auto set window title
  17. setw -g aggressive-resize on ## Aggressive windows: For screen size, of diff connections, on diff windows
  18. set -g default-terminal "tmux-256color"
  19. #set -g default-terminal "screen-256color"
  20. set -g history-limit 10000 ## Scroll back history
  21. set -g display-panes-time 4000 ## Increase show pane time
  22. set -g renumber-windows on ## Make windows auto renumber
  23. set -g lock-command vlock ## Use vlock as console lock
  24. set -g mouse on ## Mouse
  25. ### End Main Settings ### }}}
  26. ### Key Bindings ### {{{
  27. unbind C-z ## Unbind C-z so I don't suspend, and free for bind
  28. #unbind C-b ## Unbind C-b, so I can make C-z the prefix
  29. set -g prefix C-z ## Change prefix key to C-z
  30. bind-key C-z last-window ## Make <prefix>C-z go to last window
  31. #unbind C-a
  32. bind-key C-a send-prefix ## Make <prefix>C-a send C-z literally
  33. ## Join windows: <prefix> s, <prefix> j
  34. bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
  35. bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'"
  36. ## URL grab: <prefix> u
  37. #bind-key u capture-pane \; save-buffer /tmp/tmux-buffer \; new-window -n "urlview" '$SHELL -c "urlview < /tmp/tmux-buffer"'
  38. bind-key u capture-pane \; save-buffer /tmp/tmux-buffer \; new-window -n "urlscan" '$SHELL -c "urlscan --single < /tmp/tmux-buffer || urlview < /tmp/tmux-buffer"'
  39. bind-key U capture-pane \; save-buffer /tmp/tmux-buffer \; new-window -n "urlscan" 'urlscan --single --compact --run "tmux new-window tuir {}" < /tmp/tmux-buffer'
  40. ## Reload tmux.conf: <prefix> R
  41. bind R source-file ~/.config/tmux/tmux.conf \; display-message "Config reloaded..."
  42. ## Lock screen
  43. bind-key -T prefix X confirm-before -p "lock tmux? (y/n)" lock-session
  44. ## Better Bindings for Splitting
  45. bind h split-window -h
  46. bind v split-window -v
  47. ## Better Bindings for Splitting with current path
  48. bind H split-window -hc "#{pane_current_path}"
  49. bind V split-window -vc "#{pane_current_path}"
  50. bind C new-window -c "#{pane_current_path}"
  51. ### Paste Buffer Bindings
  52. bind b list-buffers ## List paste buffers
  53. #bind p paste-buffer ## Paste from the top paste buffer
  54. bind P choose-buffer ## Choose which buffer to paste from
  55. ### vi Mode for Scroll Back ### {{{
  56. setw -g mode-keys vi
  57. #unbind [
  58. bind Escape copy-mode
  59. unbind p
  60. bind p paste-buffer
  61. #bind-key -t vi-copy 'v' begin-selection
  62. #bind-key -t vi-copy 'y' copy-selection
  63. bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
  64. #bind-key -t vi-copy Escape cancel
  65. #bind-key -t vi-copy 'Y' copy-end-of-line
  66. #bind-key -t vi-copy 'V' select-line
  67. ### End vi Mode ### }}}
  68. ### Move Window Numbers ### {{{
  69. ## <prefix> Shift left/right
  70. # Inspired by https://superuser.com/questions/343572/how-do-i-reorder-tmux-windows
  71. bind-key S-Left swap-window -t -1
  72. bind-key S-Right swap-window -t +1
  73. ### End Window Numbers ### }}}
  74. ### End Key Bindings ### }}}
  75. ### Theming Settings ### {{{
  76. ## Terminal emulator window title
  77. set -g set-titles on
  78. set -g set-titles-string '#S:#I.#P #W'
  79. ## Notifying if other windows has activities
  80. setw -g monitor-activity on
  81. set -g visual-activity on
  82. ## Clock
  83. setw -g clock-mode-colour green
  84. setw -g clock-mode-style 24
  85. ### Status Bar ### {{{
  86. set -g status-bg black
  87. set -g status-fg white
  88. set -g status-interval 10
  89. ### Clean up host name ### {{{
  90. ## NOTE: %hidden needs 3.2+
  91. %if "#{==:#{host},moving-computer-of-doom}"
  92. ## Set for laptop
  93. %hidden S_HOST="doom"
  94. %elif "#{m:*-of-doom,#{host}}"
  95. ## Truncate personal host names
  96. %hidden S_HOST="#{s/-.*-doom//:host}"
  97. %else
  98. ## Limit hostnames to 10 char
  99. %hidden S_HOST="#{=10:host}"
  100. %endif
  101. ### End Clean up host name ### }}}
  102. ## Status Bar Spacing variable
  103. ## Initial Setting, if <100 col use condensed margin
  104. %if "#{e|>=:#{window_width},100}"
  105. %hidden SBS=" "
  106. %else
  107. %hidden SBS=""
  108. %endif
  109. #set-hook -g client-resized '
  110. #%if "#{e|>=:#{window_width},110}"
  111. #%hidden SBS="_"
  112. #%else
  113. #%hidden SBS="x"
  114. #%endif'
  115. ## Left Status Bar
  116. set -g status-left-length 15
  117. set -g status-left "#[fg=green,bg=#282A2E]${SBS}${S_HOST}${SBS}#[fg=#282A2E,bg=black]#[default]"
  118. ## Right Status Bar
  119. set -g status-right-length 60
  120. ## Show pane title|command, tmux session, datetime
  121. set -g status-right "\
  122. #[fg=#282A2E,bg=black]#[fg=white,bg=#282A2E]#{?pane_in_mode,#[fg=yellow]${SBS}#{pane_mode}${SBS},}\
  123. #[fg=#454A4F,bg=#282A2E]#[fg=white,bg=#454A4F]${SBS}#{?#{!=:#{pane_title},#{host}},#{=15;s/ .*//:pane_title},#{=15:pane_current_command}}${SBS}\
  124. #[fg=#282A2E,bg=#454A4F]#[fg=white,bg=#282A2E]#{?#{!=:#{session_name},#{s/-of-doom//:host}},#{l:${SBS}}#{=10:session_name}#{l:${SBS}},}\
  125. #[fg=#454A4F,bg=#282A2E]#[fg=white,bg=#454A4F]#(while :; do ~/.config/tmux/battery_check.sh; sleep 300; done)\
  126. #[fg=#282A2E,bg=#454A4F]#[fg=cyan,bold,bg=#282A2E]${SBS}%Y-%m-%d${SBS}${SBS}%H:%M${SBS}#[default]"
  127. ## Window Status Bar
  128. setw -g window-status-format "${SBS}#[fg=cyan,dim]#I#[default] #W${SBS}"
  129. setw -g window-status-separator ''
  130. ## Highlighting the active window in status bar
  131. setw -g window-status-current-format '#[fg=black,bg=blue]#[bg=blue,fg=cyan]#I#[bg=blue,fg=white] #W#[bold] #F#[none]#[fg=blue,bg=black]#[default]'
  132. ## Inactive windows
  133. setw -g window-status-last-style 'underscore'
  134. setw -g window-status-activity-style 'fg=blue,bold'
  135. setw -g window-status-bell-style 'fg=red'
  136. ### End Status Bar ### }}}
  137. ### Message/Message Command ### {{{
  138. set -g message-style 'fg=white,bg=cyan,bright'
  139. set -g message-command-style 'fg=white,bg=cyan,bright'
  140. ### End Message ### }}}
  141. ### Pane Colors ### {{{
  142. set -g pane-border-style 'fg=white'
  143. set -g pane-active-border-style 'fg=cyan'
  144. set -gq pane-border-lines double
  145. #set -g pane-border-status off
  146. ### End Pane Colors ### }}}
  147. ### End Theming Settings ### }}}