[20170926]关于linux重定向.txt

本文介绍如何利用tmux的synchronize-panes功能在多个窗格中同时执行相同命令,以及通过共享会话来协作解决问题的方法。

[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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值