Diego
Diego

Reputation: 17140

Correctly passing a path from zsh (cygwin) to vim on windows

I have the following alias/function in my .zshrc to open gvim with file names as arguments.

vim() { 
    if [[ $# -ge 1 ]]; then
        gvim "$*";
    else 
        gvim;
    fi
}

It opens files in ~ just fine, but when I try to pass a path, it doesn't work. For example, from a zsh I say vim ~/dir/test1.txt (a file which exists on C:\Users\myname\dir\test1.txt) and gvim opens with the following file \c\Users\myname\dir\test1.txt [NEW DIRECTORY] which doesn't exist? How can I fix this issue?

Upvotes: 0

Views: 375

Answers (1)

artem
artem

Reputation: 51559

cygpath might help here, like this:

gvim `cygpath -w $*`

Upvotes: 2

Related Questions