tmux 使用

参考
参考
快捷键
解决终端不能多开。
基本需要掌握的就是 session、window、panel的增、删、查看、切换


tmux所有自带命令都默认需要先按Ctrl + b,然后再键入对应的命令
tmux ls -查看所有session,attach是可连接
tmux attach-session -t name - 连接name会话
tmux new -s name - 创建name session
关闭session 就是窗口全部关闭 (一直ctrl + d)
ctrl+b s 查看切换session(在tmux中)
ctrl+b d 挂起会话,还可切换回来


----------


Ctrl+b c - (c)reate 生成一个新的窗口
Ctrl+b w - (w)indow 查看所有窗口可切换
Ctrl+b " - split pane horizontally水平划分
Ctrl+b % - 将当前窗格垂直划分
Ctrl+b 方向键 - 在各窗格间切换
Ctrl+b,并且不要松开Ctrl,方向键 - 调整窗格大小
Ctrl+b n - (n)ext 移动到下一个窗口
Ctrl+b p - (p)revious 移动到前一个窗口.
Ctrl+b 空格键 - 采用下一个内置布局 
Ctrl+b q - 显示分隔窗口的编号 
Ctrl+b o - 跳到下一个分隔窗口 
Ctrl+b & - 确认后退出 tmux 

tmux 序列化
参考
参考

#!/usr/bin/env bash
# Save and restore the state of tmux sessions and windows.
# TODO: persist and restore the state & position of panes.
set -e # 出现错误直接终止程序

dump() {
  local d=$'\t' #等于local d=$(echo -e "\t") 或者ctrl+v+tab输出tab
  tmux list-windows -a -F "#S${d}#W${d}#{pane_current_path}"
}

save() {
  dump > ~/.tmux-session
}

terminal_size() {
  stty size 2>/dev/null | awk '{ printf "-x%d -y%d", $2, $1 }'
}

session_exists() {
  tmux has-session -t "$1" 2>/dev/null
}

add_window() {
  tmux new-window -d -t "$1:" -n "$2" -c "$3"
}

new_session() {
  cd "$3" &&
  tmux new-session -d -s "$1" -n "$2" $4
}

restore() {
  tmux start-server
  local count=0
  local dimensions="$(terminal_size)"

  while IFS=$'\t' read session_name window_name dir; do
    if [[ -d "$dir" && $window_name != "log" && $window_name != "man" ]]; then
      if session_exists "$session_name"; then
        add_window "$session_name" "$window_name" "$dir"
      else
        new_session "$session_name" "$window_name" "$dir" "$dimensions"
        count=$(( count + 1 ))
      fi
    fi
  done < ~/.tmux-session

  echo "restored $count sessions"
}

case "$1" in
save | restore )
  $1
  ;;
* )
  echo "valid commands: save, restore" >&2
  exit 1
esac

screen


vbell off
defscrollback 8192
caption always "%{wb} %-w%{+b bw}%n %t%{-}%+w”

screen 乱码 
输入命令 ^a shift+;  encoding gbk utf8
ctrl +a a 至前
screen -D -RR bingone  -c .screen.bingone
-D -RR
Note: It is always a good idea to check the status of your sessions by means of "screen  -list".
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值