Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/option/vim/mod.ts>autoshelldir

๐Ÿ“š Standard module for denops.vim
Go to Latest
variable autoshelldir
import { autoshelldir } from "https://deno.land/x/denops_std@v5.1.0/option/vim/mod.ts";

When on, Vim will change the current working directory whenever you change the directory of the shell running in a terminal window. You need proper setting-up, so whenever the shell's pwd changes an OSC 7 escape sequence will be emitted. For example, on Linux, you can source /etc/profile.d/vte.sh in your shell profile if you use bash or zsh. For bash this should work (put it in a bash init file):

if [[ -n "$VIM_TERMINAL" ]]; then
    PROMPT_COMMAND='_vim_sync_PWD'
    function _vim_sync_PWD() {
        printf '\033]7;file://%s\033\\' "$PWD"
    }
fi

Or, in a zsh init file:

if [[ -n "$VIM_TERMINAL" ]]; then
    autoload -Uz add-zsh-hook
    add-zsh-hook -Uz chpwd _vim_sync_PWD
    function _vim_sync_PWD() {
        printf '\033]7;file://%s\033\\' "$PWD"
    }
fi

In a fish init file:

if test -n "$VIM_TERMINAL"
    function _vim_sync_PWD --on-variable=PWD
        printf '\033]7;file://%s\033\\' "$PWD"
    end
end

You can find an alternative method at terminal-autoshelldir. When the parsing of the OSC sequence fails you get E1179 .

(default off)