Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
285 lines (225 sloc) 9.23 KB
# ~/.tmux.conf
#
# 2017-02-16 (fabic.net)
#
# Copied from (and personal adjustments) :
# http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
# See also :
# * https://mutelight.org/practical-tmux
# * Cheatsheet : https://gist.github.com/andreyvit/2921703
# TODO:
# * See https://gist.github.com/subfuzion/814b3360e9f0b2d89c08 for more bits and pieces.
# * See https://unix.stackexchange.com/a/373692 for Mouse right click that selects a pane/window
# as swap-pane/window target.
# Remap prefix from 'C-b' to 'C-k'
unbind C-k # (just in case it's bounded).
set -g prefix C-k
# Also have Ctrl-A like Screen (?).
# (NO: it messes up too much, gets in the way).
#set -g prefix C-a
# Remove previous mapping.
# (NO: it's ok to have it for when you come back from other non-configured Tmuxes).
#unbind C-b
# Ctrl-k Ctrl-k : For controlling nested Tmux sessions.
# ( yes, this is quite useful, just keep this dude ).
bind-key C-k send-prefix
# Split panes using | and \ :
bind / split-window -v
bind \ split-window -h
# Split panes : Remove original Tmux mapping ?
#unbind "'"
#unbind %
# Make current window the 1st window.
bind a swap-window -t 1
# Move window "left".
bind e swap-window -t -1
# Reload config file.
bind r source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded."
# Switch panes using Alt-arrow without prefix :
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# And/Or Vim-style Ctrl-HJKL :
#bind C-h select-pane -L
#bind C-l select-pane -R
#bind C-k select-pane -U
#bind C-j select-pane -D
#unbind ";"
#bind C-\; last-window
# FIXME ^
# Cycle through this window's panes (like 'o').
#bind C-k select-pane -t :.+
# ^ Better to have C-k C-k for controlling nested Tmux session, see earlier.
bind C-l select-pane -t :.+
bind C-n next-window
bind C-p previous-window
# Vim mappings ?!
bind v setw -g mode-keys vi
# Start window numbering at 1.
set -g base-index 1
setw -g pane-base-index 1
# Enable mouse control (clickable windows, panes, resizable panes)
#set -g mouse-select-window on
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
# New with tmux 2.1+ :
set -g mouse on
# ^ NOTE: this messes up with your Vim & terminal (EDIT: Really ?)
# Switch mouse off/on with m/M.
bind m set -g mouse off \; display "Mouse: OFF -_-"
bind M set -g mouse on \; display "Mouse: ON o_O"
# don't rename windows automatically
#set-option -g allow-rename off
set-option -g set-titles on
setw -g aggressive-resize on
## Trying to fix mousewheel scrolling issues -_- ##
# Dude: All three methods (A, B, C) below _seem to solve the problem_.
# (A) Sane scrolling (this is supposed to enable native xterm scrolling).
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# (B) Another one found on StackOverflow.
# Allow xterm titles in terminal window, terminal scrolling with scrollbar,
# and setting overrides of C-Up, C-Down, C-Left, C-Right
#set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"
# (C) https://superuser.com/a/1007721
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"
# Don't: Vim mouse gets quite buggy, possibly due to this.
#setw -g xterm-keys on
# Scroll History
set -g history-limit 30000
# Set ability to capture on start and restore on exit window data when running an application
#setw -g alternate-screen on
# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50
# https://unix.stackexchange.com/a/318285
# bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
# bind -n WheelDownPane select-pane -t= \; send-keys -M
# bind -n C-WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
# bind -t vi-copy C-WheelUpPane halfpage-up
# bind -t vi-copy C-WheelDownPane halfpage-down
# bind -t emacs-copy C-WheelUpPane halfpage-up
# bind -t emacs-copy C-WheelDownPane halfpage-down
# To copy: drag to highlight text, press Enter and then release mouse.
# Linux-only.
# “Gnome-terminal doesn't support setting the clipboard
# using xterm escape sequences [...]”
# -- https://unix.stackexchange.com/a/349020
set-option -s set-clipboard off
# Update default binding of `Enter` to also use copy-pipe
#unbind -t vi-copy Enter
#bind-key -t vi-copy Enter copy-pipe "pbcopy"
# Use vim keybindings in copy mode
setw -g mode-keys vi
set -g status-keys vi
# Setup 'v' to begin selection as in vim
bind-key -T copy-mode-vi v send-keys -X begin-selection
# For Mac OX X we need the `reattach-to-user-namespace` tool that connects to the
# clipboard service. Install with homebrew ( http://brew.sh/ ) :
#
# ~$ brew install reattach-to-user-namespace
#
#bind-key -T vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Linux: `pbcopy` is actually a shell alias to `xclip ...`
#bind-key -T vi-copy y copy-pipe "pbcopy"
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -r -selection primary"
bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel "xclip -i -r -selection clipboard"
# Update default binding of `Enter` to also use copy-pipe (os x)
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -r -selection clipboard"
# Remap `Esc.` to exit copy-mode.
unbind -T copy-mode-vi Escape
bind-key -T copy-mode-vi Escape send-keys -X cancel
# Mouse drag and release copy text to X primary clipboard,
# _and_ also to the Ctrl-X/C/V clipboard.
# which is the behaviour we all expect.
# ( https://unix.stackexchange.com/a/349020 )
bind-key -T copy-mode-vi MouseDragEnd1Pane \
send-keys -X copy-pipe-and-cancel \
"( xclip -i -r -selection primary -i ; xclip -o | xclip -i -r -selection clipboard -i )"
# Mouse middle button release (the wheel button) will paste the Tmux buffer.
bind-key -T root MouseUp2Pane paste-buffer
# TODO: find out how to paste the X primary sel.
#bind-key -T root MouseUp3Pane run "tmux set-buffer "$(xclip -o -r -selection clipboard)"; paste-buffer
### DESIGN CHANGES {
##
## ( adjustments by http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ )
## ( to an original Tmux theme at https://www.reddit.com/r/unixporn/comments/3cn5gi/tmux_is_my_wm_on_os_x/ )
## ( by https://www.reddit.com/user/dothebarbwa )
# Panes {
set -g pane-border-fg black
set -g pane-active-border-fg brightred
# }
## Status bar design
# Status line
set -g status-justify left
set -g status-bg default
set -g status-fg colour12
set -g status-interval 2
# messaging
set -g message-fg black
set -g message-bg yellow
set -g message-command-fg blue
set -g message-command-bg black
# window mode
setw -g mode-bg colour6
setw -g mode-fg colour0
# window status
setw -g window-status-format " #F#I:#W#F "
setw -g window-status-current-format " #F#I:#W#F "
setw -g window-status-format "#[fg=magenta]#[bg=black] #I #[bg=cyan]#[fg=colour8] #W "
setw -g window-status-current-format "#[bg=brightmagenta]#[fg=colour8] #I #[fg=colour8]#[bg=colour14] #W "
setw -g window-status-current-bg colour0
setw -g window-status-current-fg colour11
setw -g window-status-current-attr dim
setw -g window-status-bg green
setw -g window-status-fg black
setw -g window-status-attr reverse
# Info on left (I don't have a session display for now)
set -g status-left ''
# loud or quiet?
set-option -g visual-activity off
set-option -g visual-bell off
set-option -g visual-silence off
set-window-option -g monitor-activity off
set-option -g bell-action none
set -g default-terminal "screen-256color"
# The modes {
setw -g clock-mode-colour colour135
setw -g mode-attr bold
setw -g mode-fg colour196
setw -g mode-bg colour238
# }
# The panes {
set -g pane-border-bg colour235
set -g pane-border-fg colour238
set -g pane-active-border-bg colour236
set -g pane-active-border-fg colour51
# }
# The statusbar {
set -g status-position bottom
set -g status-bg colour234
set -g status-fg colour137
set -g status-attr dim
set -g status-left '#[fg=colour233,bg=colour247,bold] #I:#P '
set -g status-right '#[fg=colour233,bg=colour245,bold] %H:%M:%S #[fg=colour233,bg=colour241,bold] %Y-%m-%d #[fg=colour233,bg=colour245,bold] #S #[fg=colour233,bg=colour241,bold] #H #(hostname -I)'
set -g status-right-length 50
set -g status-left-length 20
setw -g window-status-current-fg colour81
setw -g window-status-current-bg colour238
setw -g window-status-current-attr bold
setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F '
setw -g window-status-fg colour138
setw -g window-status-bg colour235
setw -g window-status-attr none
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
setw -g window-status-bell-attr bold
setw -g window-status-bell-fg colour255
setw -g window-status-bell-bg colour1
# }
# The messages {
set -g message-attr bold
set -g message-fg colour232
set -g message-bg colour166
# }
# }
# vim: set sw=2 ts=2 sts=2 et tw=0 foldmarker={,} foldlevel=3 foldmethod=marker :
You can’t perform that action at this time.