tmux配置

同事给的一个tmux的配置。做个笔记。

#-- base settings --#
## set -g default-terminal "screen-256color"
set -g default-terminal 'linux'
set -ga terminal-overrides ",rxvt-unicode-256color:Tc"
set -sg escape-time 0
set -g display-time 3000
set -g history-limit 65535
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on

#-- bindkeys --#
# prefix key (Ctrl+k)
# set -g prefix ^a
# unbind ^b
# bind a send-prefix

# split window
unbind '"'
bind - splitw -v -c "#{pane_current_path}" # vertical split (prefix -)
unbind %
bind | splitw -h # horizontal split (prefix |)

# select pane
bind k selectp -U # above (prefix k)
bind j selectp -D # below (prefix j)
bind h selectp -L # left (prefix h)
bind l selectp -R # right (prefix l)

# resize pane
bind -r ^k resizep -U 5 # upward (prefix Ctrl+k)
bind -r ^j resizep -D 5 # downward (prefix Ctrl+j)
bind -r ^h resizep -L 5 # to the left (prefix Ctrl+h)
bind -r ^l resizep -R 5 # to the right (prefix Ctrl+l)

# swap pane
bind p swapp -U # swap with the previous pane (prefix Ctrl+u)
bind n swapp -D # swap with the next pane (prefix Ctrl+d)

# select layout
bind , select-layout even-vertical
bind . select-layout even-horizontal

# misc
bind e lastp  # select the last pane (prefix e)
bind ^e last  # select the last window (prefix Ctrl+e)
bind q killp  # kill pane (prefix q)
bind ^q killw # kill window (prefix Ctrl+q)

# copy mode
bind Escape copy-mode               # enter copy mode (prefix Escape)
bind ^p pasteb                      # paste buffer (prefix Ctrl+p)
unbind -T copy-mode-vi Space
bind -T copy-mode-vi v send -X begin-selection   # select (v)
bind -T copy-mode-vi y send -X copy-pipe "xclip" # copy (y)

# app
bind ! splitw htop                                  # htop (prefix !)
bind m command-prompt "splitw 'exec man %%'"        # man (prefix m)
bind % command-prompt "splitw 'exec perldoc -t %%'" # perl doc (prefix %)
bind / command-prompt "splitw 'exec ri %%'"         # ruby doc (prefix /)

# reload config (prefix r)
bind r source ~/.tmux.conf \; display "Configuration reloaded!"

#-- statusbar --#
set -g status-interval 1
set -g status-keys vi

setw -g mode-keys vi
setw -g automatic-rename off

#-- colorscheme --#
# statusbar
set -g status-justify right
# set -g status-left ""
# set -g status-right ""
#左下角
set -g status-left "#[bg=black,fg=green][#[fg=cyan]#S#[fg=green]]"
set -g status-left-length 20
set -g automatic-rename on
set-window-option -g window-status-format '#[dim]#I:#[default]#W#[fg=grey,dim]'
set-window-option -g window-status-current-format '#[fg=cyan,bold]#I#[fg=blue]:#[fg=cyan]#W#[fg=dim]'
#右下角
set -g status-right '#[fg=green][#[fg=cyan]%Y-%m-%d %H:%M:%S#[fg=green]]'

# -- display -------------------------------------------------------------------

set -g base-index 1           # start windows numbering at 1
setw -g pane-base-index 1     # make pane numbering consistent with windows
setw -g automatic-rename on   # rename window to reflect current program
set -g renumber-windows on    # renumber windows when a window is closed
set -g set-titles on          # set terminal title
set -g display-panes-time 800 # slightly longer pane indicators display time
set -g display-time 1000      # slightly longer status messages display time
#set -g status-interval 1     # redraw status line every 10 seconds

set -g status-style "fg=#504945,bg=#282828"
# setw -g window-status-current-fg white
# setw -g window-status-current-bg red
# setw -g window-status-current-attr bright
# setw -g window-status-fg cyan
# setw -g window-status-bg default
# setw -g window-status-attr dim

# window
setw -g window-status-separator " "
setw -g window-status-format "-"
setw -g window-status-current-format "+"
setw -g window-status-current-style "fg=#d79921,bg=#282828"

# pane
set -g pane-border-style "fg=#ebdbb2"
set -g pane-active-border-style "fg=#d79921"

#开启window事件提示
setw -g monitor-activity on
#set -g visual-activity on

## 鼠标设置,不要打开,不然用鼠标选择不了内容
set-option -g mouse on

## =============================================================================
## https://github.com/erikw/tmux-powerline
set-option -g status on
set-option -g status-interval 2
set-option -g status-justify "centre"
set-option -g status-left-length 150
set-option -g status-right-length 120
set-option -g status-left "#(~/opt/.tmux/tmux-powerline/powerline.sh left)"
set-option -g status-right "#(~/opt/.tmux/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]⮀"

setw -g window-status-style 'fg=colour9 bg=colour18'
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold'
# messages
set -g message-style 'fg=colour1 bg=colour16 bold'
## =============================================================================
## =============================================================================

## 使用 bin++z 实现最大-最小屏
# unbind m
# bind m run ". ~/tmux-zoom "

bind -r a select-pane -t .+1 \;  resize-pane -Z
# bind -n C-Space resize-pane -Z

# Ref https://superuser.com/questions/238702/maximizing-a-pane-in-tmux
# #!/bin/bash -f
# currentwindow=`tmux list-window | tr '\t' ' ' | sed -n -e '/(active)/s/^[^:]*: *\([^ ]*\) .*/\1/gp'`;
# currentpane=`tmux list-panes | sed -n -e '/(active)/s/^\([^:]*\):.*/\1/gp'`;
# panecount=`tmux list-panes | wc | sed -e 's/^ *//g' -e 's/ .*$//g'`;
# inzoom=`echo $currentwindow | sed -n -e '/^zoom/p'`;
# if [ $panecount -ne 1 ]; then
#     inzoom="";
# fi
# if [ $inzoom ]; then
#     lastpane=`echo $currentwindow | rev | cut -f 1 -d '@' | rev`;
#     lastwindow=`echo $currentwindow | cut -f 2- -d '@' | rev | cut -f 2- -d '@' | rev`;
#     tmux select-window -t $lastwindow;
#     tmux select-pane -t $lastpane;
#     tmux swap-pane -s $currentwindow;
#     tmux kill-window -t $currentwindow;
# else
#     newwindowname=zoom@$currentwindow@$currentpane;
#     tmux new-window -d -n $newwindowname;
#     tmux swap-pane -s $newwindowname;
#     tmux select-window -t $newwindowname;
# fi

## --------------------------------------------------
# setw -g window-style 'bg=#262626'
# setw -g window-active-style 'bg=#121212'
# set-option -g pane-active-border-style 'bg=#3a3a3a'
# set-option -ag pane-active-border-style 'bg=#3a3a3a'
# set-option -g pane-active-border-fg colour237
# set-option -g pane-border-fg colour237
# setw -g pane-border-status bottom
# setw -g window-active-style 'bg=#3a3a3a,bold'

## -----------------------------------------------------
## 设置活跃窗口的背景颜色
set-option -ga terminal-overrides ",xterm-256color:Tc"
# setw -g window-style 'bg=#504945'
# setw -g window-active-style 'bg=#282828'

# set -g "window-style" "fg=#aab2bf,bg=default"
# # set -g "window-active-style" "bg=default"
# # setw -g window-style 'bg=#504945'
# setw -g window-active-style 'bg=#010038,bold'


set -g "window-style" "bg=default"
# set -g "window-active-style" "bg=default"
# setw -g window-style 'bg=#504945'
setw -g window-active-style 'bg=#282828,bold'


## -----------------------------------------------------

set-window-option -g clock-mode-colour colour40 #green
# set-option -g pane-border-fg colour10
# set-option -g pane-active-border-fg colour4
 
# toggle pane synchronization
bind s setw synchronize-panes

## =============================================================================
## 安装 tmux plugin
## 在 Tmux 里面使用 prefix + I 安装插件
# prefix + Ctrl-s - save
# prefix + Ctrl-r - restore
set -g @plugin 'tmux-plugins/tmux-resurrect'
## 或者手动安装
## cd ~/Documents
## git clone https://github.com/tmux-plugins/tmux-resurrect
run-shell ~/Documents/tmux-resurrect/resurrect.tmux
## =============================================================================

set -g pane-border-status bottom
set -g pane-border-format "#P #T #{pane_current_command}"

你可能感兴趣的:(tmux配置)