Closed mroavi closed 4 years ago
After looking into this issue, I narrowed down that the root problem of why the cd on quit functionality is not working is because the ~/.config/nnn/.lastd file is not being written when the env variable NNN_TMPFILE
is defined. I will close this issue and open a new cleaner one describing this root problem.
Describe the bug
I cannot get the cd on quit functionality to work with the vim plugin.
I followed the steps described here: https://github.com/jarun/nnn/wiki/Basic-use-cases#configure-cd-on-quit
I made sure this works when starting nnn (via n) directly from the terminal.
In my init.vim I added the following configuration:
When I run
:NnnPicker
I get the following error:Apparently, the nnn vim-plugin doesn't like ZSH functions.
My next attempt was to move the contents of the
n
function into a separate bash file and placed it in my ~/.local/bin which is in myPATH
env variable. This didn't work even when starting it from the terminal: whenever I quit (with or without ^G) the cd does not happen.Any ideas on how to support cd on quit inside vim's nnn plugin?
Update 1: I kept googling and now I understand why the bash file approach doesn't work: you cannot change directory from a child process. One suggested solution to this problem is to source the script (
. n
) instead of executing it directly. Doing this now I can actually cd on quit from nnn using then
bash script. So then I went back to vim to modify the nnn command to:Now nnn starts successfully but the cd on quit functionality still does not work. I suspect that the reason why the cd on quit functionality does not work with the vim plugin has the same root as the problem described above: child processes not being able to make their parents to cd.
Update 2: I tried the following command to start nnn:
However, I noticed that the .lastd file is not being generated after exiting. Any idea why?
PD: I wasn't sure whether to mark this as an enhancement or a bug. Please feel free to modify it if you consider this an enhancement rather than a bug.