tmux/.tmux.conf: 从左边截取的字符串

tmux/.tmux.conf: string cut from the left

这是关于通过 $HOME/.tmux.conf 中存储的脚本配置 tmux 控制台的状态栏。当应用类似

的内容时,变量 #{pane_current_path} 可以访问当前目录
set -g status-left "#[fg=black]#{pane_current_path}"
set -g status-left-length 32

但是,当它变得太长时,默认从右边切掉,即

/the/very/long/path/to/the/current/directory/of/the/pane

变成

/the/very/long/path/to/the/curre

如果只有目录的结尾名称会更好,例如

he/current/directory/of/the/pane

如何设置?

从手册页的 formats 部分,您可以限制变量的长度,通过提供负长度前缀从左侧截断,如:

set -g status-left "#[fg=black]#{=-32:pane_current_path}"

我认为这是从 2.3 版开始提供的。