Skip to content

Instantly share code, notes, and snippets.

@aminamid
Last active August 29, 2015 14:17
Show Gist options
  • Save aminamid/63fd38e91725a9e578e3 to your computer and use it in GitHub Desktop.
Save aminamid/63fd38e91725a9e578e3 to your computer and use it in GitHub Desktop.
tmux_tips
## multisessions
http://tech.naviplus.co.jp/2014/01/09/tmux%E3%81%A7%E8%A4%87%E6%95%B0%E3%82%B5%E3%83%BC%E3%83%90%E3%81%AE%E5%90%8C%E6%99%82%E3%82%AA%E3%83%9A%E3%83%AC%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3/
switch sync/async
```
set-window-option synchronize-panes on
set-window-option synchronize-panes off
```
Assign key for sync/async
```
bind e setw synchronize-panes on
bind E setw synchronize-panes off
```
```
mssh()
{
if [ -n "$SESSION_NAME" ];then
session=$SESSION_NAME
else
session=multi-ssh-`date +%s`
fi
window=multi-ssh
### tmuxのセッションを作成
tmux new-session -d -n $window -s $session
### 各ホストにsshログイン
# 最初の1台はsshするだけ
tmux send-keys "ssh $1" C-m
shift
# 残りはpaneを作成してからssh
for i in $*;do
tmux split-window
tmux select-layout tiled
tmux send-keys "ssh $i" C-m
done
### 最初のpaneを選択状態にする
tmux select-pane -t 0
### paneの同期モードを設定
tmux set-window-option synchronize-panes on
### セッションにアタッチ
tmux attach-session -t $session
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment