########################################################
# Kostia / Kossboss / Infotinks - favorite tmux config #
########################################################

# tested on tmux 2.6, find version with "tmux -V"
# put this file on ~/.tmux.conf
# if edited this file while running, reload tmux completely or reload while running with:
# ^a (or prefix) and :source-file ~/.tmux.conf

# Set the prefix to ^Q.
unbind C-b
set -g prefix ^Q
bind q send-prefix

# Bind appropriate commands similar to screen.
# lockscreen ^X x
unbind ^X
bind ^X lock-server
unbind x
bind x lock-server

# screen ^C c
unbind ^C
bind ^C new-window
unbind c
# old: bind c new-window
bind c new-window -c "#{pane_current_path}"

# detach ^D d
unbind ^D
bind ^D detach

# displays *
unbind *
bind * list-clients

# next ^@ ^N sp n
unbind ^@
bind ^@ next-window
unbind ^N
bind ^N next-window
unbind " "
bind " " next-window
unbind n
bind n next-window

# title A
unbind A
bind A command-prompt "rename-window %%"

# other ^A
unbind ^A
bind ^A last-window

# prev ^H ^P p ^?
unbind ^H
bind ^H previous-window
unbind ^P
bind ^P previous-window
unbind p
bind p previous-window
unbind BSpace
bind BSpace previous-window

# windows ^W w
unbind ^W
bind ^W list-windows
unbind w
bind w list-windows

# quit \
unbind '\'
bind '\' confirm-before "kill-server"

# kill K k
unbind K
bind K confirm-before "kill-window"
unbind k
# bind k confirm-before "kill-window"
# Kostia edit - upper case kills window, lower case kills pane in window
bind k confirm-before "kill-pane"

# redisplay ^L l
unbind ^L
bind ^L refresh-client
unbind l
bind l refresh-client

# split -v |
unbind |
# old: bind | split-window
bind | split-window -c "#{pane_current_path}"

# split -h %
bind % split-window -h -c "#{pane_current_path}"

# :kB: focus up
unbind Tab
bind Tab select-pane -t:.+
unbind BTab
bind BTab select-pane -t:.-

# " windowlist -b
unbind '"'
bind '"' choose-window

########## final working tweaks #######

# for mouse support, comment out unneeded section

# enable mouse support in tmux < 2.1
# setw -g mode-mouse on
# set -g mouse-select-pane on
# set -g mouse-resize-pane on
# set -g mouse-select-window on

# enable mouse support in tmux >= 2.1
set-option -g mouse on

# scroll speed 1 for tmux 2.4 and older
bind -Tcopy-mode WheelUpPane send -N1 -X scroll-up
bind -Tcopy-mode WheelDownPane send -N1 -X scroll-down
set -g @scroll-speed-num-lines-per-scroll 1

# scroll limit increase (def is 2000)
set-option -g history-limit 10000

# pane sync with just control-s
# bind -n C-s set-window-option synchronize-panes

# pane sync control-a (or prefix) then control-s
bind C-s set-window-option synchronize-panes

# stop auto renaming windows / tabs - I name my tabs often with ^a Shift-a and its annoying having them rename back
# set allow-rename off # <-- this didn't error, but it also didn't work they still renamed. one below worked
set-window-option -g allow-rename off

# swap windows/tab with Control-Shift-left or right arrow
bind -n C-S-Left swap-window -t -1\; select-window -t -1
bind -n C-S-Right swap-window -t +1\; select-window -t +1

# if you don't travel with the window/tab, comment out above, and uncomment this
# bind -n C-S-Left swap-window -t -1
# bind -n C-S-Right swap-window -t +1

# END OF FILE
