Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change working directory on exit? #617

Open
Oneechan69 opened this issue Dec 12, 2024 · 4 comments
Open

Change working directory on exit? #617

Oneechan69 opened this issue Dec 12, 2024 · 4 comments

Comments

@Oneechan69
Copy link

I want my cwd in nvim to change when I press q in Yazi.nvim, I only quickly looked here but is this possible?

@Oneechan69 Oneechan69 changed the title Changing working directory on exit? Change working directory on exit? Dec 12, 2024
@mikavilpas
Copy link
Owner

Hi, this is not currently supported. As a workaround you can maybe use the keymaps.change_working_directory key before you quit yazi.

I could see if I can implement this in the future, so let's keep this open until then.

@mikavilpas
Copy link
Owner

I remembered that this was also discussed in #83

It seems to have a custom implementation that you could try using in your own config, if you want to have something working for yourself until I implement this.

mikavilpas added a commit that referenced this issue Dec 13, 2024
Some users have a workflow where they change the cwd a lot. This feature
adds an option to change neovim's cwd to the directory that was last
open when yazi was closed.

To opt in to this feature, set the `change_cwd_on_exit` option to
`"always"` in your yazi config. You can see an example in the README
file.

Right now only "always" is supported, which means the cwd is always
changed regardless of whether files were opened or not, but in the
future we might add more options.

Related issues and discussions:
- #617
- #83
- #95
@mikavilpas
Copy link
Owner

Hmm, I implemented this in a naive way but I don't think it's going to work. The issue is that while I can change the cwd easily, many yazi.nvim keymappings also close yazi, and I can't make a distinction between the user quitting yazi, and some command quitting yazi. The cwd should only be changed if the user presses q or whatever key they have mapped for yazi to quit.

I'll have to think of another way and maybe discuss this with sxyazi.

@sxyazi
Copy link

sxyazi commented Jan 7, 2025

If I understand correctly, you're looking for yazi --cwd-file.

No matter if the user exits Yazi through custom keys or default keys, Yazi will write the last CWD to the file specified by --cwd-file.

So, you can pass it when starting Yazi, just like how the shell wrappers do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants