Symbol Link in MSYS on WIN7


詳細
As we know the symbol link command 'ln' in MinGW is fake that it creates copy instead of real link in *nix file system.
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:
mklink [/d] link target

So it won't be hard to implement a "mklink"for MinGW like below:
#!/bin/bash

#####################################################
#
# (c) Copyright 2012 Clark. All Rights Reserved.
# 2012-08-29
#
#####################################################

Usage() {
cat< 
 

Please be noted that according to this article 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!!!

A typical use case

You have created your awesome .vimrc and .vim in MSYS and you want to re-use them in gvim:
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  &