[size=medium]As we know the symbol link command 'ln' in MinGW is fake that it creates copy instead of real link in *nix file system.[/size]
[size=medium]A good news is on Win7 its new NTFS support symbol link feature! With "mklink" command in Windows Command Prompt, we could easily do so like below:[/size]
[size=medium]So it won't be hard to implement a "mklink" for MinGW like below:[/size]
[size=medium][color=red]Please be noted that according to [url=http://superuser.com/questions/167076/windows-7-delete-symbolic-link]this article[/url] if you want to remove a directory symbol link in Win7 you should only use 'rmdir' (both available in CMD and MSYS). The 'del' command in CMD will delete all your files in the source directory!!![/color][/size]
[b][size=medium]A typical use case[/size][/b]
[size=medium]You have created your awesome .vimrc and .vim in MSYS and you want to re-use them in gvim:[/size]
[size=medium]A good news is on Win7 its new NTFS support symbol link feature! With "mklink" command in Windows Command Prompt, we could easily do so like below:[/size]
mklink [/d] link target
[size=medium]So it won't be hard to implement a "mklink" for MinGW like below:[/size]
#!/bin/bash
#####################################################
#
# (c) Copyright 2012 Clark. All Rights Reserved.
# 2012-08-29
#
#####################################################
Usage() {
cat<<EOF
mklink [-d][ -z "$2" ][ "$3" != "" && "$1" != "-d" ][ "$3" != "" ][ "${TARGET:0:1}" == "/" ]; then
ROUTE=$(echo "$TARGET" | sed 's,^/\([c-z][ "$ROUTE" == "$TARGET" ]; then
ROUTE=$(echo "$3" | sed 's,^/,'$MSYS',')
fi
else
ROUTE="$TARGET"
fi
ROUTE=$(echo "$ROUTE" | sed 's,/,\\,g')
CMD=$(echo mklink $ISDIR $LINK \"$ROUTE\")
#echo $CMD
cmd /c "$CMD"
[size=medium][color=red]Please be noted that according to [url=http://superuser.com/questions/167076/windows-7-delete-symbolic-link]this article[/url] if you want to remove a directory symbol link in Win7 you should only use 'rmdir' (both available in CMD and MSYS). The 'del' command in CMD will delete all your files in the source directory!!![/color][/size]
[b][size=medium]A typical use case[/size][/b]
[size=medium]You have created your awesome .vimrc and .vim in MSYS and you want to re-use them in gvim:[/size]
cd "$USERPROFILE"
# below 2 links makes your Windows gvim load resource directly from
# you MSYS configurations.
mklink /c/MinGW/msys/1.0/home/user/.vimrc _vimrc
mklink /c/MinGW/msys/1.0/home/user/.vim vimfiles.
# and if you want to invoke gvim from MSYS
cd ~
mklink .vim vimfiles
# a link for _vimrc is not necessary
alias gvim="/c/Program\ Files\ \(x86\)/Vim/vim73/gvim.exe"
# to start gvim in background
gvim <FILENAME> &