use*_*402 2 tmux cd-command cwd
所以我试图更新我的以反映in.tmux.conf file
的更改。我已将其添加到我的conf中,但不幸的是它不起作用。我的新窗口和窗格总是从以下位置开始:-c
new-window
~/
# Saner splitting.
bind v split-window -c $PWD -h
bind s split-window -c $PWD -v
# Autorename sanely.
setw -g automatic-rename on
# Better name management
bind c new-window -c $PWD
Run Code Online (Sandbox Code Playgroud)
我的预期行为是我的新窗格或窗口将位于我之前所在的窗格的目录中。因此,如果我位于 中的窗口 1 中~/Sites/project
,我的新窗口也会在那里。
您使用了错误的示例。;) 作为$PWD
参数-c
意味着让新创建的窗格在tmux
服务器所在的目录中启动,换句话说,就是您第一次启动的目录tmux
。当前窗格的目录是存储在tmux
内部变量中的目录#{pane_current_path}
:
* 'default-path' has been removed. The new-window command accepts '-c' to
cater for this. The previous value of "." can be replaced with: 'neww -c
$PWD', the previous value of '' which meant current path of the pane can
be specified as: 'neww -c "#{pane_current_path}"'
Run Code Online (Sandbox Code Playgroud)
所以做你想做的事情的正确方法是
# Saner splitting.
bind v split-window -c "#{pane_current_path}" -h
bind s split-window -c "#{pane_current_path}" -v
# Autorename sanely.
setw -g automatic-rename on
# Better name management
bind c new-window -c "#{pane_current_path}"
Run Code Online (Sandbox Code Playgroud)
注意:如果您当前的窗格中正在运行其他人的 shell,则这将不起作用sudo
(我对此感到困惑,所以我明确地告诉您):如果您正在运行或su
会话,那么您的新窗格将最终得到一个工作目录的/
。这很容易解释:您tmux
无法获取正在运行的进程的当前工作目录,因为出于安全原因它没有适当的权限来执行此操作(您无法读取外部用户进程的重要状态)。