Skip to content

Instantly share code, notes, and snippets.

@TzuChiehHung
Last active January 24, 2019 09:33
Show Gist options
  • Save TzuChiehHung/1a9c42dd75583b1c5345b2ef215be674 to your computer and use it in GitHub Desktop.
Save TzuChiehHung/1a9c42dd75583b1c5345b2ef215be674 to your computer and use it in GitHub Desktop.
[tmux config] #tmux #powerline #config
# TC's tmux.conf
# =============================
# -----------------------------
# General settings
# -----------------------------
# scrollback buffer n lines
set -g history-limit 5000
# listen for activity on all windows
set -g bell-action any
# start window and pane indexing at 1 so the <prefix> 1 is easier to reach
set -g base-index 1
set -g pane-base-index 1
# renumber windows when a window is colsed
set -g renumber-windows on
# tell tmux to use 256 colour terminal
set -g default-terminal "xterm-256color"
# xterm-style function key sequences
setw -g xterm-keys on
# control automatic window renaming
setw -g automatic-rename off
# enable wm window titles
set -g set-titles on
# remove <esc> key press delay
set -sg escape-time 0
# enable mouse mode
set -g mouse on
# -----------------------------
# Useful commands
# -----------------------------
# open a man page in new pane, using q to leave
# bind-key / command-prompt -p 'man ' "split-window -h 'exec man %%'"
# bind-key r command-prompt -p 'Command >> ' "split-window -c '#{pane_current_path}' -h '%%; echo \"Press enter to continue.\"; read;'"
# reload settings
bind-key r source-file ~/.tmux.conf
# Prevent terminal freezing by C-s
bind-key -n C-s display 'Terminal freezing by C-s prevented'
# -----------------------------
# Key bindings
# -----------------------------
# set <prefix> key to C-a
set-option -g prefix C-a
# use C-a again to send ctrl-a to inner session
bind-key C-a send-prefix
# Create window
bind-key -n C-n new-window
# use C-n to create new windows because C-c is to interrupt
# split windows (create pane)
bind-key h split-window -v -c '#{pane_current_path}'
bind-key v split-window -h -c '#{pane_current_path}'
# kill current pane when the inner process is unable to exit for whatever reason
#bind-key q confirm-before kill-pane
# Navigation
# navigate windows
unbind-key l
bind-key -n S-left select-window -t :-
bind-key -n S-right select-window -t :+
# navigate panes
bind -n C-Left select-pane -L
bind -n C-Right select-pane -R
bind -n C-Up select-pane -U
bind -n C-Down select-pane -D
# Modify - rename, resize and reorder
# rename title
bind-key , command-prompt "rename-window %%"
# move the split line (resize pane)
bind-key -n M-left resize-pane -L 3
bind-key -n M-right resize-pane -R 3
bind-key -n M-up resize-pane -U 1
bind-key -n M-down resize-pane -D 1
# # move (swap) panes and windows
# # <prefix> alt-
# # k --- move pane next
# # h l --- move window left / move window right
# # j --- move pane previous
# bind-key -r M-h swap-window -t :-
# bind-key -r M-j swap-pane -D
# bind-key -r M-k swap-pane -U
# bind-key -r M-l swap-window -t :+
# # change window pane layouts
# bind-key -r M-f next-layout
# toogle a pane between full-screen and pane-size
bind-key -n C-f resize-pane -Z
# Copy-mode (vi-mode)
#
# vi-style controls for copy mode
setw -g mode-keys vi
# C-v (the original '[' is still availible) to enter vi-mode
# bind-key [ copy-mode
bind-key -n C-e copy-mode
# bind-key C-v copy-mode
# select and copy like vi in vi-mode
# bind-key -T copy-mode-vi v send -X begin-selection
# bind-key -T copy-mode-vi y send -X copy-selection
# if encounter incompatible with send-keys/send -X, use lagacy setting:
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
# pasting
#bind-key ] paste-buffer
bind-key -n C-p paste-buffer
# bind-key C-p paste-buffer
# enable navigation in vi mode
# bind-key -T copy-mode-vi C-h select-window -t :-
# bind-key -T copy-mode-vi C-l select-window -t :+
# bind-key -T copy-mode-vi C-j select-pane -t :.-
# bind-key -T copy-mode-vi C-k select-pane -t :.+
# -----------------------------
# tmux powerline
# -----------------------------
set -g status-bg black
set -g status-fg white
set -g window-status-current-bg white
set -g window-status-current-fg black
# set -g window-status-current-attr bold
set-option -g status on
set-option -g status-interval 60
set-option -g status-justify "left"
set-option -g status-left-length 60
set-option -g status-right-length 90
set-option -g status-left "#(~/.tmux-powerline/powerline.sh left)"
set-option -g status-right "#(~/.tmux-powerline/powerline.sh right)"
#set-window-option -g window-status-current-format "#[fg=colour235, bg=colour27]⮀#[fg=colour255, bg=colour27] #I ⮁ #W #[fg=colour27, bg=colour235]⮀"
#bind C-[ run '~/.tmux-powerline/mute_powerline.sh left' # Mute left statusbar.
#bind C-] run '~/.tmux-powerline/mute_powerline.sh right' # Mute right statusbar.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment