Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
262 lines (217 sloc) 9.33 KB
# INSTALL
# cp tmuxconf ~/.tmux.conf
#
# Set prefix key to c-f instead of default c-b
unbind C-b
set -g prefix C-f
bind C-f send-prefix
# toogle last window by hitting again C-f
bind-key C-f last-window
# if multiple clients are attached to the same window, maximize it to the
# bigger one
set-window-option -g aggressive-resize
# Start windows and pane numbering with index 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
# re-number windows when one is closed
set -g renumber-windows on
# word separators for automatic word selection
setw -g word-separators ' @"=()[]_-:,.'
setw -ag word-separators "'"
# Show times longer than supposed
set -g display-panes-time 2000
# tmux messages are displayed for 4 seconds
set -g display-time 4000
# {n}vim compability
set -g default-terminal "screen-256color"
# Split horiziontal and vertical splits, instead of % and "
# Also open them in the same directory
bind-key v split-window -h -c '#{pane_current_path}'
bind-key s split-window -v -c '#{pane_current_path}'
# Pressing Ctrl+Shift+Left (will move the current window to the left. Similarly
# right. No need to use the modifier (C-b).
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
# Source file
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Update default binding of `Enter` and `Space to also use copy-pipe
unbind -T copy-mode-vi Enter
unbind -T copy-mode-vi Space
bind-key -T edit-mode-vi Up send-keys -X history-up
bind-key -T edit-mode-vi Down send-keys -X history-down
# setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
# copy text with `y` in copy mode
# bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel\; run "tmux save -|pbcopy >/dev/null 2>&1"
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# copy text with mouse selection without pressing any key
# bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel\; run "tmux save -|pbcopy >/dev/null 2>&1"
# bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel
# emacs key bindings in tmux command prompt (prefix + :) are better than
# vi keys, even for vim users
set -g status-keys emacs
# focus events enabled for terminals that support them
set -g focus-events on
# Sync panes (Send input to all panes in the window). When enabled, pane
# borders become red as an indication.
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 "' \
'setw synchronize-panes on; \
setw pane-active-border-style fg=red; \
setw pane-border-format " #P - Pane Synchronization ON "'
# Faster command sequence
set -s escape-time 0
# Have a very large history
set -g history-limit 1000000
# Mouse mode on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set -g mouse on
# Set title
set -g set-titles on
set -g set-titles-string "#T"
# Equally resize all panes
bind-key = select-layout even-horizontal
bind-key | select-layout even-vertical
# Resize panes
bind-key J resize-pane -D 10
bind-key K resize-pane -U 10
bind-key H resize-pane -L 10
bind-key L resize-pane -R 10
# Select panes
# NOTE(arslan): See to prevent cycling https://github.com/tmux/tmux/issues/1158
bind-key j select-pane -D
bind-key k select-pane -U
bind-key h select-pane -L
bind-key l select-pane -R
# Disable confirm before killing
bind-key x kill-pane
# This tmux statusbar config was created by tmuxline.vim
# on Wed, 25 Nov 2015
set -g status "on"
set -g status-bg "colour236"
set -g status-justify "left"
set -g status-position "top"
set -g status-left-length "100"
set -g status-left-attr "none"
set -g status-right-length "100"
set -g status-right-attr "none"
set -g status-attr "none"
set -g status-left "#{prefix_highlight}#[fg=colour22,bg=colour148,bold] #S #[fg=colour148,bg=colour236,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=colour240,bg=colour236,nobold,nounderscore,noitalics]#[fg=colour250,bg=colour240] %Y-%m-%d %H:%M #[fg=colour252,bg=colour240,nobold,nounderscore,noitalics]#[fg=colour241,bg=colour252] #h "
set -g pane-active-border-fg "colour148"
set -g pane-border-fg "colour240"
set -g message-command-fg "colour231"
set -g message-bg "colour240"
set -g message-fg "colour231"
set -g message-command-bg "colour240"
setw -g window-status-fg "colour245"
setw -g window-status-attr "none"
setw -g window-status-activity-bg "colour236"
setw -g window-status-activity-attr "none"
setw -g window-status-activity-fg "colour148"
setw -g window-status-separator ""
setw -g window-status-bg "colour236"
setw -g window-status-format "#[fg=colour245,bg=colour236] #I #[fg=colour245,bg=colour236]#W "
setw -g window-status-current-format "#[fg=colour236,bg=colour240,nobold,nounderscore,noitalics]#[fg=colour231,bg=colour240] #I #[fg=colour231,bg=colour240]#{?window_zoomed_flag,#[fg=green][],}#W #[fg=colour240,bg=colour236,nobold,nounderscore,noitalics]"
# List of plugins
# see this https://github.com/tmux-plugins/tpm to installation
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @yank_with_mouse off
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# The followings are not any kind of setting for Tmux, but crucial to my
# own productivity. Setting them up is really pain, and I probably going to
# forget it. So I'm just putting them here again.
######## iTerm + Tmux key integration #########
# First of all, iTerm can send hex codes for shortcuts you define. So for
# example you can send a hex code for the shortcut "c-f v" which in my case
# opens a vertical pane (see setting above). The hex code for this combination
# is: 0x06 0x76. There are many cases to find it out. One of them is the tool
# 'xxd'
# If you run "xxd -psd" and hit "c-f v" and then enter and finally c-c to exit
# , it outputs the following:
#
# $ xxd -psd
# ^Fv
# 06760a^C
#
# What matters is the sequence 06760a^C where:
#
# 06 -> c-f
# 76 -> v
# 0a -> return
# ^C -> c-c
#
# From here, we know that 0x06 0x76 corresponds to "c-f v".
#
# Finally, inside the iTerm2 Key settings, I'm adding just various shortcuts,
# such as cmd-j, cmd-left, etc.. , select the option "send hex code" and the
# enter the hex code which I want to be executed, hence the tmux sequence. So
# when I press CMD + d in iterm, I send the sequence 0x06 0x76,
# which tmux inteprets it as opening a new pane.
###############################################
######## Alacritty + Tmux key integration #########
# First of all, Alacritty can send hex codes for shortcuts you define. So for
# example you can send a hex code for the shortcut "c-f v" which in my case
# opens a vertical pane (see setting above). The hex code for this combination
# is: 0x06 0x76. There are many cases to find it out. One of them is the tool
# 'xxd'
# If you run "xxd -psd" and hit "c-f v" and then enter and finally c-c to exit
# , it outputs the following:
#
# $ xxd -psd
# ^Fv
# 06760a^C
#
# What matters is the sequence 06760a^C where:
#
# 06 -> c-f
# 76 -> v
# 0a -> return
# ^C -> c-c
#
# From here, we know that 0x06 0x76 corresponds to "c-f v".
#
# Next step is to add a line to 'key_binding' setting in Alacritty:
#
# - { key: D, mods: Command, chars: "\x06\x76" }
#
# That's it! The followings are the ones that I'm using:
#
# key_bindings:
# - { key: D, mods: Command, chars: "\x06\x76" }
# - { key: D, mods: Command|Shift, chars: "\x06\x73" }
# - { key: W, mods: Command, chars: "\x06\x78" }
# - { key: H, mods: Command, chars: "\x06\x68" }
# - { key: J, mods: Command, chars: "\x06\x6a" }
# - { key: K, mods: Command, chars: "\x06\x6b" }
# - { key: L, mods: Command, chars: "\x06\x6c" }
# - { key: T, mods: Command, chars: "\x06\x63" }
# - { key: Key1, mods: Command, chars: "\x06\x31" }
# - { key: Key2, mods: Command, chars: "\x06\x32" }
# - { key: Key3, mods: Command, chars: "\x06\x33" }
# - { key: Key4, mods: Command, chars: "\x06\x34" }
# - { key: Key5, mods: Command, chars: "\x06\x35" }
# - { key: Key6, mods: Command, chars: "\x06\x36" }
# - { key: Key7, mods: Command, chars: "\x06\x37" }
# - { key: Key8, mods: Command, chars: "\x06\x38" }
# - { key: Key9, mods: Command, chars: "\x06\x39" }
# - { key: Left, mods: Command, chars: "\x06\x48" }
# - { key: Down, mods: Command, chars: "\x06\x4a" }
# - { key: Up, mods: Command, chars: "\x06\x4b" }
# - { key: Right, mods: Command, chars: "\x06\x4c" }
#
# Finally, inside the iTerm2 Key settings, I'm adding just various shortcuts,
# such as cmd-j, cmd-left, etc.. , select the option "send hex code" and the
# enter the hex code which I want to be executed, hence the tmux sequence. So
# when I press CMD + d in iterm, I send the sequence 0x06 0x76,
# which tmux inteprets it as opening a new pane.
###############################################