Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
in vifm by

Hi there, I'm using vifm and when I want to open up a new terminal pane with the terminal Ghostty, it doesn't open it in the current vifm working directory. In other terminals (like kitty or WezTerm), if I use the associated split function, it would open up a pane in the current vifm directory.

Also in vifm, if I start :shell which opens to a terminal, and then open up a new pane with Ghostty, it won't be in the current directory; I have to use cd for it to split in the CWD. Why is that?

Someone on the Ghostty Discord asks if vifm supports OSC 7 and I'm assuming yes? This can't be an issue with vifm, right?

Thank you!

1 Answer

0 votes
by

Hello.

Looks like Ghostty relies exclusively on OSC 7 of which I've never heard before. Neither Vifm nor shells use it, so you get "wrong" working directory. tmux and other terminals just look at /proc/<PID>/cwd which works with any application.

You can try adding something like this to your Vifm configuration:

autocmd DirEnter * :!printf '\033]7;file:///%%s\033\\' %d > /dev/tty %i

It has high chance of working to some extent, but I haven't tested it. Also if it's really a URL, then a proper URL encoding is likely necessary (otherwise spaces, percents and non-latin characters can cause problems).

by

Thank you so much for this, xaizek. I needed to tweak it a bit and add a hostname:

autocmd DirEnter * :!printf '\033]7;file://ubuntu/%%s\033\\' %d > /dev/tty %i
by

Hello xaizek, for some reason this doesn't work with %i in the latest version: 0.14. I tried it with the ubuntu repo version 0.12 and it works. This is the command:

au DirEnter * :!printf '\033]7;file://localhost/%%s\033\\' %d %i > /dev/tty

Thank you

by

Hi, you're right, it stopped working in v0.12.1, thanks for pointing that out.

Implementation of %i used to differ from %i &, but the former broke some commands and I made them act the same in v0.12.1 without foreseeing the breakage. Currently %i doesn't take %N into account (this macro keeps terminal available for viewers that need it) but I guess it should.

I don't like incompatible changes but since it's already broken for 2.5 years and nobody has reported it until now might as well require adding %N to get the same behaviour in newer versions. I'm considering starting doing proper bugfix releases, so %i %N might be available relatively soon in v0.14.1.

by

Changed my mind, the behaviour prior to v0.12.1 is restored by this commit, so %i will work as it used to.

by

I appreciate your work, thanks so much!

...