Add a few test configs thanks to various people.

This commit is contained in:
Nicholas Marriott 2019-05-21 08:01:57 +01:00
parent 98ee93bde3
commit afe231c94c
6 changed files with 1249 additions and 0 deletions

View File

@ -0,0 +1,30 @@
###
if-shell " \
tmux -V \
| awk '{print $2}' \
| awk -F - '{print $1}' \
| awk '{ \
if ($1 ~ /^[[:digit:].]+$/) { \
exit !($1 >= 2.6) \
} else { \
exit !($1 == \"master\" || $1 == \"next\") \
} \
}'" \
"source-file ~/.tmux/v2rc" \
"source-file ~/.tmux/v1rc" \
;
###
set-option -qg status-left \
"[#[fg=yellow]#{session_name}#[default]] #[fg=colour060]#{host_short}#[default]:#[fg=colour151]#{b:pane_current_path} #[fg=colour099]#(git -C #{pane_current_path} symbolic-ref --short HEAD) #[fg=green]#(git -C #{pane_current_path} status --porcelain --untracked-files=no | cut -b 1-1 | sort | uniq | awk '/^[^[:space:]]/ {printf\(\"%%s\", $0\)}')#[fg=red]#(git -C #{pane_current_path} status --porcelain --untracked-files=no | cut -b 2-2 | sort | uniq | awk '/^[^[:space:]]/ {printf\(\"%%s\", $0\)}')#[fg=colour113]#(git -C #{pane_current_path} stash list 2>/dev/null | wc -l | tr -d '\n' | sed s,^0\$,,) #[default]"
set-option -qg status-right \
"#[default] ┊ #[fg=colour065]#(grep ^MemFree /proc/meminfo | awk '{print rshift\($2, 10\)}')#[fg=colour071]m #[default]┊ #[fg=colour101]#(echo \"\(`awk '{print \$1}' /proc/loadavg` / `grep ^processor /proc/cpuinfo | wc -l`\) \* 100\" | bc -ql | sed 's,\\..*,,' | awk '{printf\(\"%%2u\", $0\)}')#[fg=colour102]%% "
set-option -qwg window-status-current-format \
"#[fg=colour208]»#[fg=colour190]#{window_name}#[fg=colour037]·#{?window_flags,#[fg=colour058]#{window_flags}#[default], #[default]}"
set-option -qwg window-status-format \
"#[default]»#[fg=colour066]#{window_name}#[fg=colour037]·#{?window_flags,#[fg=colour058]#{window_flags}#[default], #[default]}"

View File

@ -0,0 +1,80 @@
set -g default-command "if [ \"$(uname)\" = 'Darwin' ]; then exec reattach-to-user-namespace $SHELL; else exec $SHELL; fi"
set -g history-limit 32000
set -g update-environment "DISPLAY WINDOWID SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION SSH_CLIENT SSH_TTY KRB5CCNAME Apple_PubSub_Socket_Render Apple_Ubiquity_Message"
# Reset SHLVL (otherwise it is 2 inside tmux)
setenv -g SHLVL 0
# Send esc faster so that neovim won't get so laggy
# https://github.com/neovim/neovim/issues/2093
set -g escape-time 100
# Disable paste detection
set -g assume-paste-time 0
# Titles and window names
set -g set-titles on
set -g set-titles-string "#T"
# Make it not so annoying/sticky to switch windows
set -g repeat-time 170
# Don't deattach me when a session ends
set -g detach-on-destroy off
# Make shift+keys work
setw -g xterm-keys on
# Prefix
set -g prefix ^A
unbind ^B
bind ^A send-prefix
bind a send-prefix
# Last window
bind ^a last
# Next & prev
bind ' ' next
bind '^ ' next
bind ^p prev
# Status
set -g status off
# Need more (cow)bells!
set -g bell-action any
set -g bell-on-alert on
# Detach
bind ^d detach
# Control the a tmux in a tmux
bind A send-prefix \; send-prefix
bind C send-prefix \; send-keys c
bind n send-prefix \; send-keys ' '
bind bspace send-prefix \; send-keys p
bind '#' send-prefix \; send-keys '"'
# Other key bindings.
bind ^r command-prompt "find-window '%%'"
bind '"' choose-tree -w
bind w split-window
bind W split-window -c "#{pane_current_path}"
bind ^w split-window
bind I list-windows
bind i list-windows
bind D neww 'if who | grep -q "$USER.* via mosh"; then tmux lsc -F "#{client_activity} #{client_tty}" | sort | head -n -1 | awk "{print \$2}" | xargs -n1 tmux detach -t; else for i in $(tmux lsc | cut -d: -f1 | grep -v "^$SSH_TTY$"); do tmux detach -t $i; done; fi'
bind S neww -t 999 'window=`tmux display -p "#{pane_title}"`; i=0; tmux list-windows | cut -d: -f1 | while read j; do if [ $j != $i ]; then tmux move-window -s $j -t $i; fi; i=$(($i+1)); done' # ; tmux find-window -T "$window"
bind ^s command-prompt "rename-session '%%'"
# Make the default HOME always ~
bind c neww -c ~
bind ^c new -c ~
bind escape copy-mode
# Copy to the OS clipboard
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "if [ \"$(uname)\" = 'Darwin' ]; then reattach-to-user-namespace pbcopy; else xclip; fi"
bind j command-prompt "join-pane -s '%%'"
bind ! break-pane -d
bind - command-prompt "move-pane -t '%%'"
# Makes `tmux a` work even when there isn't a session going on
new-session -A -c ~

View File

@ -0,0 +1,580 @@
# Time-stamp: <2018-05-31 17:10:05 kmodi>
# https://github.com/tmux/tmux
# Hi-lock: (("\\(^\\s< \\**\\)\\(\\* *.*\\)" (1 'org-hide prepend) (2 '(:inherit org-level-1 :height 1.3 :weight bold :overline t :underline t) prepend)))
# Hi-Lock: end
# Running tmux built from master branch on tcsh in uxterm
# tmux version 2.5-RC+ dev
# Contents:
#
# PREFIX
# Source config
# Pane Management
# Window <-join/split-> Pane
# Select Panes
# Resize Panes
# Dynamic Split
# Window Management
# Window Navigation
# Swap Windows
# Split Window
# Layout
# Session Management
# Mouse
# Drag pane border to resize
# Left click on pane
# Middle click on pane
# Right click on pane
# Wheel scroll in pane
# Wheel scroll in pane WHILE in copy-mode
# Left click on status
# Middle click on status
# Other mouse settings
# Window Title
# Status Bar
# Left Status
# Right Status
# Pane Status
# Colors
# Status Bar Colors
# Message Colors
# Window Status Colors
# Pane Colors
# Mode Info Colors
# Activity
# Command Prompt
# Audible and Visual Bells
# Copy & Paste
# Synchronize commands to panes/windows/sessions
# Terminal Setting
# Other Options
# Server Options
# Session Options
# Window Options
# Notes
# * PREFIX
set -g prefix C-z
unbind C-b # unbind the default binding to send prefix key to the application
# Often you'll run a tmux inside another tmux and need a command sequence to
# send things to the inner session. With below binding that can be accomplished
# using "PREFIX Z <command>"
bind Z send-prefix
# * Source config
unbind r # unbind default binding to force redraw of attached client
bind r source-file ~/.tmux.conf \; display "Finished sourcing ~/.tmux.conf ."
# * Pane Management
set -g pane-base-index 1 # start pane indices at 1
set -g main-pane-width 100 # used by selectl main-vertical
bind z resize-pane -Z # zoom/unzoom the current pane
# If the window has >1 panes kill them without confirming. But confirm before kill
# the last pane (along with its window) in a window
bind x if "tmux display -p \"#{window_panes}\" | grep ^1\$" \
"confirm-before -p \"Kill the only pane in window? It will kill this window too! (y/n)\" kill-pane" \
"kill-pane"
bind C clear-history \; display "Cleared history of the current pane."
unbind C-p
bind C-p run -b "tmux display -p -F '#{pane_current_path}' | xclip -i -sel pri" \; display "Copied current path '#{pane_current_path}' to the primary selection."
# Hooks need tmux 2.3+
# set-hook -g -u after-kill-pane # Remove after hook for kill-pane
set-hook -g after-kill-pane "selectl main-vertical"
# If -g options is used when setting the hook, it has to be used when
# removing (-u option) the hook too.
# ** Window <-join/split-> Pane
# Join a pane *from* a different window (of same or different session) into the CURRENT window
# Binding mnemonic: F for (F)etch/pull (as in git) from a different window
bind F command-prompt -p "Join pane from [sess:]win#[.pane#] (ex: kmodi:3.1) into current window:" "join-pane -s '%%'"
# Join CURRENT pane *to* a different window
# Binding mnemonic: P for (P)ush (as in git) to a different window
bind P command-prompt -p "Send CURRENT pane to [sess:]win# (ex: kmodi:3):" "join-pane -t '%%'"
# PREFIX ! : break-pane, convert the current pane to a window
# ** Select Panes
bind o select-pane -t :.+ # cycle to the next pane number
bind O select-pane -t :.- # cycle to the previous pane number
# PREFIX ; : last-pane or select-pane -l, switch to the last active pane
# PREFIX ← : select-pane -L, switch to the pane on the left
# PREFIX → : select-pane -R, switch to the pane on the right
# PREFIX ↑ : select-pane -U, switch to the pane on the top
# PREFIX ↓ : select-pane -D, switch to the pane on the bottom
# PREFIX { : swap-pane -U, swap current pane with the pane above (not literally above)
# PREFIX } : swap-pane -D, swap current pane with the pane below (not literally below)
# ** Resize Panes
bind -r h resize-pane -L 2
bind -r C-h resize-pane -L 2
bind -r j resize-pane -D 2
bind -r C-j resize-pane -D 2
bind -r k resize-pane -U 2
bind -r C-k resize-pane -U 2
unbind l # unbind default binding for `last-window`
bind -r l resize-pane -R 2
bind -r C-l resize-pane -R 2
# ** Dynamic Split
# Key-chaining example, analogous to prefix maps in emacs
bind / switch-client -Tlauncher
# Run below -Tlauncher commands using "PREFIX / <binding>"
# Open calendar in a split window "PREFIX / c"
# FIXME: Below does not work; cal pane quits as soon as it launches (before "&& sleep .."
# was added). To make better of the situation, I now auto-close that pane after 3 seconds.
# bind -Tlauncher c split-window -h 'cal && sleep 3'
bind -Tlauncher c run "/home/kmodi/scripts/tcsh/tmux/dynamic_split.csh 'cal && sleep 3'"
# Start emacsclient in terminal mode in a split window "PREFIX / e"
# Use the emacs binding "C-x 5 0" to quit from that pane gracefully.
bind -Tlauncher e run "/home/kmodi/scripts/tcsh/tmux/dynamic_split.csh 'emacsclient -a \"\" -t'"
# Open man page "PREFIX / m"
# PREFIX / m will bring up the tmux command prompt. Enter the command for which
# you want to see the man page, example: ls. That man page will open in a split
# pane. When you are done reviewing the man page, hit q and the split pane
# closes by itself. Beautiful!
bind -Tlauncher m command-prompt -p "man" "run \"/home/kmodi/scripts/tcsh/tmux/dynamic_split.csh 'man %1'\""
# Open python interpreter in a split window for quick calculations "PREFIX / p"
# Ctrl-D in python quits python and thus closes the split window too.
bind -Tlauncher p run "/home/kmodi/scripts/tcsh/tmux/dynamic_split.csh 'ipython --profile=default --no-confirm-exit'"
# PREFIX Up, Down, Right, Left : Move cursor from one pane to another
# PREFIX Space : Cycle through different pane layouts
# PREFIX C-o : rotate-window, rotate panes in the current window
# * Window Management
set -g base-index 1 # start window indices at 1
# automatically renumber the windows
# http://unix.stackexchange.com/questions/21742/renumbering-windows-in-tmux
set -g renumber-windows on
bind C-f command-prompt -p "New window:" "new-window -c '#{pane_current_path}' -n %1"
bind C-r command-prompt -p "New name for this window:" "rename-window '%%'"
unbind L # unbind default binding for `switch-client -l`
bind L list-windows -F '#{window_index}:#{window_name}: #{?pane_dead, (dead), (not dead)}'
unbind & # unbind default binding for `kill-window`
bind C-c confirm-before -p "Kill this window? (y/n)" kill-window
# Move the current window to another window index in the same or any other session
bind m command-prompt -p "Move window to sess or sess:win# or win# (ex: kmodi or kmodi:3 or 2(of current session)):" "move-window -t '%%'"
# Move or bring a window from a different session to the current one
bind M command-prompt -p "Move the window from sess:win# (ex: kmodi:3):" "move-window -s '%%'"
# ** Window Navigation
bind C-z last-window # switch to last active window
# Allow repeats for next/previous-window
bind -r p previous-window
bind -r n next-window
# switch to another window by name
bind W split-window "tmux lsw | peco --initial-index `tmux lsw | awk '/active.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux select-window -t"
# PREFIX <N> : switches to window with index=N
# ** Swap Windows
bind N move-window -r # renumber the windows
unbind , # unbind default binding for `rename-window`
bind -r , swap-window -t -1 # move window one position to the left
bind -r < swap-window -t -1 # move window one position to the left
unbind . # unbind default binding to move window to user provided index
bind -r . swap-window -t +1 # move window one position to the right
bind -r > swap-window -t +1 # move window one position to the right
unbind t # unbind default binding to show time
bind t swap-window -t 1 # swap the current window's position with window # 1, move it to the top
# ** Split Window
unbind & # unbind default binding for `split-window -h`
bind - split-window -v -c '#{pane_current_path}' # vertical split
bind _ split-window -v -c '#{pane_current_path}' -f # full vertical split (v2.3+)
bind \ split-window -h -c '#{pane_current_path}' # horizontal split
bind | split-window -h -c '#{pane_current_path}' -f # full horizontal split (v2.3+)
# https://www.reddit.com/r/tmux/comments/3paqoi/tmux_21_has_been_released/cw5wy00
bind w switch-client -Tsplit_wind
bind -Tsplit_wind v split-window -v -c '#{pane_current_path}'
bind -Tsplit_wind V split-window -v -c '#{pane_current_path}'\; swap-pane -U
bind -Tsplit_wind h split-window -h -c '#{pane_current_path}'
bind -Tsplit_wind H split-window -h -c '#{pane_current_path}'\; swap-pane -U
# ** Layout
bind Space next-layout
bind C-Space select-layout -o # undo only the last layout change #v2.1
# * Session Management
bind C-t command-prompt -p "New name for this session:" "rename-session '%%'"
bind b switch-client -l # switch to previously selected session
# switch to another session by name
bind S split-window "tmux ls | peco --initial-index `tmux ls | awk '/attached.$/ {print NR-1}'` | cut -d':' -f 1 | xargs tmux switch-client -t"
# switch to ANY window in ANY session by name
bind s split-window "tmux ls | cut -d: -f1 | xargs -I SESSION tmux lsw -F 'SESSION:#{window_name}' -t SESSION | peco --initial-index `tmux ls | cut -d: -f1 | xargs -I SESSION tmux lsw -F '___#{session_attached}#{window_active}___' -t SESSION | awk '/___11___/ {print NR-1}'` | xargs tmux switch-client -t"
# tmux kill-session -t NAME/SESSIONNUMBER # Kill session
# * Mouse
# setw -g mode-mouse on # incompatible in tmux 2.1+
set -g mouse on
# ** Drag pane border to resize
# set -g mouse-resize-pane off # incompatible in tmux 2.1+
bind -T root MouseDrag1Border resize-pane -M # default
# unbind -T root MouseDrag1Border # disable drag pane border to resize
bind -T root MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= "#{pane_in_mode}" "copy-mode -M" "send-keys -M"' 'copy-mode -M' # default
# ** Left click on pane
# set -g mouse-select-pane on # incompatible in tmux 2.1+
# Left click on a pane selects it
# bind -T root MouseDown1Pane select-pane -t=\; send-keys -M # default
bind -T root MouseDown1Pane select-pane -t=
# Sun Feb 19 11:31:34 EST 2017 - kmodi
# Below break in tmux 2.4
# # Fri Aug 26 18:35:21 EDT 2016 - kmodi
# # FIXME Need to remember why I unbound the below 2 bindings
# unbind -temacs-copy MouseDown1Pane
# unbind -temacs-copy MouseUp1Pane
# #
# https://groups.google.com/forum/#!topic/tmux-users/mHhdx7Au0Ds
# Fri Aug 26 18:30:15 EDT 2016 - kmodi
# Do not do the below!! That will update the primary selection with the top-most
# tmux buffer each time you left click on a pane.
# bind -T root MouseUp1Pane run -b "tmux show-buffer | xclip -i -sel pri"
#
# Left click in the pane *followed after a region selection* copies that to the
# secondary selection
bind -T root MouseUp1Pane run -b "tmux show-buffer | xclip -i -sel sec"
# Fri Aug 26 19:03:57 EDT 2016 - kmodi
# FIXME: As of today it needs to be figured out how to best paste the content
# from secondary selection
# ** Middle click on pane
# Middle click in a pane to paste from the primary selection
bind -T root MouseDown2Pane run -b "xclip -o -sel pri | tmux load-buffer - && tmux paste-buffer -s ' '"
# ** Right click on pane
# Right click on a pane selects and marks it *if not in copy-mode*; else
# passes on the mode keys
# bind -T root MouseDown3Pane select-pane -t= -m # default
bind -T root MouseDown3Pane if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t= -m'
# Sun Feb 19 11:32:00 EST 2017 - kmodi
# Below breaks in tmux 2.4
# # Right click *release* on a pane *in copy-mode* quits copy-mode
# bind -temacs-copy MouseUp3Pane cancel
# ** Wheel scroll in pane
unbind -T root WheelUpPane
unbind -T root WheelDownPane
# Do mouse wheel-up to enter copy mode and do page-up
# https://groups.google.com/d/msg/tmux-users/XTrSVUR15Zk/3iyJLMyQ7PwJ
# Below binding did not work
# bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'if -Ft= "#{pane_in_mode}" "copy-mode -u" "send-keys -M"' 'copy-mode -u'
# Below works and allows the WheelUpPane binding in emacs-copy table to be effective
bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= "#{pane_in_mode}" "send-keys -M" "copy-mode -u"'
# |---------------------+-----------------------------------------+--------------------------------|
# | using mouse? AND .. | #{pane_in_mode} (already in copy-mode?) | action |
# |---------------------+-----------------------------------------+--------------------------------|
# | Yes | Don't care | Send the mode keys |
# | No | Yes | Send the mode keys |
# | No | No | Enable copy-mode and do PageUp |
# |---------------------+-----------------------------------------+--------------------------------|
# *** Wheel scroll in pane WHILE in copy-mode
# Sun Feb 19 11:32:16 EST 2017 - kmodi
# Below breaks in tmux 2.4
# # Once in copy-mode, mouse wheel scrolls scrolls by half pages
# bind -temacs-copy WheelUpPane halfpage-up
# bind -temacs-copy WheelDownPane halfpage-down
# ** Left click on status
# set -g mouse-select-window on # incompatible in tmux 2.1+
# Left click on a window name in status bar to select it
bind -T root MouseDown1Status select-window -t= # default
# ** Middle click on status
# Middle click on a window name in status bar to kill it
bind -T root MouseDown2Status kill-window
# ** Other mouse settings
# The special token {mouse} or = may be used as target-window or target-pane in
# commands bound to mouse key bindings. Example: -t =
# * Window Title
set -g set-titles on
set -g set-titles-string '#h :: #S:W#I(#W).P#P'
# * Status Bar
set -g status-interval 5 # default = 15 seconds
set -g status-justify centre
# ** Left Status
set -g status-left-length 20
# Change the left status when prefix is pressed.
# https://www.reddit.com/r/tmux/comments/5cm2ca/post_you_favourite_tmux_tricks_here/d9ziuy9/
set -g status-left "#{?client_prefix,#[fg=yellow]prefix pressed ..,[#S]}"
# ** Right Status
set -g status-right-length 20
set -g status-right "%l:%M %b %d %a "
# ** Pane Status
setw -g pane-border-status "bottom"
setw -g pane-border-format " #P #T "
# # tmux-powerline
# # https://github.com/erikw/tmux-powerline
# set -g status-left-length 30
# set -g status-right-length 30
# set -g status-left "#(~/usr_local/scripts/tmux-powerline/powerline.sh left)"
# set -g status-right "#(~/usr_local/scripts/tmux-powerline/powerline.sh right)"
# * Colors
# ** Status Bar Colors
set -g status-style fg=colour246,bg=colour233 # default for whole status line
set -g status-left-style fg=white,bold,bg=colour233
set -g status-right-style fg=colour75,none,bg=colour233
# ** Message Colors
set -g message-style fg=colour2,bold,bg=default
# ** Window Status Colors
setw -g window-status-style default # default for all window statuses
setw -g window-status-last-style fg=default,bg=colour235
setw -g window-status-current-style fg=white,bold,bg=colour63
setw -g window-status-bell-style default
setw -g window-status-activity-style fg=white,none,bg=colour196
# setw -g window-status-content-style fg=black,none,bg=green # incompatible with tmux 2.0+
# ** Pane Colors
setw -g pane-active-border-style fg=colour63,bg=default
setw -g pane-border-style fg=colour235,bg=default
setw -g window-active-style 'bg=#330000' # bg color of active pane
setw -g window-style 'bg=black' # bg color of inactive pane(s)
# ** Mode Info Colors
# Color of display shown on top-right in copy-mode, highlighting
setw -g mode-style fg=black,bg=colour244
# * Activity
# Notify when a window has activity
# This quick snippet will have tmux notify you in the status area when a
# window has activity:
setw -g monitor-activity on
set -g visual-activity off # Display message telling that an activity happened (on/off)
# It lets me know that there is activity in a non-active window
# To try this, enter `sleep 10 && echo “Hi”` in a window and switch to
# another window.
# # Notify when a window has a content alert
# setw -g monitor-content "--[A-Za-z][A-Za-z]sim Done--" # This string appears when a sim finishes, alert then # incompatible with tmux 2.0+
# # setw -g monitor-content "" # Disable monitor-content
# set -g visual-content on # Display message telling that a content alert was triggered (on/off) # incompatible with tmux 2.0+
# * Command Prompt
# Move focus to command prompt. tmux commands can be entered there directly
# without using the `tmux` prefix and it also supports auto-complete.
bind C-x command-prompt # default command-prompt binding "PREFIX :" also works
# * Audible and Visual Bells
set -g bell-action any
set -g bell-on-alert off
set -g visual-bell on
# * Copy & Paste
set -g set-clipboard off # default is on
# Copy tmux buffer to primary and clipboard selections
# run -b runs a shell command in background
# http://grota.github.io/blog/2012/05/08/tmux-clipboard-integration/
bind C-w run -b "tmux show-buffer | xclip -i -sel pri && tmux show-buffer | xclip -i -sel cli"
# Fri Aug 26 18:41:30 EDT 2016 - kmodi
# Below binding was suggested by Nicholas Marriott
# But the my older binding works fine so I am commenting out below for now.
# bind C-w run "tmux saveb - | xclip -i -sel pri; tmux saveb - | xclip -i -sel cli"
# Paste into tmux; also replace LF characters with
# space as separator characters (-s) when pasting.
# Yank from primary
bind C-y run -b "xclip -o -sel pri | tmux load-buffer - && tmux paste-buffer -s ' '"
# Yank from clipboard
bind M-y run -b "xclip -o -sel cli | tmux load-buffer - && tmux paste-buffer -s ' '"
# Open the file/dir path that was copied by selection in existing emacs client
# Usage: Highlight a file name in ls output and press "PREFIX e"
bind e run -b "tmux show-buffer | xclip -i -sel pri; (emacsclient -a '' `tmux display -p '#{pane_current_path}'`/`xclip -o -sel pri `&)"
# * Synchronize commands to panes/windows/sessions
# Send the same command to all panes in the same window
bind C-a command-prompt -p "Command to all panes in this window:" \
"run \"tmux list-panes -F '##{pane_index}' | xargs -I PANE \
tmux send-keys -t PANE '%1' Enter\""
# Alternative to using the above "C-a" binding is to enable pane synchronization,
# type the command you want to execute in all panes in the same window and disable
# pane synchronization
# Also turn the pane borders red while pane synchronization is enabled.
# - https://www.reddit.com/r/tmux/comments/5cm2ca/post_you_favourite_tmux_tricks_here/d9y6jzu/
bind C-s if -F '#{pane_synchronized}' \
'setw synchronize-panes off; \
setw pane-active-border-style fg=colour63,bg=default; \
setw pane-border-format " #P #T "' \
'setw synchronize-panes on; \
setw pane-active-border-style fg=red; \
setw pane-border-format " #P - Pane Synchronization ON "'
# So it would be: C-s <type the command RET> C-s
# https://scripter.co/command-to-every-pane-window-session-in-tmux/
# Send the same command to all panes/windows in the current session
bind C-e command-prompt -p "Command:" \
"run \"tmux list-panes -s -F '##{session_name}:##{window_index}.##{pane_index}' \
| xargs -I PANE tmux send-keys -t PANE '%1' Enter\""
# Send the same command to all panes/windows/sessions
bind E command-prompt -p "Command:" \
"run \"tmux list-panes -a -F '##{session_name}:##{window_index}.##{pane_index}' \
| xargs -I PANE tmux send-keys -t PANE '%1' Enter\""
# * Terminal Setting
# From `man tmux', about `default-terminal'
# Set the default terminal for new windows created in this session - the default
# value of the TERM environment variable. For tmux to work correctly, this must
# be set to screen, tmux or a derivative of them.
# set -g default-terminal "screen"
set -g default-terminal "screen-256color"
# Mon May 22 11:43:56 EDT 2017 - kmodi
# Blinking text (useful to show broken symlinks in ls) does not work when using tmux-24bits.
# set -g default-terminal "tmux-24bits"
# tmux-24bits is a custom terminfo profile created using the steps explained
# on https://github.com/ThomasAdam/tmux/blob/master/FAQ to support italics and
# 256 colors.
# Enable 24-bit color
# https://sunaku.github.io/tmux-24bit-color.html
set -ga terminal-overrides ",screen-256color:Tc"
# set -ga terminal-overrides ",tmux-24bits:Tc"
# Thu May 31 17:10:04 EDT 2018 - kmodi
# TODO: Try the 24-bit emacs+tmux config for ST
# https://www.reddit.com/r/emacs/comments/8ndm2x/gnu_emacs_261_24bit_colors_suckless_st_terminal/dzwh4vv/
# set -g default-terminal "tmux-256color"
# set -ga terminal-overrides ",*256col*:Tc"
#
setw -g xterm-keys on
# Uncomment below when using st (by suckless.org)
# set -g default-terminal "st-256color"
# # https://sunaku.github.io/tmux-24bit-color.html
# # st supports 24-bit color, so enable support for that in tmux
# set -ga terminal-overrides ",st-256color:Tc"
# setw -g xterm-keys off
bind R refresh-client
# bind R refresh-client \; display "Refreshed the client."
# * Other Options
# ** Server Options
set -s escape-time 0 # Allows for faster key repetition
# ** Session Options
# Set the default shell to /bin/sh. If the default is tcsh, doing a split-window takes a long
# time as my tcsh init is loaded first (which takes really long).
set -g default-shell /bin/sh
# If I am doing a new-window or split-window without a specified command, start the tcsh
# shell by default.
set -g default-command tcsh
set -g history-limit 100000
set -g display-time 1000 # Duration of tmux display messages in milliseconds
# ** Window Options
# When a smaller terminal connects to a tmux client, it shrinks to fit it. The
# clients attached with bigger displays see this constrained view.
# aggressive-resize makes it such that the window is only resized if the smaller
# client is actively looking at it.
setw -g aggressive-resize on
setw -g mode-keys emacs # Use emacs keybindings in copy mode
setw -g status-keys emacs
# * Notes
# |-------------------+------------|
# | tmux command | short form |
# |-------------------+------------|
# | set-option | set |
# | set-window-option | setw |
# | bind-key | bind |
# | unbind-key | unbind |
# | display-message | display |
# | run-shell | run |
# | if-shell | if |
# |-------------------+------------|
# Colo'u'r table
# http://guns.github.io/xterm-color-table.vim/images/xterm-color-table.png
# CHARACTER PAIR REPLACED WITH
# #(command) First line of commands output
# #[attributes] Colour or attribute change
# #H Hostname of local host
# #I Current window index
# #P Current pane index
# #S Session name
# #T Current window title
# #W Current window name
# ## A literal #
# Variables used in time format
# Source: http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Commontimeformatvariables
# %y = year in numbers (2-digit)
# %Y = year in numbers (4-digit)
# %m = month in number (eg: 12)
# %B = full month name (eg: December)sho
# %b = short month name (eg: Dec)
# %d = day in numbers, with leading zeros (eg: 08)
# %e = day in numbers, no leading zeros (eg: 8)
# %A = full weekday name (eg: Sunday)
# %a = short weekday name (eg: Sun)
# %H = hours in 24-clock, with leading zeros
# %k = hours in 24-clock, no leading zeros
# %l = hours in 12-clock, with leading zeros
# %p = am/pm
# %T = time in 24-hour notation (%H:%M:%S)
# PREFIX ? : list-keys, display key bindings
# In command-prompt: show-options -g shows the global options
# In command-prompt: show-window-options -g shows the global windows options
# How do I know which tmux version I am running?
# tmux -V
# How to set bindings that don't need the prefix?
# bind -n .. or
# bind -T root ..
# Changelog: https://github.com/tmux/tmux/blob/master/CHANGES
# style colors: default, black, red, green, yellow, blue, magenta, cyan, white,
# colour0-colour255, hexdecimal RGB string '#ffffff'
# Use $SCRIPTS/bash/256-colors.sh to figure out the color number you want
# style attributes: none, bold/bright, dim, underscore, blink, reverse, hidden,
# or italics
# https://www.reddit.com/r/tmux/comments/3paqoi/tmux_21_has_been_released/cw552qd
# tmux buffers
# PREFIX # : List all paste buffers
# PREFIX - : Delete the most recently copied buffer of text
# PREFIX = : Choose which buffer to paste interactively from a list
# PREFIX ] : Paste the most recently copied buffer of text
# How to start a temporary tmux server in addition to an existing running one?
# > tmux -L temp
# In a shell environment in a terminal in tmux, the env var $TMUX will be
# defined to something like "/tmp/tmux-23273/default,31101,0". Outside tmux,
# $TMUX will be undefined.
# Notation to address a specific pane
# SESSION_NAME:WINDOW_INDEX.PANE_NUMBER (Example: foo:2.1 i.e. Pane 1 in Window 2 of Session foo)
# To print a message containing tmux variable values to stdout use '-p' option in display-message
# tmux display-message -p '#{session_name}:#{window_name}.#{pane_index}', or
# tmux display -p '#{session_name}:#{window_name}.#{pane_index}'

View File

@ -0,0 +1,198 @@
### GENERAL
set-option -g prefix C-a # Set prefix to <C-a>
bind a send-prefix # Send <C-a> with <C-a>a
bind R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded"
bind -n M-R source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded"
set -g history-limit 10000 # lines to keep in hisoty
set-option -g display-panes-time 3000 # Timeout for pane-numbering in ms
bind -n M-q display-panes
set-option -sg escape-time 0 # speed up commands
set -g mouse on # enable mouse (tmux 2.1+)
set -g base-index 1 # start window numbering at 1
set -g pane-base-index 1 # start pane numbering at 1
set -g renumber-windows on # renumber windows automatically
setw -g automatic-rename on # rename window after process
# Clear window name before renaming
bind , rename-window "" \; command-prompt "rename-window '%%'"
#### APPEARANCE
set -g default-terminal "screen-256color" # use 256 colors
setw -g aggressive-resize on # resize window to smallest client
set -g pane-border-style fg=colour238 # border color for inactive panes
set -g pane-active-border-style fg=colour247 # border color for active panes
# Status bar colors and format
setw -g window-status-format ' #[fg=#999999]#I #[fg=$666666]#W '
setw -g window-status-current-format '#[fg=#ffffff] #I #W#[fg=#ffffff] '
setw -g window-status-separator '#[fg=#292929]|#[fg=default]'
set -g status-bg default # background color for status bar
set -g status-position bottom # put status bar on top or bottom
set -g status-interval 2 # interval in s to update status
set -g status-justify left # horizontal alignment
set -g message-style fg=white,bg=black # appearance of status messages
set -g message-command-style fg=white # appearance of status message cmds
# Left section of status bar
set -g status-left ""
# Status bar visibility
set -g status off
bind -r -n M-t set status on
bind -r -n M-T set status off
bind t set status on
bind T set status off
# Right section of status bar
if-shell 'uname | grep -qi Darwin' "set -g status-right \"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//') #[fg=cyan]#(~/bin/battery-osx) #(~/bin/mailstatus.sh) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=#666666]%F #[fg=#bababa]%R\""
if-shell 'uname | grep -qi Linux' "set -g status-right \"#[fg=cyan]#(~/bin/battery-linux) #(~/bin/mailstatus.sh) #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=#666666]%F #[fg=#bababa]%R\""
# Scaling of status-bar sections
set -g status-right-length 40
#### NAVIGATION
# With C-a prefix
bind h select-pane -L # navigate left with <C-a>h
bind j select-pane -D # navigate down with <C-a>j
bind k select-pane -U # navigate up with <C-a>k
bind l select-pane -R # navigate right with <C-a>l
bind -r H resize-pane -L 5 # resize pane left with <C-a>H
bind -r J resize-pane -D 5 # resize pane down with <C-a>J
bind -r K resize-pane -U 5 # resize pane up with <C-a>K
bind -r L resize-pane -R 5 # resize pane right with <C-a>L
# Navigate panes with Meta (alt) modifier + hjkl
bind -r -n M-h select-pane -L # navigate left with M-h
bind -r -n M-j select-pane -D # navigate down with M-j
bind -r -n M-k select-pane -U # navigate up with M-k
bind -r -n M-l select-pane -R # navigate right with M-l
bind -r -n M-H resize-pane -L 5 # resize pane left with M-H
bind -r -n M-J resize-pane -D 5 # resize pane down with M-J
bind -r -n M-K resize-pane -U 5 # resize pane up with M-K
bind -r -n M-L resize-pane -R 5 # resize pane right with M-L
# Navigate windows with Meta (alt) modifier + number keys
bind -n M-1 select-window -t :=1
bind -n M-2 select-window -t :=2
bind -n M-3 select-window -t :=3
bind -n M-4 select-window -t :=4
bind -n M-5 select-window -t :=5
bind -n M-6 select-window -t :=6
bind -n M-7 select-window -t :=7
bind -n M-8 select-window -t :=8
bind -n M-9 select-window -t :=9
bind -n M-0 select-window -t :=10
bind C-s last-window # go to last window with <C-a><C-s>
bind C-a last-pane # go to last pane with <C-a><C-a>
bind -n M-s last-window # go to last pane with M-s
bind -n M-a last-pane # go to last pane with M-a
bind -r n next-window # next window with <C-a>n
bind -r b previous-window # next window with <C-a>p
bind -n -r M-n next-window # next window with <M-n>
bind -n -r M-b previous-window # previous window with <M-n>
#bind -n M-, run-shell "tmux list-panes -as -F \"##I.##P ##{pane_current_command} . #{pane_current_path} (#W)#F\" | fzf-tmux | cut -d \" \" -f 1 | xargs tmux select-pane -t"
bind -n M-, run-shell "tmux list-windows -F \"##I:##W\" | fzf-tmux | cut -d \":\" -f 1 | xargs tmux select-window -t"
bind -n M-. run-shell "tmux list-sessions -F \"##S\" | fzf-tmux | xargs tmux switch -t"
#### LAYOUT CHANGING BINDINGS
# create panes in same directory
bind '"' split-window -c "#{pane_current_path}"
bind '%' split-window -h -c "#{pane_current_path}"
bind -r z resize-pane -Z # toggle pane zoom with <C-a>z
bind -r y next-layout # cycle to next pane layout with <C-a>y
bind -r Y previous-layout # cycle to previous pane layout with <C-a>Y
bind -r r rotate-window # rotate panes with <C-a>r
bind -n M-z resize-pane -Z # toggle pane zoom with <M-z>
bind -n -r M-y next-layout # cycle to next pane layout with <M-y>
bind -n -r M-Y previous-layout # cycle to previous pane layout with <M-Y>
bind -n -r M-r rotate-window # rotate panes with <M-r>
bind -r Left swap-window -t -1 # Swap window left
bind -r Right swap-window -t +1 # Swap window right
bind -r B swap-window -t -1 # Swap window left
bind -r N swap-window -t +1 # Swap window right
bind -n -r M-B swap-window -t -1 # Swap window left
bind -n -r M-N swap-window -t +1 # Swap window right
#### CLIPBOARD
# enable reattach-to-user-namespace which fixes pasteboard access and launchctl
bind Space copy-mode # enter copy mode with <C-a><Space>
bind -n M-u copy-mode # enter copy mode with M-u
bind -T copy-mode-vi M-u send -X halfpage-up # scroll up with M-u
bind -T copy-mode-vi M-d send -X halfpage-down # scroll down with M-d
bind -T copy-mode-vi v send -X begin-selection # start "visual" with v
# Copy (yank) with y
if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "DISPLAY=:0 xclip -i -sel clipboard"'
if-shell 'uname | grep -qi Darwin' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"'
if-shell 'uname | grep -qi Cygwin' 'bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "cat > /dev/clipboard"'
# Paste with C-a p or M-p
if-shell 'uname | grep -qi Linux && which xclip > /dev/null' 'bind p run "DISPLAY=:0 xclip -o | tmux load-buffer - ; tmux paste-buffer"'
if-shell 'uname | grep -qi Darwin && which reattach-to-user-namespace > /dev/null' 'bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"'
if-shell 'uname | grep -qi Darwin' 'bind -n M-p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"'
if-shell 'uname | grep -qi Cygwin' 'bind p run "cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer"'
if-shell 'uname | grep -qi Cygwin' 'bind -n M-p run "cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer"'
#### LAUNCH PROCESSES
# use urlview to follow URLs in current pane
bind u capture-pane -J \; \
save-buffer "/tmp/active_tmux_buffer" \; \
delete-buffer \; \
split-window -l 10 "urlview '/tmp/active_tmux_buffer' && rm /tmp/active_tmux_buffer"
# Launch offlineimap in inactive splits
bind o split-window -p 25 '$SHELL -c "offlineimap -qf INBOX"' \; select-pane -l
bind O split-window -p 25 '$SHELL -c "offlineimap"' \; select-pane -l
# Use nested bindings (<C-a>l) for grouping process launch bindings
bind -n C-M-v new-window -n vim "/usr/local/bin/vim"
bind -n C-M-w new-window -n weather \
"curl 'wttr.in/?m'; echo -e '\nPress <enter> to quit'; read -n 1 -s"
# Open new window and resize status accordingly (should be a hook instead)
bind Enter new-window -c "#{pane_current_path}" "$SHELL"
bind -n M-Enter new-window \
"tmux set status-right-length `echo $(tput cols)/2|bc|tr -d '\n'`; zsh"
# Use nested bindings (<C-a>m) for grouping music-control bindings
bind m switchc -Tmpd
bind -n M-m switchc -Tmpd
bind -Tmpd v new-window -n vimpc "vimpc"
bind -Tmpd p display "#(mpc toggle | tr '\n' ' ')"
bind -Tmpd s display "#(mpc stop | tr '\n' ' ')"
bind -Tmpd n display "#(mpc next | tr '\n' ' ')"
bind -Tmpd b display "#(mpc prev | tr '\n' ' ')"
bind -Tmpd r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')"
#bind -Tmpd r new-window -n mpc "mpc clear && mpc ls | mpc add && mpc shuffle && mpc play"
bind -n C-M-p display "#(mpc toggle | tr '\n' ' ')"
bind -n C-M-s display "#(mpc stop | tr '\n' ' ')"
bind -n C-M-n display "#(mpc next | tr '\n' ' ')"
bind -n C-M-b display "#(mpc prev | tr '\n' ' ')"
#bind -n C-M-r display "#(mpc clear && mpc ls | mpc add && mpc random on && mpc play | tr '\n' ' ')"
bind -n C-M-a split-window -p 50 "source ~/code/fzf-mpd/fzf-mpd.zsh && fm"
# fzf-locate from entire file system and insert result in current pane (Alt-`)
bind -n 'M-`' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate / | fzf -m | paste -sd\\ -)\"'"
# Change to the previous pane, repeat the last command, change back
bind -n M-! last-pane \; send-keys C-p C-m \; last-pane

View File

@ -0,0 +1,78 @@
# Scott Rochford's tmux configuration
#
# change the prefix to the GNU screen default (avoids clash with page up in vi)
set -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
# toggle sending input to all panes
bind-key b set-window-option synchronize-panes
# alternative to ',' which doesn't pre-fill the prompt with the existing name
bind-key < command-prompt "rename-window '%%'"
# Disabled all of these in favour of changing 'default-command' below.
#bind-key C-p pipe-pane -o 'cat >>~/tmux_logs/output.$(echo #I-#P-#W-#T | sed "s/[^[:alnum:].-]/_/g")' \; display-message 'Toggled logging'
# From http://unix.stackexchange.com/questions/5832/is-there-an-equivalent-of-gnu-screens-log-command-in-tmux
# bind-key H pipe-pane -o "exec cat >>$HOME/'#W-tmux.log'" \; display-message 'Toggled logging to $HOME/#W-tmux.log'
#bind-key H pipe-pane "exec cat >>$HOME/'#W-tmux.log'" \; display-message 'Started logging to $HOME/#W-tmux.log'
#bind-key h pipe-pane \; display-message 'Ended logging to $HOME/#W-tmux.log'
#set -g utf8 on
set-option -g history-limit 32768
# no longer available in 2.2
#set-option -g mouse-select-pane on
#set-option -g mouse-select-window on
set-option -g mouse on
# increase the amount of time status bar messages are displayed for (default 1000 I think)
set-option -g display-time 1500
# unfortunately this seems to have no effect in putty :-(
set-option -g set-clipboard on
set-option -g default-command 'tmux pipe-pane -o "cat >>~/tmux_logs/output-`date +%Y%m%d-%H%M%S-$$`" ; /bin/ksh -l'
#
# allow yank into system clipboard
# from http://stackoverflow.com/questions/17255031/how-to-copy-from-tmux-running-in-putty-to-windows-clipbard
#
# for some reason this is wrapping at 80 cols, using save- instead of show- helps
# -b for background is needed because xclip continues to run to service the clipboard paste reqeusts until the
# clipboard buffer is replaced with some new contents
#bind C-y run-shell -b "tmux save-buffer - | DISPLAY=$(<~/.xdisplay) xclip -selection clipboard -in && tmux display-message 'xclipped successfully'"
bind C-y save-buffer ~/etc/clipboard.pipe
#
# this was just for testing, but interestingly for some reason tmux-show-buffer >/tmp/t never terminates, writing to a pipe works fine??
#bind C-z run-shell "tmux show-buffer | cat >/tmp/t"
# move x clipboard into tmux paste buffer
#bind C-p run-shell -b "xclip -o -selection clipboard | tmux load-buffer - ; tmux paste-buffer"
bind C-p run-shell "DISPLAY=$(<~/.xdisplay) xclip -o -selection clipboard | tmux load-buffer - ; tmux paste-buffer"
# switch to last-but-one window (like prefix-l but last, last)
# only works on tmux-2.4 + with Nicholas Marriott's patch from my feature request, unless it reached mainline....
#bind k run-shell "tmux select-window -t $(tmux list-windows -F '#{session_stack}' | awk -F, '{print $3;exit}END{print $1}')"
bind k run-shell "tmux select-window -t $(echo #{session_stack} | awk -F, '{w=$1}NF>=3{w=$3;exit}END{print w}')"
# switch to oldest window (for clean-up), not sure why brackets are required around (NF) here...
bind K run-shell "tmux select-window -t $(echo #{session_stack} | awk -F, '{print $(NF)}')"
# prompt for hosts to connect to, open a new synchronized window with horizontally split panes for each host, supports brace expansion
bind N command-prompt -p hosts: 'run-shell -b "bash -c \"~/lbin/nw %% >/dev/null\""'
# seems to cause unexpected resizes when focussing on putty :-(
#set-option mouse-resize-pane on
#05:59 < Celti> annihilannic: I believe the #{pane_in_mode} format does what you want
#05:59 < Celti> put it in your statusline
#05:59 < Celti> annihilannic: No, my mistake, I should have read farther down, you want #{pane_synchronized}
# only works in tmux 2.0?, higher than 1.6.3 anyawy
set-option -g window-status-format ' #I:#W#F#{?pane_synchronized,S,}'
#set-option -g window-status-current-format ' #I:#W#{?pane_synchronized,[sync],}#F'
# to highlight in red when sync is on... not sure why I did this with set-window-option instead of set-option, perhaps
# both work?
set-window-option -g window-status-current-format "#{?pane_synchronized,#[bg=red],}#{?window_zoomed_flag,#[bg=yellow],} #I:#W#F#{?pane_synchronized,S,}"
#
# also only in 2.0? if I use this, don't need #F in window-status-*-format? - actually, nah,
# still useful for showing [Z]oomed, or - last active, etc.
set-option -g window-status-current-style bg=blue
# Toggle input on a pane (from Thomas Sattler)
bind-key R if -F '#{pane_input_off}' "select-pane -e; select-pane -P fg=default" "select-pane -d; select-pane -P fg=yellow"

View File

@ -0,0 +1,283 @@
#---------------------------------------------------------------------------#
# .tmux.conf
# Helmut K. C. Tessarek, Last update 2018-10-16
#---------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
# set prefix key to ctrl+a / ctrl-b is used in vi for going back one page
#---------------------------------------------------------------------------#
unbind C-b
set -g prefix C-a
#---------------------------------------------------------------------------#
# send the prefix to client inside window (nested sessions)
#---------------------------------------------------------------------------#
bind-key a send-prefix
#---------------------------------------------------------------------------#
# toggle last window like screen
#---------------------------------------------------------------------------#
bind-key C-a last-window
#---------------------------------------------------------------------------#
# start window indexing at one instead of zero
#---------------------------------------------------------------------------#
#set -g base-index 1
#---------------------------------------------------------------------------#
# default terminal - we want 256 colors !!!
#---------------------------------------------------------------------------#
set -g default-terminal "screen-256color"
#---------------------------------------------------------------------------#
# on-screen time for status messages in ms
#---------------------------------------------------------------------------#
set -g display-time 2000
#---------------------------------------------------------------------------#
# on-screen time for display-panes in ms
#---------------------------------------------------------------------------#
set -g display-panes-time 2000
#---------------------------------------------------------------------------#
# color for display pane indicator
#---------------------------------------------------------------------------#
set -g display-panes-colour "cyan"
#set -g display-panes-active-colour "#0087ff"
#set -g display-panes-active-colour "red"
#---------------------------------------------------------------------------#
# open a man page in new window
#---------------------------------------------------------------------------#
unbind m
bind m command-prompt "split-window 'exec man %%'"
#---------------------------------------------------------------------------#
# quick view of processes
#---------------------------------------------------------------------------#
#bind '~' split-window "exec htop"
#---------------------------------------------------------------------------#
# scrollback buffer n lines
#---------------------------------------------------------------------------#
set -g history-limit 5000
#---------------------------------------------------------------------------#
# toggle status bar
#---------------------------------------------------------------------------#
unbind b
bind-key b set-option status
#---------------------------------------------------------------------------#
# resize panes like vim
# feel free to change the "1" to however many lines you want to resize by,
# only one at a time can be slow
#---------------------------------------------------------------------------#
unbind <
unbind >
unbind -
unbind +
bind -r < resize-pane -L 1
bind -r > resize-pane -R 1
bind -r - resize-pane -D 1
bind -r + resize-pane -U 1
#---------------------------------------------------------------------------#
# toggle mouse helpers
#---------------------------------------------------------------------------#
unbind Enter
unbind C-m
bind C-m set-option mouse \; display-message 'mouse -> #{?mouse,on,off}'
#---------------------------------------------------------------------------#
# Reload config file
#---------------------------------------------------------------------------#
unbind R
bind-key R source-file ~/.tmux.conf \; display-message "Reloading configuration done"
#---------------------------------------------------------------------------#
# start ssh session in new window
#---------------------------------------------------------------------------#
unbind S
bind-key S command-prompt "new-window -n %1 'ssh %1'"
#---------------------------------------------------------------------------#
# start new session
#---------------------------------------------------------------------------#
unbind C
bind-key C command-prompt "new-session -s %1"
#---------------------------------------------------------------------------#
# Keys to switch session
#---------------------------------------------------------------------------#
bind Q switchc -t0
bind W switchc -t compile
bind E switchc -t config
#---------------------------------------------------------------------------#
# break pane in background
#---------------------------------------------------------------------------#
unbind '@'
bind '@' break-pane -d
#---------------------------------------------------------------------------#
# join pane with target window
#---------------------------------------------------------------------------#
unbind ^
bind ^ command-prompt "join-pane -t %1"
#---------------------------------------------------------------------------#
# move around panes with hjkl, as one would in vim after pressing ctrl-w
#---------------------------------------------------------------------------#
#bind h select-pane -L
#bind j select-pane -D
#bind k select-pane -U
#bind l select-pane -R
#---------------------------------------------------------------------------#
# bind : to command-prompt like vim
# this is the default in tmux already
#---------------------------------------------------------------------------#
bind : command-prompt
#---------------------------------------------------------------------------#
# Remain on exit
#---------------------------------------------------------------------------#
#setw -g remain-on-exit on
#---------------------------------------------------------------------------#
# vi-style controls for copy mode
#---------------------------------------------------------------------------#
setw -g mode-keys vi
#---------------------------------------------------------------------------#
# Make mouse useful in copy mode
#---------------------------------------------------------------------------#
#setw -g mode-mouse on
#---------------------------------------------------------------------------#
# More straight forward key bindings for splitting
#---------------------------------------------------------------------------#
unbind %
unbind v
#bind | split-window -h
bind v split-window -h
unbind '"'
unbind h
#bind - split-window -v
bind h split-window -v
#---------------------------------------------------------------------------#
# Synchronize panes
#---------------------------------------------------------------------------#
unbind y
bind y set-window-option synchronize-panes \; display-message 'synchronize-panes -> #{?synchronize-panes,on,off}'
#---------------------------------------------------------------------------#
# Other key codes: Tab, BTab, Escape
#---------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
# Clock
#---------------------------------------------------------------------------#
setw -g clock-mode-colour green
setw -g clock-mode-style 24
#---------------------------------------------------------------------------#
# Terminal emulator window title
#---------------------------------------------------------------------------#
set -g set-titles on
set -g set-titles-string '#S:#I.#P #W'
#---------------------------------------------------------------------------#
# Status Bar
#---------------------------------------------------------------------------#
set -g status-bg black
set -g status-fg white
set -g status-interval 1
set -g status-left-length 30
set -g status-left '#[fg=green]#h#[default] '
#set -g status-right '#[fg=yellow]#(cut -d " " -f 1-4 /proc/loadavg)#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default]'
#set -g status-right '#[fg=yellow,bold]%Y-%m-%d %H:%M#[default]'
set -g status-right '#[fg=yellow]%Y-%m-%d %H:%M %Z#[default]'
#set -g status-justify center
#set -g status-keys vi
set -g allow-rename off
setw -g automatic-rename on
#---------------------------------------------------------------------------#
# Highlighting the active window in status bar
#---------------------------------------------------------------------------#
#setw -g window-status-current-bg red
set-option -g window-status-format "#I:#W#F#{?pane_synchronized,S,}"
set-window-option -g window-status-current-format "#{?pane_synchronized,#[bg=red],}#{?window_zoomed_flag,#[bg=colour130],}#I:#W#F#{?pane_synchronized,S,}"
set-option -g window-status-current-style bg=blue
#---------------------------------------------------------------------------#
# global update environment
#---------------------------------------------------------------------------#
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TZ"
#---------------------------------------------------------------------------#
# settings for AIX
# terminal overrides to enable colors
# set default terminal to vt100 or xterm (screen does not exist on AIX)
#---------------------------------------------------------------------------#
if-shell "uname|grep AIX" 'set -g terminal-overrides "xterm*:XT,xterm*:setab=\\E[4%p1%dm,xterm*:setaf=\\E[3%p1%dm"'
#if-shell "uname|grep AIX" "set -g default-terminal vt100"
if-shell "uname|grep AIX" "set -g default-terminal xterm"
#---------------------------------------------------------------------------#
# settings for macOS
#---------------------------------------------------------------------------#
if-shell "uname|grep Darwin" 'set -g default-command "/bin/bash -l"'
#---------------------------------------------------------------------------#
# Pane coloring
# set inactive/active window styles
#---------------------------------------------------------------------------#
set -g window-style "fg=colour247,bg=colour234"
set -g window-active-style "fg=colour250,bg=black"
set -g @TPCS "1"
#---------------------------------------------------------------------------#
# pane border - different style / use cyan
#---------------------------------------------------------------------------#
#set -g pane-border-bg colour235
#set -g pane-border-fg colour238
#set -g pane-active-border-bg colour234
#set -g pane-active-border-fg colour51
#---------------------------------------------------------------------------#
# toggle pane coloring on/off
#---------------------------------------------------------------------------#
unbind C-b
bind C-b if -F '#{@TPCS}' \
'set -g window-style "fg=default,bg=default" ; set -g window-active-style "fg=default,bg=default" ; set -g @TPCS "0"; display-message "Pane coloring -> off"' \
'set -g window-style "fg=colour247,bg=colour234" ; set -g window-active-style "fg=colour250,bg=black" ; set -g @TPCS "1"; display-message "Pane coloring -> on"'
#---------------------------------------------------------------------------#
# List of plugins
#---------------------------------------------------------------------------#
set -g @plugin 'tmux-plugins/tpm'
#set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-logging'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-save-bash-history 'on'
set -g @logging-path $HOME
set -g @screen-capture-path $HOME
set -g @save-complete-history-path $HOME
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'
#---------------------------------------------------------------------------#
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
#---------------------------------------------------------------------------#
run '~/.tmux/plugins/tpm/tpm'