I use msysgit on Windows to use git, but I often want to navigate through a Windows-style *.lnk
shortcut. I typically manage my file structure through Windows' explorer, so using a different type of shortcut (such as creating hard or soft link in git) isn't feasible. How would I navigate through this type of shortcut?
For example:
PCUser@PCName ~
$ cd Desktop
PCUser@PCName ~/Desktop
$ ls
Scripts.lnk
PCUser@PCName ~/Desktop
$ cd Scripts.lnk
sh.exe": cd: Scripts.lnk: Not a directory
Is it possible to change this behavior, so that instead of getting an error, it just goes to the location of the directory? Alternatively, is there a command to get the path in a *.lnk
file?
EDIT: I've heard that the inverse of this exists for cygwin, allowing you to create a symlink which works with explorer.
Best Answer
*ahem*
First, compile the following AutoHotkey script:
Place the
.EXE
file in a %PATH% directory. I named minefollow.exe
.Now, you can effectively follow a Windows
.LNK
file in your working directory by using the following syntax:where
Shortcut.lnk
's target is a valid directory.Demonstration:
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!Now, you can follow
.LNK
files with justcd
!Demonstration: