Below are two very useful bash functions if you use cygwin:


ccd() { cd “`cygpath \”$1\”`”
}

explore() { explorer.exe `cygpath -d “\`pwd\`”`
}

Add these to your .bashrc file, and either restart bash or just run source ~/.bashrc

The first function ccd can be used to “cd” into a given Windows path. For example doing ccd "C:\Documents and Settings\All Users\Application Data" will figure out the equivalent cygwin based path and cd to it. Note that you have to have the double quotes around the path, otherwise bash will think of the slashes as escape characters.

The second function ‘explore’ basically opens the current working directory in Windows Explorer.

2007-2-20 Update: Added double quotes around the pwd command in explore function; without the quotes paths with spaces will not work.

Back to blog...