gpt4 book ai didi

tmux - 如何自动将 tmux 窗口重命名为当前目录

转载 作者:行者123 更新时间:2023-12-03 07:10:10 25 4
gpt4 key购买 nike

我想让 tmux 自动使用当前工作目录(cwd)重命名窗口。默认情况下,它将选项卡/窗口命名为当前进程的名称,例如 zsh 或 vim。

当我在 tmux 中打开一个新窗口时,名称为 reattach-to-use-namespace,然后它立即切换到 zsh

tmux tabs

我使用的是 OS X 10.10.2,我使用 zshell,并且我有 tmux 1.9a。

需要明确的是,我不需要窗口名称中的整个路径,而只需要当前目录,因此例如,我想要 projectName,而不是 /Users/username/开发/项目名称

如果您想查看我当前的tmux.confhere it is .

最佳答案

tmux 2.3+ 中,b: 格式修饰符显示路径的“基本名称”(或“尾部”)。

set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path}'

man tmux 的 FORMATS 部分描述了其他修饰符,例如 #{d:} 甚至 #{s/foo/bar/:}.

<小时/>

对于 tmux 2.2 或更早版本,可以使用 basename shell 命令。

set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#(basename "#{pane_current_path}")'

关于tmux - 如何自动将 tmux 窗口重命名为当前目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28376611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com