Question

I am using Windows gVim and I am trying to invoke commands to run on cygwin's bash. It is working, but the working directory is set to $HOME every time. Would it possible to set to the current file's directory?

I have the following line in my .vimrc:

set shell=C:/cygwin/bin/bash
set shellcmdflag=--login\ -c
set shellxquote=\"

I have the following lines in my .profile:

if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi
Was it helpful?

Solution

I think the --login does that; remove that argument and the shell will be opened in GVIM's current directory.

OTHER TIPS

You can pass the current file's directory to external commands like this:

:!ls %:p:h

See :h filename-modifiers and possibly :h shellescape().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top