浏览代码

feat(tmux): 新增隐私模式,方便截屏

dzp 3 年之前
父节点
当前提交
6e090e51d2
共有 3 个文件被更改,包括 23 次插入4 次删除
  1. 1 0
      Dockerfile
  2. 2 0
      bin/start
  3. 20 4
      tmux.conf

+ 1 - 0
Dockerfile

@@ -68,5 +68,6 @@ COPY --from=0 /vim-startify /paotin/.local/share/nvim/plugged/BufExplorer/
 COPY --from=0 /tintin/src/tt++ /paotin/bin/
 
 RUN mkdir -p /paotin/log/
+RUN mkdir -p /paotin/tmux/
 
 ENTRYPOINT ["/bin/bash", "-i", "/paotin/bin/start-ui"]

+ 2 - 0
bin/start

@@ -36,4 +36,6 @@ fi
 $ECHO "\x1b[1;32m启动 tintin...\x1b[0m"
 $ECHO "\x1b[1;32m$TT $START_FILE\x1b[0m"
 
+mkdir -p tmux/$ID
+
 $TT -G -t GAME-$ID $START_FILE

+ 20 - 4
tmux.conf

@@ -74,10 +74,6 @@ set -g message-style fg=brightyellow,bold,bg=red
 set -g display-time 1000
 # }}}
 
-########## 窗口管理 ---{{{
-set -g detach-on-destroy off
-### }}}
-
 ########## 窗口管理 ---{{{
 #
 # 窗口的索引值从 0 开始
@@ -85,6 +81,8 @@ set -g base-index 0
 # 关闭中间的会自动重新编号
 # set -g renumber-windows on
 
+set -g detach-on-destroy off
+
 # 类似于 screen,用 Ctrl+C 创建窗口,故意映射两组,防止按错
 bind-key C-c new-window -c '#{pane_current_path}'
 bind-key c new-window -c '#{pane_current_path}'
@@ -104,6 +102,24 @@ bind-key C-a last-window
 # 显示所有窗口,以供跳转
 unbind-key l
 bind-key l choose-window
+
+bind-key k if-shell 'rm tmux/secret 2>/dev/null && exit 0 || touch tmux/secret && exit 1' {
+setw -g window-status-format '#[fg=green]#I-#(tmux-ui WIN #{pane_title})#[default]'
+} {
+# 但如果是隐私模式则只显示星号
+setw -g window-status-format '#[fg=green]#I-****#[default]'
+}
+
+bind-key K if-shell 'rm tmux/secret 2>/dev/null && exit 0 || touch tmux/secret && exit 1' {
+setw -g window-status-format '#[fg=green]#I-#(tmux-ui WIN #{pane_title})#[default]'
+setw -g window-status-current-format '#[fg=brightyellow]#I-#(tmux-ui WIN #{pane_title})#[default]'
+set -g pane-border-format '#(tmux-ui PANE #{pane_title} #{pane_active} #{pane_width})'
+} {
+# 但如果是隐私模式则只显示星号
+setw -g window-status-format '#[fg=green]#I-****#[default]'
+setw -g window-status-current-format '#[fg=brightyellow]#I-****#[default]'
+set -g pane-border-format ''
+}
 # }}}
 
 ########## 面板管理 ---{{{