<>

Shortcut for switching to a Windows directory in Cygwin

January 1, 2010

In cygwin it can be a pain to change to a Windows directory like C:\Users\breck\Documents\My Dropbox.

I made a small bash script called wcd that makes it easier.

wcd

#!/bin/bash echo $1 newpath=$(echo $1 | sed 's|\\|/|g' | sed 's|:||g' | sed 's|^C|/cygdrive/c|') echo $newpath cd "$newpath"

The echos are just for debugging--I'm kind of new to bash scripting. Feel free to remove.

Make this file executable and add an alias into your bash_profile:

alias wcd="source ~/wcd"

Now you can just type(or actually copy/paste) something like this:

wcd "C:\Users\breck\Documents\My Dropbox"

...and that will take you to the Windows directory.

Notes

  1. wcd gist.



Built with Scroll v164.7.0