Advertisement
jv2112

Tmux-Config-Laptop

Apr 17th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 15.88 KB | None | 0 0
  1. # cat << ►_◄ > /dev/null
  2.  
  3.  
  4. # -- general -------------------------------------------------------------------
  5.  
  6. set -g default-terminal "screen-256color" # colors!
  7. setw -g xterm-keys on
  8. set -s escape-time 0                      # fastest command sequences
  9. set -sg repeat-time 600                   # increase repeat timeout
  10. set -s quiet on                           # disable various messages
  11.  
  12. set -g prefix2 C-a                        # GNU-Screen compatible prefix
  13. bind C-a send-prefix -2
  14.  
  15. # uncomment to force vi-style key bindings
  16. # emacs is the default unless $EDITOR or $VISUAL contain 'vi'
  17. #set -g status-keys vi
  18. #setw -g mode-keys vi
  19.  
  20. set -g status-utf8 on                     # expect UTF-8
  21. setw -g utf8 on
  22.  
  23. set -g history-limit 5000                 # boost history
  24.  
  25. # edit configuration
  26. bind e new-window -n '~/.tmux.conf' '${EDITOR:-vim} ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display "~/.tmux.conf sourced"'
  27.  
  28. # reload configuration
  29. bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
  30.  
  31. # see https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
  32. if 'which -s reattach-to-user-namespace' 'set -g default-command "tmux rename-window initializing; tmux set -w automatic-rename; reattach-to-user-namespace $SHELL -l"'
  33.  
  34.  
  35. # ----------------- Python --------------------- #
  36. bind-key M-p new-window -n Python -c $HOME/Python/ \; \
  37.     send-keys 'clear' 'Enter' \; \
  38.     send-keys 'bpython2' 'Enter'  \; \
  39.     split-window -v -p 70 -c $HOME/Python/ \; \
  40.     select-pane -t 1
  41.  
  42.  
  43. # --------------- Music ------------------------- #
  44. bind-key M-t new-window -n Tunes -c $HOME \; \
  45.     send-keys 'cmus' 'Enter' \; \
  46.     split-window -v -p 30 -t 1 \; \
  47.     send-keys 'clear && pianobar' 'Enter' 'tux2112@comcast.net' 'Enter' 'jasl2112' 'Enter' \; \
  48.     #split-window -h -p 50 -t 2 \; \
  49.     select-pane -t 1
  50.  
  51. # ------------- File Manangement --------------- #
  52. bind-key M-f  new-window -n FM -c $HOME \; \
  53.     send-keys 'ranger /home/joe/' 'Enter' \; \
  54.  
  55. # ------------------ IRSSI ---------------------- #
  56. bind-key M-c new-window -n IRSSI -c $HOME \; \
  57.     send-keys 'weechat' 'Enter' \; \
  58.  
  59. #------------------- Redit ------------------------#
  60. bind-key M-r new-window -n Redit -c $HOME \; \
  61.     send-keys 'reddit_top -s archlinux' 'Enter' \; \
  62.     split-window -v -p 40 -t 1  \; \
  63.     send-keys 'reddit_top -s linuxactionshow' 'Enter' \; \
  64.     split-window -v -p 50 -t 1  \; \
  65.     send-keys 'reddit_top -s linux' 'Enter' \; \
  66.     select-pane -t 1
  67.  
  68. # -------------System Monitor ---------------------#
  69. bind-key M-g new-window -n Glances -c $HOME \; \
  70.     send-keys 'glances' 'Enter' \; \
  71.  
  72.  
  73. # -- display -------------------------------------------------------------------
  74.  
  75. set -g base-index 1         # start windows numbering at 1
  76. setw -g pane-base-index 1   # make pane numbering consistent with windows
  77.  
  78. setw -g automatic-rename on # rename window to reflect current program
  79. # renumber windows when a window is closed
  80. set -g renumber-windows on
  81.  
  82. set -g set-titles on                        # set terminal title
  83. set -g set-titles-string '#h ❐ #S ● #I #W'
  84.  
  85. set -g display-panes-time 800 # slightly longer pane indicators display time
  86. set -g display-time 1000      # slightly longer status messages display time
  87.  
  88. set -g status-interval 10     # redraw status line every 10 seconds
  89.  
  90. # 24 hour clock
  91. setw -g clock-mode-style 24
  92.  
  93. # clear both screen and history
  94. bind -n C-l send-keys C-l \; run 'tmux clear-history'
  95.  
  96. # activity
  97. set -g monitor-activity on
  98. set -g visual-activity off
  99.  
  100. # tmux theme, colors and status line
  101. # available themes:
  102. #   - powerline (a powerline inspired theme)
  103. #   - powerline_patched_font (a powerline inspired theme using a patched font)
  104. tmux_conf_theme=powerline
  105.  
  106.  
  107. # -- navigation ----------------------------------------------------------------
  108.  
  109. # create new session
  110. bind C-c new-session
  111.  
  112. # find session
  113. bind C-f command-prompt -p find-session 'switch-client -t %%'
  114.  
  115. # pane navigation
  116. bind -r h select-pane -L  # move left
  117. bind -r j select-pane -D  # move down
  118. bind -r k select-pane -U  # move up
  119. bind -r l select-pane -R  # move right
  120. bind > swap-pane -D       # swap current pane with the next one
  121. bind < swap-pane -U       # swap current pane with the previous one
  122.  
  123. # maximize current pane
  124. bind + run 'cut -c3- ~/.tmux.conf | sh -s maximize_pane'
  125.  
  126. # pane resizing
  127. bind -r H resize-pane -L 2
  128. bind -r J resize-pane -D 2
  129. bind -r K resize-pane -U 2
  130. bind -r L resize-pane -R 2
  131.  
  132. # window navigation
  133. bind -r C-h previous-window # select previous window
  134. bind -r C-l next-window     # select next window
  135. bind Space last-window      # move to last active window
  136.  
  137. # toggle mouse
  138. bind m run "cut -c3- ~/.tmux.conf | sh -s toggle_mouse"
  139.  
  140.  
  141. # -- list choice ---------------------------------------------------------------
  142.  
  143. bind -t vi-choice h tree-collapse
  144. bind -t vi-choice l tree-expand
  145. run 'tmux bind -t vi-choice K start-of-list 2> /dev/null'
  146. run 'tmux bind -t vi-choice J end-of-list 2> /dev/null'
  147. bind -t vi-choice H tree-collapse-all
  148. bind -t vi-choice L tree-expand-all
  149. bind -t vi-choice Escape cancel
  150.  
  151.  
  152. # -- edit mode -----------------------------------------------------------------
  153.  
  154. # the following vi-copy bindings match my vim settings
  155. #   see https://github.com/gpakosz/.vim.git
  156. bind -ct vi-edit H start-of-line
  157. bind -ct vi-edit L end-of-line
  158. bind -ct vi-edit q cancel
  159. bind -ct vi-edit Escape cancel
  160.  
  161.  
  162. # -- copy mode -----------------------------------------------------------------
  163.  
  164. bind Enter copy-mode # enter copy mode
  165. bind b list-buffers  # list paster buffers
  166. bind p paste-buffer  # paste from the top pate buffer
  167. bind P choose-buffer # choose which buffer to paste from
  168.  
  169. # the following vi-copy bindings match my vim settings
  170. #   see https://github.com/gpakosz/.vim.git
  171. bind -t vi-copy v begin-selection
  172. bind -t vi-copy C-v rectangle-toggle
  173. bind -t vi-copy y copy-selection
  174. bind -t vi-copy Escape cancel
  175. bind -t vi-copy H start-of-line
  176. bind -t vi-copy L end-of-line
  177.  
  178. # copy to Mac OSX pasteboard
  179. if 'which -s reattach-to-user-namespace' 'bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
  180.  
  181.  
  182. # -- user defined --------------------------------------------------------------
  183.  
  184. if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local'
  185.  
  186.  
  187. # -- 8< ------------------------------------------------------------------------
  188.  
  189. run 'cut -c3- ~/.tmux.conf | sh -s apply_theme $tmux_conf_theme'
  190. run 'cut -c3- ~/.tmux.conf | sh -s apply_configurable_bindings $tmux_conf_new_windows_retain_current_path $tmux_conf_new_panes_retain_current_path'
  191. run 'for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $name; done;'
  192.  
  193.  
  194. # ►_◄
  195. #
  196. # # exit the script if any statement returns a non-true return value
  197. # set -e
  198. #
  199. # apply_theme() {
  200. #   case "$1" in
  201. #     powerline_patched_font)
  202. #       left_separator=''
  203. #       left_separator_black=''
  204. #       right_separator=''
  205. #       right_separator_black=''
  206. #       session_symbol=''
  207. #       ;;
  208. #     powerline)
  209. #       left_separator='|'
  210. #       left_separator_black=' '
  211. #       right_separator='|'
  212. #       right_separator_black=' '
  213. #       ;;
  214. #   esac
  215. #
  216. #   case "$1" in
  217. #     powerline*)
  218. #
  219. #       # panes
  220. #       pane_border_fg=colour238        # light gray
  221. #       pane_active_border_fg=colour39  # light blue
  222. #
  223. #       tmux set -g pane-border-style fg=$pane_border_fg \; set -g pane-active-border-style fg=$pane_active_border_fg
  224. #       #uncomment for fat borders
  225. #       #tmux set -ga pane-border-style bg=$pane_border_fg \; set -ga pane-active-border-style bg=$pane_active_border_fg
  226. #
  227. #       display_panes_active_colour=colour39 # light blue
  228. #       display_panes_colour=colour39        # light blue
  229. #       tmux set -g display-panes-active-colour $display_panes_active_colour \; set -g display-panes-colour $display_panes_colour
  230. #
  231. #       # messages
  232. #       message_fg=colour16           # black
  233. #       message_bg=colour226          # yellow
  234. #       message_attr=bold
  235. #       tmux set -g message-style fg=$message_fg,bg=$message_bg,$message_attr
  236. #
  237. #       message_command_fg=colour16   # black
  238. #       message_command_bg=colour160  # light yellow
  239. #       tmux set -g message-command-style fg=$message_command_fg,bg=$message_command_bg,$message_attr
  240. #
  241. #       # windows mode
  242. #       mode_fg=colour16   # black
  243. #       mode_bg=colour226  # yellow
  244. #       mode_attr=bold
  245. #       tmux setw -g mode-style fg=$mode_fg,bg=$mode_bg,$mode_attr
  246. #
  247. #       # status line
  248. #       status_fg=colour253 # white
  249. #       status_bg=colour232 # dark gray
  250. #       tmux set -g status-style fg=$status_fg,bg=$status_bg
  251. #
  252. #       session_fg=colour16  # black
  253. #       session_bg=colour226 # yellow
  254. #       status_left="#[fg=$session_fg,bg=$session_bg,bold] ❐ #S #[fg=$session_bg,bg=$status_bg,nobold]$left_separator_black"
  255. #       tmux set -g status-left-length 32 \; set -g status-left "$status_left"
  256. #
  257. #       window_status_fg=colour245 # light gray
  258. #       window_status_bg=colour232 # dark gray
  259. #       window_status_format="#I #W"
  260. #       tmux setw -g window-status-style fg=$window_status_fg,bg=$window_status_bg \; setw -g window-status-format "$window_status_format"
  261. #
  262. #       window_status_current_fg=colour16 # black
  263. #       window_status_current_bg=colour39 # light blue
  264. #       window_status_current_format="#[fg=$window_status_bg,bg=$window_status_current_bg]$left_separator_black#[fg=$window_status_current_fg,bg=$window_status_current_bg,bold] #I $left_separator #W #[fg=$window_status_current_bg,bg=$status_bg,nobold]$left_separator_black"
  265. #       tmux setw -g window-status-current-format "$window_status_current_format"
  266. #       tmux set -g status-justify left
  267. #
  268. #       window_status_activity_fg=default
  269. #       window_status_activity_bg=default
  270. #       window_status_activity_attr=underscore
  271. #       tmux setw -g window-status-activity-style fg=$window_status_activity_fg,bg=$window_status_activity_bg,$window_status_activity_attr
  272. #
  273. #       window_status_bell_fg=colour226 # yellow
  274. #       window_status_bell_bg=default
  275. #       window_status_bell_attr=blink,bold
  276. #       tmux setw -g window-status-bell-style fg=$window_status_bell_fg,bg=$window_status_bell_bg,$window_status_bell_attr
  277. #
  278. #       window_status_last_fg=colour39 # light blue
  279. #       window_status_last_attr=default
  280. #       tmux setw -g window-status-last-style $window_status_last_attr,fg=$window_status_last_fg
  281. #
  282. #       time_date_fg=colour245  # light gray
  283. #       time_date_bg=colour232  # dark gray
  284. #       whoami_fg=colour254     # white
  285. #       whoami_bg=colour160     # red
  286. #       host_fg=colour16        # black
  287. #       host_bg=colour254       # white
  288. #       status_right="${tmux_conf_battery:-#(cut -c3- ~/.tmux.conf | sh -s battery ${tmux_conf_battery_symbol:-block} ${tmux_conf_battery_symbol_count:-auto})} #[fg=$time_date_fg,nobold]$right_separator %R $right_separator %d %b #[fg=$whoami_bg,bg=$time_date_bg,nobold]$right_separator_black#[fg=$whoami_fg,bg=$whoami_bg,nobold] #(whoami) $right_separator_black#[fg=$host_fg,bg=$host_bg,bold] #h "
  289. #       tmux set -g status-right-length 64 \; set -g status-right "$status_right"
  290. #
  291. #       # clock
  292. #       clock_mode_colour=colour39  # light blue
  293. #       tmux setw -g clock-mode-colour $clock_mode_colour
  294. #       ;;
  295. #   esac
  296. # }
  297. #
  298. # circled_digit() {
  299. #   circled_digits='⓪①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳'
  300. #   if [ $1 -lt 20 ] 2>/dev/null ; then
  301. #     echo ${circled_digits:$1:1}
  302. #   else
  303. #     echo $1
  304. #   fi
  305. # }
  306. #
  307. # maximize_pane() {
  308. #   tmux -q -L swap-pane-test -f /dev/null new-session -d \; new-window \; new-window \; swap-pane -t :1 \; kill-session || { tmux display 'your tmux version has a buggy swap-pane command - see ticket #108, fixed in upstream commit 78e783e'; exit; }
  309. #   __current_pane=$(tmux display -p '#{pane_id}')
  310. #
  311. #   __dead_panes=$(tmux list-panes -s -F '#{pane_dead} #{pane_id} #{pane_title}' | grep -o '^1 %.\+%.\+$' || true)
  312. #   __restore=$(echo "${__dead_panes}" | sed -n -E -e "s/^1 ${__current_pane} \[\+\](%[0-9]+)$/tmux swap-pane -s \1 -t ${__current_pane} \; kill-pane -t ${__current_pane}/p" -e "s/^1 (%[0-9]+) \[\+\]${__current_pane}$/tmux swap-pane -s \1 -t ${__current_pane} \; kill-pane -t \1/p" )
  313. #
  314. #   if [ x"${__restore}" = x ] ; then
  315. #     [ x"$(tmux list-panes | wc -l | sed 's/^ *//g')" = x1 ] && tmux display "Can't maximize with only one pane" && return
  316. #     __window=$(tmux new-window -P "exec maximized+ 2> /dev/null | tmux setw remain-on-exit on && printf '\033]2;%s\033\\' [+]${__current_pane}")
  317. #     __window=${__window%.*}
  318. #
  319. #     __guard=100
  320. #     while ( [ x"$(tmux list-panes -t ${__window} -F '#{session_name}:#{window_index} #{pane_dead}')" != x"${__window} "1 ] && [ x"${__guard}" != x0 ] ) ; do sleep 0.01 ; _guard=$((__guard - 1)) ; done
  321. #     if [ x"${__guard}" = 0 ] ; then
  322. #       exit 1
  323. #     fi
  324. #
  325. #     __new_pane=$(tmux display -p '#{pane_id}')
  326. #     tmux setw remain-on-exit off \; swap-pane -s "${__current_pane}" -t "${__new_pane}"
  327. #   else
  328. #     ${__restore} || tmux kill-pane
  329. #   fi
  330. # }
  331. #
  332. # toggle_mouse() {
  333. #   old=$(tmux show -g -w | grep mode-mouse | cut -d' ' -f2)
  334. #   new=""
  335. #
  336. #   if [ "$old" = "on" ] ; then
  337. #     new="off"
  338. #   else
  339. #     new="on"
  340. #   fi
  341. #
  342. #   tmux set -g mode-mouse $new \;\
  343. #        set -g mouse-resize-pane $new \;\
  344. #        set -g mouse-select-pane $new \;\
  345. #        set -g mouse-select-window $new \;\
  346. #        display "mouse: $new"
  347. # }
  348. #
  349. # battery() {
  350. #   battery_symbol=$1
  351. #   battery_symbol_count=$2
  352. #   if [ $battery_symbol_count = auto ]; then
  353. #     columns=$(tmux display -p '#{client_width}' || echo 80)
  354. #     if [ $columns -ge 80 ]; then
  355. #       battery_symbol_count=10
  356. #     else
  357. #       battery_symbol_count=5
  358. #     fi
  359. #   fi
  360. #   battery_full_fg=colour160
  361. #   battery_full_bg=colour16
  362. #   battery_empty_fg=colour254
  363. #   battery_empty_bg=colour16
  364. #
  365. #   battery_symbol_heart_full=♥
  366. #   battery_symbol_heart_empty=♥
  367. #   battery_symbol_block_full=◼
  368. #   battery_symbol_block_empty=◻
  369. #   eval battery_symbol_full='$battery_symbol_'"$battery_symbol"'_full'
  370. #   eval battery_symbol_empty='$battery_symbol_'"$battery_symbol"'_empty'
  371. #
  372. #   uname_s=$(uname -s)
  373. #   if [ $uname_s = Darwin ]; then
  374. #     batt=$(pmset -g batt)
  375. #     percentage=$(echo $batt |egrep -o [0-9]+%) || return
  376. #     charge="${percentage%%%} / 100"
  377. #   elif [ $uname_s = Linux ]; then
  378. #     batpath=/sys/class/power_supply/BAT0
  379. #     if [ ! -d $batpath ]; then
  380. #       batpath=/sys/class/power_supply/BAT1
  381. #     fi
  382. #     batfull=$batpath/energy_full
  383. #     batnow=$batpath/energy_now
  384. #     if [ ! -r $batfull -o ! -r $batnow ]; then
  385. #       return
  386. #     fi
  387. #     charge="$(cat $batnow) / $(cat $batfull)" || return
  388. #   fi
  389. #
  390. #   full=$(printf %.0f $(echo "$charge * $battery_symbol_count" | bc -l))
  391. #   [ $full -gt 0 ] && \
  392. #     printf '#[fg=%s,bg=%s]' $battery_full_fg $battery_full_bg && \
  393. #     printf "%0.s$battery_symbol_full" $(seq 1 $full)
  394. #   empty=$(($battery_symbol_count - $full))
  395. #   [ $empty -gt 0 ] && \
  396. #     printf '#[fg=%s,bg=%s]' $battery_empty_fg $battery_empty_bg && \
  397. #     printf "%0.s$battery_symbol_empty" $(seq 1 $empty)
  398. # }
  399. #
  400. # apply_configurable_bindings() {
  401. #   windows_retain_current_path=${1:-false}
  402. #   if [ x"$windows_retain_current_path" = x"true" -o x"$windows_retain_current_path" = x"1" ] ; then
  403. #     tmux bind c new-window -c '#{pane_current_path}'
  404. #   else
  405. #     tmux bind c new-window
  406. #   fi
  407. #
  408. #   panes_retain_current_path=${2:-true}
  409. #   if [ x"$panes_retain_current_path" = x"true" -o x"$panes_retain_current_path" = x"1" ] ; then
  410. #     tmux  bind h split-window -h -c "#{pane_current_path}"  \;\
  411. #           bind _ split-window -h -c "#{pane_current_path}"    \;\
  412. #           bind v split-window -v -c "#{pane_current_path}"    \;\
  413. #           bind - split-window -v -c "#{pane_current_path}"
  414. #   else
  415. #     tmux  bind h split-window -h  \;\
  416. #           bind _ split-window -h    \;\
  417. #           bind v split-window -v    \;\
  418. #           bind - split-window -v
  419. #   fi
  420. # }
  421. #
  422. # $@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement