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

时间:2019-01-11 07:02:33

标签: console tmux

这是关于通过$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

如何设置?

1 个答案:

答案 0 :(得分:1)

在手册页的formats部分中,您可以通过提供负长度前缀来限制变量的长度,从左侧开始将其截断,如下所示:

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

我认为这可以从2.3版中获得。