自动将 tmux window 重命名为当前命令

Automatically rename a tmux window to the current command

有没有办法将当前的 运行 命令显示为 tmux window姓名?

$ python train_net.py --lr 50 -> 会导致 window 名称立即更改为 python train_net.py --lr 50

您可以更改 tmux 默认配置文件。通常它位于您的主文件夹中:~/.tmux.conf。向其中添加以下行:

set-option -g status-interval 1
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{pane_current_command}'

您可以将 automatic-rename-format 更改为您喜欢的任何内容。 pane_current_command 表示当前的 运行 命令。 然后重新启动您的 tmux 会话或:
Ctrl+b 然后 :source-file ~/.tmux.conf 在 tmux 会话中重新读取 tmux 配置文件。

请注意,如果您没有手动为它设置名称,这将自动重命名您的选项卡,如果您手动重命名它不会改变。

供将来参考:

~/.tmux.conf中添加:

set-option -g status-interval 1
set-option -g automatic-rename on
set-option -g automatic-rename-format "#(ps -f --no-headers --ppid $(tmux display-message -p #{pane_pid}) | awk '{ print substr([=10=], index([=10=],)) }') "
set-option -g history-limit 3000

然后在 tmux 控制台中 ctrl+b :source-file ~/.tmux.conf to reload