tmux 使用

来源:互联网 发布:基金估值的算法 编辑:程序博客网 时间:2024/05/29 04:46

参考
参考
快捷键
解决终端不能多开。
基本需要掌握的就是 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" insave | restore )  $1  ;;* )  echo "valid commands: save, restore" >&2  exit 1esac

screen

vbell offdefscrollback 8192caption always "%{wb} %-w%{+b bw}%n %t%{-}%+w”screen 乱码 输入命令 ^a shift+;  encoding gbk utf8ctrl +a a 至前screen -D -RR bingone  -c .screen.bingone-D -RRNote: It is always a good idea to check the status of your sessions by means of "screen  -list".
0 0
原创粉丝点击