这是关于通过存储在 .mux 中的脚本配置 tmux 控制台的状态栏$HOME/.tmux.conf。当应用类似的东西时,该变量#{pane_current_path}可以访问当前目录
set -g status-left "#[fg=black]#{pane_current_path}"
set -g status-left-length 32
Run Code Online (Sandbox Code Playgroud)
但是,当它变得太长时,默认情况下会从右侧剪切,即
/the/very/long/path/to/the/current/directory/of/the/pane
Run Code Online (Sandbox Code Playgroud)
变成类似的东西
/the/very/long/path/to/the/curre
Run Code Online (Sandbox Code Playgroud)
如果只有目录的尾随名称会更好,例如
he/current/directory/of/the/pane
Run Code Online (Sandbox Code Playgroud)
如何设置?
从手册页的格式部分,您可以限制变量的长度,通过提供负长度前缀从左侧截断,如下所示:
set -g status-left "#[fg=black]#{=-32:pane_current_path}"
Run Code Online (Sandbox Code Playgroud)
我认为从 2.3 版本开始就可以使用这个功能。