40

Can anyone help me set up this configuration?

If I create a new pane, the new pane should start out in the same working directory as the pane I was just in. If I create a new window, the new window should start out in the home directory (or any other global default path).

Is this possible with tmux 1.8?

1
72

Try setting:

bind c new-window -c "#{pane_current_path}"

In my case new panes were failing as well to start in the current directory. Adding -c "#{pane_current_path}" to the split-window bindings fixed that. Example:

bind c new-window      -c "#{pane_current_path}"
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"

I found the pane_current_path trick here. It's also documented in upstream CHANGES.

3
  • 3
    For me, $PWD does not work, but #{pane_current_path} works.
    – Henry Hu
    Nov 7 '15 at 4:11
  • I don't think this answers the OP's question, because he asked whether it was possible to have new windows start in the home directory. Based on this answer and the ones considered duplicates, I thought placing bind c new-window -c "$HOME" would work, but new windows are still created in the pane_current_path
    – cbcoutinho
    Mar 24 '18 at 23:09
  • 2
    If you want to override <prefix>" you have to escape the double quote like this: bind '"' split-window -v -c "#{pane_current_path}". Hopefully saves someone some time.
    – jchook
    May 7 '20 at 0:07
8

While @mmoya's answer works for tmux version 1.9 and beyond, the -c option for new-window is not present in earlier versions. For earlier versions, this requires a bit of mucking with default-path. Here is how I have it set up in my .tmux.conf file.

set -g default-path "~"
bind % set default-path "" \; split-window -h \; set -u default-path
bind '"' set default-path "" \; split-window -v \; set -u default-path

This makes the new-window command use the global default-path. However, when splitting a window into panes, it makes a local default-path to override it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.