Use msysgit/"Git for Windows" to navigate Windows shortcuts?

*ahem*

First, compile the following AutoHotkey script:

FileGetShortcut, %1%, shortcut_target
FileAppend, %shortcut_target%, *
ExitApp

Place the .EXE file in a %PATH% directory. I named mine follow.exe.

Now, you can effectively follow a Windows .LNK file in your working directory by using the following syntax:

cd `follow Shortcut.lnk`

where Shortcut.lnk's target is a valid directory.


Demonstration:

shortcut

git bash


Once you've set up your follow.exe, you can add the following shell function to your ~/.bashrc file to simplify the syntax even further. Thanks, Daniel!

function cd
{
    if [[ ".lnk" = "${1:(-4)}" && -f "$1" ]] ;
        then builtin cd "$( follow "$1" )" ;
    else builtin cd "$1" ;
    fi
}

Now, you can follow .LNK files with just cd!

cd Shortcut.lnk

Demonstration:

cd


It seems that it's not possible at this moment, and the recommended approach is to use the Junction utility:

About creating symbolic on msys

Update:

Thank you iglvzx for your answer.

However, in my case sometimes the bash autocompletion puts an / after the shortcut, like cd /f/downloads/scripts.lnk/, so I use it as an excuse to play with bash scripting and adjust your script, also checking for not acceptable shortcuts (broken or pointing to files):

cd() {

    shopt -s nocasematch

    if [[ -z "$1" ]];
        then
            echo Error: missing operand;
            return 1;
    fi;

    if [[ "$1" == "/" ]];
        then
            destination=$1;
        else
            destination=${1%/};
    fi;

    extension=${destination##*.}

    if [[ -f "$destination" && $extension == "lnk" ]];
        then

            finaldestination=`follow "$destination"`;

            if [[ -z "$finaldestination" ]];
                then
                    echo Error: invalid destination;
                    return 2;
            fi;

            if [[ -f "$finaldestination" ]];
                then
                    echo Error: destination is a file;
                    return 3;
            fi;

            builtin cd "$finaldestination";

        else
            builtin cd "$destination";
    fi;
}