天天看点

[20141225]学习使用tmux心得.txt

[20141225]学习使用tmux心得.txt

--前一段时间由于工作需要,学习使用tmux。

tmux is a "terminal multiplexer". It allows a number of terminals (or windows) to be accessed and controlled from a

single terminal. It is intended to be a simple, modern, BSD-licensed alternative to programs such as GNU screen.

--实际上我一直没心思学习使用它,开始来源一次升级数据库操作,对方给我的执行命令expdp前面加入nohup 后面还加了&.

--我感觉没有必要,按照对方的说法就是害怕网络断开,实际上在screen使用就可以,我以前就是这样用(很少).

--对方给我提到了tmux,终端复用软件,我感觉这个比较复杂,一直没时间学习使用。

--我开始google寻找这方面的资料,看到别人的截图确实有学习的冲动。

--随后开始泄气,tmux的按键太复杂了,概念panel,windows这些还好理解,操作还是不习惯。

--后面我想我不就是按照以前使用screen的时候来使用吗?就把它当作shell来用,开一个窗口来使用。那些按键可以以后慢慢熟悉。剩

--下的就简单了,一边用一边学,一个软件天天用,自然会上手的。

--最后我想谈谈一些使用心得:

1.关于prefix key:

prefix key 的缺省定义是ctrl-b,实际上有一些修改成ctrl-a或者ctrl-x,主要是无论如何定义基本都会有冲突,我自己也纠结很久。

ctrl-b 在vim下是上翻页,在shell下是向前移动1格。

ctrl-a 在vim下(linux)是给一个数字做加法。在shell下移动到开始。

ctrl-x 在vim下(linux)是给一个数字做减法。在shell下ctrl+x 再加上键是删除当前位置到开始的内容。

--我最终选择了ctrl-a作为prefix key。

2.关于其他组合键的定义:

--我个人认为最好还是不要改,保持原样。最多根据自己的需要定义一些快捷键。

最终我的tmux.conf配置很简单:

#

# author   : lfree

# modified : 2014/12/05

#-- bindkeys --#

set -g prefix ^a

unbind ^b

bind a send-prefix

# vertical split (prefix x)

unbind '"'

bind -n ^x splitw -v

# horizontal split (prefix |)

unbind %

bind -n ^y splitw -h

# Pane switching with Alt+arrow

# 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

# Activity Monitoring

setw -g monitor-activity on

set -g visual-activity on

# switch window

bind -n C-n next-window

#Highlighting Current Window Using Specified Colour

set-window-option -g window-status-current-bg black

set-window-option -g window-status-current-fg red

#set-window-option -g window-status-fg red

#set-window-option -g window-status-bg black

#set-option -g status-bg white

#set-option -g status-fg blue

#Pane Switching Using Mouse

#set-option -g mouse-select-pane on

#set-option -g mouse-resize-pane on

# reload tmux configuration

#bind r source-file ~/.tmux.conf \; display "Reloaded!"

--说明大部分我都注解掉了,我仅仅定义ctrl-x 水平分割,ctrl-y 垂直分割,ctrl-n 选择写一个窗口,

--现在仅仅记住一个命令 前缀键 c => 打开新窗口。

--剩下的以后慢慢学习。