[20170926]关于linux重定向.txt
--//昨天看Pragmatic.Bookshelf.tmux.2.Productive.Mouse-Free.Development.1680502212.pdf
--//以前没看完,继续不看.在P100页:
Issuing Commands in Many Panes Simultaneously P100
Every once in a while, you might need to execute the same command in multiple panes. You might
need to run the same update script on two servers, for example. You can do this easily with tmux.
Using the command set-window-option synchronize-panes on, anything you type in one pane will be
immediately broadcast to the other panes in the current session. Once you've issued the command,
you can turn it off with set-window-option synchronize-panes off.
To make this easier to do, you can map this to PREFIX CTRL - s , like this:
workflows/tmux.conf
# shortcut for synchronize-panes toggle
bind C-s set-window-option synchronize-panes
--//这样可以实现开关功能.按PREFIX(可以自己定义缺省ctrl+b) + CTRL+s.
By not specifying the off or on option, the synchronize-panes command acts as a toggle. While this isn't
something you'll use very often, it's amazingly handy when you need it.
--//这样可以实现在多个panes上执行相同的命令.真不知道多少管理员有这样需求.
--//还可以看 [20170711]关于tmux共享会话问题.txt
--session 1 :
$ tmux new-session -s groupedsession
--session 2 :
$ tmux new-session -t groupedsession -s mysession
--//这样session 1 连接使用
$ tmux attach -t groupedsession
--//这样session 2 连接使用
$ tmux attach -t mysession
--//这样约定好那些窗口session 1使用,那些窗口session 2使用,就不存在冲突了.
--//当然你可以看到别人的操作,这对于协调解决问题也许有用.
--//如果想在现实在另外的窗口现实结果,可以这样操作:
--//session 1:
# tty
/dev/pts/7
--//session 2:
# tty
/dev/pts/8
# script /dev/null | tee -a /dev/pts/7
--//这样在session 2上的操作会显示在session 1的界面上.
--//不过这样操作非常让人迷惑,我简单演示看看:
--//session 1:
# cd /home/oracle
# pwd
/home/oracle
--//session 2:
# cd /tmp
# pwd
/tmp
--//你可以发现session 2 的执行结果在session 1上显示,在session 1上而实际上当前的目录还是/home/oracle:
--//session 2上的显示如下:
[root@xxxdg4 IP=100.78 /home/oracle 10]# cd /tmp
[root@xxxdg4 IP=100.78 /tmp 16]# pwd
/tmp
[root@xxxdg4 IP=100.78 /tmp 17]# pwd
/home/oracle