From 0327ab74a27623f9470198cbf3e5905cf940f2f4 Mon Sep 17 00:00:00 2001 From: shylinux Date: Wed, 19 Sep 2018 21:20:13 +0800 Subject: [PATCH 1/2] vps add tmux --- usr/wiki/zsh_tmux_vim.md | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/usr/wiki/zsh_tmux_vim.md b/usr/wiki/zsh_tmux_vim.md index 2cc8b365..fa8f68ca 100644 --- a/usr/wiki/zsh_tmux_vim.md +++ b/usr/wiki/zsh_tmux_vim.md @@ -77,6 +77,86 @@ $ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools $ sudo apt-get install curl ``` ### tmux使用 +tmux是终端管理软件,可以将一个窗口分隔成任意多个终端,这样就可以在一个窗口中同时执行多条命令。 +而且tmux在后台运行,即使窗口关闭或是网络连接断开了,终端依然在运行,可以重新连接,窗口的所有数据不会丢失。 +所以tmux可以极大的提高工作的效率和连续性。 + +Ubuntu上安装tmux +``` +$ sudo apt-get install tmux +``` +Mac上安装tmux +``` +$ brew install tmux +``` +Windows上安装tmux还是算了,太折腾了。 + +启动或连接tmux。 +``` +$ tmux +``` +每次在终端运行tmux命令,tmux首先连接后台服务,如果服务进程不存在,就会创建一个后台服务进程。 +服务启动后,和普通终端一样,就可以在tmux的窗口中执行各种命令行。 + +#### tmux快捷键体验 +tmux默认的控制键是Ctrl+b,然后再输入命令字符。就可以对tmux进行各种控制。 + +如下按下Ctrl+b,然后再按引号键,就可以将当前终端分隔成上下两个终端。 +``` +Ctrl+b " +``` +如下按下Ctrl+b,然后再按百分号键,就可以将当前终端分隔成左右两个终端。 +``` +Ctrl+b % +``` +如下按下Ctrl+b,然后再按字母o,就可以在两个终端来回切换。 +``` +Ctrl+b o +``` + +如下按下Ctrl+b,然后再按字母c,就可以创建一个新窗口。 +``` +Ctrl+b c +``` +如下按下Ctrl+b,然后再按字母n,就可以切换到下一个窗口。 +``` +Ctrl+b n +``` +如下按下Ctrl+b,然后再按字母p,就可以切换到下一个窗口。 +``` +Ctrl+b p +``` + +#### tmux命令行体验 +tmux的控制方式除了方便的快捷键,还有丰富的命令行。 + +如下命令,查看有多少个窗口。 +``` +$ tmux list-windows +``` +如下命令,创建一个新窗口。再调用list-windows,就可以看到新的窗口。 +``` +$ tmux new-window +``` +如下命令,查看有多少个会话。 +``` +$ tmux list-sessions +``` +如下命令,连接最近的会话。 +``` +$ tmux attach-session +``` + +#### tmux客户端与会话 +tmux是以CS的服务模型实现窗口管理。 +tmux的后台服务,负责管理客户端与会话的连接。可以同时管理多个会话,多个客户端,所以可以支持多个人同时连接服务。 +而且可以多个客户端连接同一个会话,这样连接的话,多个客户端是完全一样界面,从而实现屏幕共享,协同操作。 + +#### tmux窗口与面板 +#### tmux配置文件 +#### tmux缓存管理 + +同时管理多个终端。[tmux源码](https://github.com/tmux/tmux) ### docker使用 - [Windows版docker下载](https://store.docker.com/editions/community/docker-ce-desktop-windows) From 08552871fc3f099077319ba6f3541807946c68e6 Mon Sep 17 00:00:00 2001 From: shylinux Date: Wed, 19 Sep 2018 21:24:51 +0800 Subject: [PATCH 2/2] git add vim --- etc/dotsfile/.tmux.conf | 125 +++++++++++++++++++++++++++------------- etc/dotsfile/.zsh_local | 17 +----- 2 files changed, 86 insertions(+), 56 deletions(-) diff --git a/etc/dotsfile/.tmux.conf b/etc/dotsfile/.tmux.conf index ac7e0b53..6b4aeadf 100644 --- a/etc/dotsfile/.tmux.conf +++ b/etc/dotsfile/.tmux.conf @@ -1,27 +1,65 @@ -# 配置管理 -set -g prefix C-s +set -g prefix C-s #{{{ + +set default-terminal screen +#set default-shell /usr/bin/zsh + +set -g mode-keys vi +set -g history-limit 500000 set -g base-index 1 set -g display-panes-time 5000 set -g display-time 5000 -setw -g pane-base-index 1 -set -g mode-keys vi -set -g history-limit 50000 + +setw -g pane-base-index 1 +#}}} +set -g status off #{{{ +#set -g status-keys emacs +#set -g status-interval 1 +# +#set -g status-justify centre +#set -g status-style bg=green +# +#set -g status-left-length 40 +#set -g status-left-style bg=red +#set -g status-left ' [%m-%d %H:%M] #[bg=magenta] #S #[bg=green][#h.local] ' +# +#set -g status-right-length 40 +#set -g status-right-style bg=green +#set -g status-right '[#(basename `pwd`)/]#[bg=cyan] #P #[bg=blue][#{cursor_x},#{cursor_y} #{pane_height}x#{pane_width}] ' +# +#setw -g window-status-format ' #I:#W#F ' +#setw -g window-status-separator " " +#setw -g window-status-style bg=green +#setw -g window-status-bell-style bg=red +#setw -g window-status-last-style bg=green +#setw -g window-status-current-style bg=red +#setw -g window-status-current-format ' #I:#W#F ' + +#}}} bind Space command-prompt - -# 窗口管理 +# session # {{{ +bind d detach-client +bind g command-prompt -p "rename session:" "rename-session %%" +bind r source ~/.tmux.conf \; refresh-client +bind t clock-mode +# }}} +#window #{{{ bind w choose-window bind q confirm-before kill-window +# bind b break-pane +bind b display-panes bind c new-window bind o last-window bind n next-window bind p previous-window -bind m command-prompt -p "move window from:,to:" "swap-window -s %% -t %%" +bind f command-prompt -p "find: " "find-window '%%'" +bind e command-prompt -p "name: " "rename-window '%%'" +bind m command-prompt -p "from:,to:" "swap-window -s %% -t %%" bind 1 select-window -t :1 bind 2 select-window -t :2 @@ -30,7 +68,8 @@ bind 4 select-window -t :4 bind 5 select-window -t :5 bind 6 select-window -t :6 -# 面板管理 +#}}} +#pane #{{{ bind i display-panes bind x confirm-before -p "kill-pane #P? (y/n)" kill-pane @@ -47,44 +86,48 @@ bind C-h command-prompt -p "size:" "resize-pane -L %%" bind C-l command-prompt -p "size:" "resize-pane -R %%" bind C-j command-prompt -p "size:" "resize-pane -D %%" bind C-k command-prompt -p "size:" "resize-pane -U %%" -bind C-m command-prompt -p "move pane from:,to:" "swap-pane -s %% -t %%" +bind C-m command-prompt -p "from:,to:" "swap-pane -s %% -t %%" -# 缓存管理 +# bind C-u select-layout main-horizontal +# bind C-v select-layout main-vertical +bind C-t select-layout tiled + +bind ! select-window -t .1 +bind @ select-window -t .2 +bind '#' select-window -t .3 +bind '$' select-window -t .4 +bind '%' select-window -t .5 + +#}}} +#buffers #{{{ +bind y capture-pane bind C-s copy-mode bind C-d clear-history bind a choose-buffer bind z paste-buffer +bind -t vi-copy v begin-selection +bind -t vi-copy c copy-selection -# tmux 1.x -if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -lt '2' ]" "\ - bind -t vi-copy e scroll-down; \ - bind -t vi-copy y scroll-up; \ - bind -t vi-copy d halfpage-down; \ - bind -t vi-copy u halfpage-up; \ - bind -t vi-copy f page-down; \ - bind -t vi-copy b page-up; \ - bind -t vi-copy v begin-selection; \ - bind -t vi-copy c copy-selection; \ - bind -t vi-edit C-n history-down; \ - bind -t vi-edit C-p history-up; \ - bind -t vi-copy Space page-down; \ - set -g mouse-select-window on; \ - set -g mouse-select-pane on; \ - set -g mouse-resize-pane on; \ - " - -# tmux 2.x -if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -gt '1' ]" "\ - bind -T copy-mode-vi y send-keys -X scroll-down; \ - bind -T copy-mode-vi e send-keys -X scroll-up; \ - bind -T copy-mode-vi d send-keys -X halfpage-down; \ - bind -T copy-mode-vi u send-keys -X halfpage-up; \ - bind -T copy-mode-vi f send-keys -X page-down; \ - bind -T copy-mode-vi b send-keys -X page-up; \ - bind -T copy-mode-vi v send-keys -X begin-selection; \ - bind -T copy-mode-vi c send-keys -X copy-selection; \ - set -g mouse on; \ - " +bind -t vi-copy Space page-down +bind -t vi-copy f page-down +bind -t vi-copy b page-up +bind -t vi-copy e scroll-down +bind -t vi-copy y scroll-up +#}}} +#version greate than 2.0# {{{ +if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -gt '1' ]" "set -g mouse on" +# if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -gt '1' ]" "set -g renumber-windows on" +if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -gt '1' ]" "setw -g -q utf8 on" +if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -gt '1' ]" "set -g -q status-utf8 on" +if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -gt '1' ]" "bind -t vi-copy d halfpage-down" +if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -gt '1' ]" "bind -t vi-copy u halfpage-up" +if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -gt '1' ]" "bind -t vi-copy a append-selection" +# }}} +#version less than 2.0# {{{ +if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -lt '2' ]" "set -g mouse-resize-pane on" +if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -lt '2' ]" "set -g mouse-select-pane on" +if-shell "[ `tmux -V |cut -d' ' -f2|cut -d'.' -f1` -lt '2' ]" "set -g mouse-select-window on" +# }}} diff --git a/etc/dotsfile/.zsh_local b/etc/dotsfile/.zsh_local index 1f346427..9c0402a2 100644 --- a/etc/dotsfile/.zsh_local +++ b/etc/dotsfile/.zsh_local @@ -1,16 +1,3 @@ -export PROMPT=$LOCAL_PROMPT'%![%*]%c$ ' -export EDITOR=vim - -alias t='tmux' -alias v='vim' -alias g='git' - -bindkey -e -bindkey jk accept-line -bindkey "^N" down-line-or-beginning-search -bindkey "^P" up-line-or-beginning-search - -bindkey -M vicmd j down-line-or-beginning-search -bindkey -M vicmd k up-line-or-beginning-search - +export PROMPT='vps%![%*]%c$ ' +export GOPATH=~/etcvpn:$GOPATH