4

Using split-window & new-window in tmux to create new panes & windows seems to be ignoring any use of the -c (start-directory) flag.

I've tried binding this to % in my ~/.tmux.conf & manually entering it as a command inside tmux at the prompt by hitting prefix :.

My intention is to set it to always use my current $PWD by binding the keys like this:

unbind %
bind % split-window -h -c "#{pane_current_path}"

unbind '"'
bind '"' split-window -h -c "#{pane_current_path}"

but it doesn't seem to matter what argument I pass to -c, tmux just opens the new pane or window at my home directory.

I'm running tmux v2.6 on Ubuntu 18.04 accessed via ssh. Here's the contents of my /home/andrew/.tmux.conf file:

# bind new panes to same path as active pane

# horizontal split
unbind %
bind % split-window -h -c "/home/andrew/dev/py-spec" # I've also tried "#{pane_current_path}" here as well, but neither works

# vertical split
unbind '"'
bind   '"' split-window -v -c "/home/andrew/dev/py-spec" # I've also tried "#{pane_current_path}" here as well, but neither works
9
  • These bindings are working fine for me! what version of tmux are you using? I'm on v2.6.
    – Attie
    Feb 18, 2019 at 18:03
  • $ tmux -V returns tmux 2.6, so we're the same version. I'm accessing the ubuntu computer with tmux on it over ssh; could that somehow make a difference? Feb 18, 2019 at 18:06
  • It shouldn't... unless you're unable to type % and " correctly.
    – Attie
    Feb 18, 2019 at 18:10
  • I've tried bind-key as well; I can't even get it to recognize anything when I manually give the split-window -h -c '/some/path/here' command in the prompt too by hitting Ctrl-B, then :. Feb 18, 2019 at 18:11
  • Yeah, that's what I'm using. Sorry, I wasn't sure what syntax to say I was using that key combination. Feb 18, 2019 at 18:15

1 Answer 1

3

Finally figured out my problem, I'm putting it here just in case if anyone else makes the same mistake I did.

Turns out my .bashrc was always changing the directory back to home here:

# reset current directory to $HOME
cd

I have no idea why I ever stuck that line in there, but removing it fixed the problem.

Thanks to @Attie for all the help troubleshooting!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .