mcchrish/nnn.vim

nnn changes the vim PWD to the directory which it quitted

Closed this issue · 8 comments

Describe the bug

As the title, the PWD in the session will be changed if I quit at the other directory rather than the started one.

This is my config

Plug 'mcchrish/nnn.vim'
let g:nnn#command = 'n'
nnoremap <leader>n :NnnPicker %:p:h<CR>
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.7, 'highlight': 'Debug' } }
let g:nnn#action = {
      \ '<c-t>': 'tab split',
      \ '<c-x>': 'split',
      \ '<c-v>': 'vsplit' }

in my case, i need to source a bash environment in vim as my nnn is prebuilt one as following

let $BASH_ENV="~/.vim/vim_bash"

and then the vim_bash file


nnn(){
    # Block nesting
    if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
            echo "nnn is already running"
            return
    fi

    # Start nnn with your preferred options
        $Linuxtools/nnn/nnn-nerd-static "$@"

}
alias n=nnn

What version of nnn.vim are you using? Do you see still see the issue when using older versions?

I'm using 4.2 in both mac and ubuntu. I will check the older version later.

Currently my procedure using nnn.vim is to press n then do some actions in nnn (move, delete, etc..). After that I go back to the original directory before pressing "q".

How about the version of this plugin, are you using the master branch?

Strangely enough, this bug is actually a feature I want to implement 😄. Being able to use nnn to change vim's pwd just like netrw.

I'm using this version in ubuntu 20.04
https://github.com/jarun/nnn/releases/download/v4.2/nnn-icons-static-4.2.x86_64.tar.gz

The thing is when I use nnn in the terminal, pressing 'q' will quit to the original directory.
There is probably some differences in vim environment.

I can also reproduce this on master nnn.vim and NVIM v0.6.0-dev+276-g685cf3981. I don't use nnn sessions either.

Well seems this mechanism is implemented and merged for quite a while (wasn't aware at that time). Seem to be undocumented: #70

It should only work with <c-g> though not q.

I'm guessing it's either some configuration that's causing this or a bug in nnn.

jarun commented

It would also happen with q if NNN_TMPFILE is exported before calling nnn.

See the in-file doc: https://github.com/jarun/nnn/blob/master/misc/quitcd/quitcd.bash_zsh

jarun commented

Closing as no response from submitter.