diff --git a/autoload/dirvish.vim b/autoload/dirvish.vim index 10d0149..792a5ee 100644 --- a/autoload/dirvish.vim +++ b/autoload/dirvish.vim @@ -5,6 +5,11 @@ let s:noau = 'silent noautocmd keepjumps' let s:cb_map = {} " callback map let s:rel = get(g:, 'dirvish_relative_paths', 0) +augroup dirvish_dummy_events + autocmd! + autocmd User Dirvish* " +augroup END + " Debug: " echo '' > dirvish.log ; tail -F dirvish.log " nvim +"let g:dirvish_dbg=1" -- b1 b2 @@ -169,6 +174,9 @@ func! dirvish#shdo(paths, cmd) abort augroup END nnoremap Z! :silent writeexe '!'.(has('win32')?fnameescape(escape(expand('%:p:gs?\\?/?'), '&\')):join(map(split(&shell), 'shellescape(v:val)')).' %')if !v:shell_errorcloseendif + + let b:dirvish_dir = escape(shellescape(head),'&\') + doautocmd User DirvishShdoCreated endf " Returns true if the buffer was modified by the user. diff --git a/doc/dirvish.txt b/doc/dirvish.txt index 56fed1b..cdc4116 100644 --- a/doc/dirvish.txt +++ b/doc/dirvish.txt @@ -126,6 +126,28 @@ dirvish#remove_icon_fn(fn_id) Unregisters the function associated with {fn_id} returned from |dirvish#add_icon_fn()|. +============================================================================== +AUTOCOMMANDS *dirvish-autocommands* + +DirvishShdoCreated *User_DirvishShdoCreated* + A |User| |autocommand| invoked after creating a |:Shdo| buffer. + b:dirvish_dir is set to the previous Dirvish buffer's path. + + To ensure scripts always cd to the current dirvish directory, you could + add this to your vimrc: > + + autocmd User DirvishShdoCreated call OnShdoCreated() + function! OnShdoCreated() abort + if has('win32') + " work across hard drives + let chdir = 'pushd ' + else + let chdir = 'cd ' + endif + call append(0, [chdir .. b:dirvish_dir, '']) + endf +< + ============================================================================== OPTIONS *dirvish-options*