首页 > 技术文章 > 分享一个好用的tmux配置文件

yongjieShi 2019-03-01 16:03 原文

tmux众所周知,不过多介绍,友好的tmux配置,让人用起来很舒服,分享一个tmux配置文件

# ------ general ------------------------------------
set -g prefix2 C-s
bind C-s send-prefix -2

set -g escape-time 0
set -g base-index 1
set -g renumber-windows on
set -g mouse on
set -wg pane-base-index 1

# rename-window
set -wg allow-rename off
set -wg automatic-rename off

set -wg mode-keys vi

# last-window
bind a last

# retain current path
bind c new-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"

# restart and edit
bind r source ~/.tmux.conf\; display "tmux config sourced"
bind e neww -n tmux-config "\${EDITOR:-vim} ~/.tmux.conf"

# ------ move around --------------------------------
bind -r h select-pane -L 
bind l select-pane -R        # remove repeat, because of ls
bind -r j select-pane -D
bind -r k select-pane -U

# ------ status theme -------------------------------
set -g message-style "bg=#00346e, fg=#ffffd7"        # tomorrow night blue, base3

set -g status-style "bg=#00346e, fg=#ffffd7"   # tomorrow night blue, base3
set -g status-left "#[bg=#0087ff] ❐ #S "       # blue
set -g status-left-length 400
set -g status-right "#{?client_prefix, ⌨ , } #[bg=#0087ff] #(whoami)@#h #[bg=red] %Y-%m-%d %H:%M "
set -g status-right-length 600

set -g set-clipboard on
set -g history-limit 8000

set -wg window-status-format " #I #W "
set -wg window-status-current-format " #I #W "
set -wg window-status-separator ""
set -wg window-status-current-style "bg=red" # red
set -wg window-status-last-style "fg=red"

set -wg pane-active-border-style "fg=blue"
set -wg pane-border-style "fg=#585858"       # base01

# ------- copy to clipboard ------------------------
# bind -t vi-copy y copy-pipe 'xclip -selection clipboard > /dev/null'
# bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

注意在添加配置文件的时候,一定要关闭所有tmux窗口,然后source .tmux.conf,之后进入tmux就可以愉快的使用了

--------

更新,进入tmux之后,可能无法使用鼠标选中并且复制的情况,这个时候将配置文件中的

set -g mouse on

这一行注释掉即可

推荐阅读