0

I have this setting, which is supposed to rename the current window to my current directory by pressing <prefix>.

bind-key . run -b "tmux rename-window $(basename #{pane_current_path})"

For some reason it doesn't work. At the moment it gives me a 127 error. I tried replacing basename with /usr/bin/basename but that didn't help either. I don't know what I'm doing wrong at this point...

0

Edit: My original answer was incorrect, and worked as a fluke. Kamil's comment below prompted me to reconsider.

The below commands work for me, including paths with spaces in them.

bind-key . run -b 'tmux rename-window "`basename \"#{pane_current_path}\"`"'

or

bind-key . run -b 'NEWNAME="#{pane_current_path}"; tmux rename-window "${NEWNAME####*/}"'

  • I had similar thoughts. Then I checked the OP's original code – and it works for me (Ubuntu 14.04.4 LTS, tmux_1.8-5_amd64.deb). It is not perfect, there may be some problems if there is a space within directory name (proper use of \" fixes that); but I couldn't reproduce the OP's error. Your version also works for me. I wonder how it behaves in OP's environment. – Kamil Maciorowski Jul 16 '16 at 16:51
  • Indeed OP's original command works for me (tmux 2.2 on OSX). I never tried it! That mine works is a bit a fluke. According the man, run-shell already does variable substituion. – Satya Mishra Jul 16 '16 at 18:24
  • This still gives me a 127 error. It's not like this is the only statement in the configuration file, but this one is the only that gives me such an error. – hgiesel Jul 18 '16 at 9:12
  • @hgiesel Which locale are you using? Perhaps it's a Unicode handling problem? Could you give an example of a path that generates the error? – Satya Mishra Jul 18 '16 at 14:32
  • @SatyaMishra I can even go to root and it will still throw that error – hgiesel Jul 18 '16 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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