Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a shortcut for typing /cygdrive/ for every path? Is it possible to alias /cygdrive/ to /cd/ for example?

share|improve this question

migrated from Oct 13 '11 at 13:44

This question came from our site for professional and enthusiast programmers.

Does ln -s cygdrive /cd not work? – grawity Oct 13 '11 at 13:48
$ man alias
     alias, unalias - create or remove a pseudonym  or  shorthand
     for a command or series of commands

They are used for commands only.

if you want to create a shortcut to /cygdrive i recommend using environment variables:
export PROJECT_DIR=/cygdrive/c/path/to/project
export c_dir=/cygdrive/c
export d_dir=/cygdrive/d

Put these into the .profile file under your home directory.

cd $c_dir
cd $d_dir
share|improve this answer
Although you can alias c:='/cydrive/c' too, it might have some unwanted side effects. – Slomojo Oct 13 '11 at 15:33

You could use : mount --change-cygdrive-prefix

For example : mount --change-cygdrive-prefix / and cd /c/ will change the working directory to /cygdrive/c/.

For permanent change (not session's change), you need to change the Windows registry.

share|improve this answer
There's no need to edit the registry. In Cygwin versions before 1.7, changing the prefix with the mount command automatically became permanent, by updating the relevant registry entry. In Cygwin 1.7, mount points are no longer stored in the registry but read from /etc/fstab. See the user manual for the format of this. – ak2 Oct 13 '11 at 15:27
This is the correct solution, supported by Cygwin, as the manual for the Cygwin mount command shows. – Andrew Schulman Nov 1 '11 at 6:53
I just added this to my .bashrc and it works great, thanks! – Mark Ransom Dec 3 '15 at 17:24

What I do is create symbolic links in the Cygwin home for those directories that I go to regularly, for example:

$ cd ~
$ ln -s /cygdrive/c/code

Then $ cd code takes me where I want to go.

share|improve this answer

Could you use tab completion? eg type cd /cy and then press TAB and it should hopefully complete to /cygdrive/

share|improve this answer
FYI zsh completion will expand cd /cy/c to cd /cygdrive/c, I think bash won't. Of course, zsh completion will do the whole path as abbreviations, e.g. cd /cy/c/prog/mi/ [TAB] reliant on unique abbreviations of course. – Slomojo Oct 13 '11 at 15:35

the following is a cygwin mount solution:

mount --change-cygdrive-prefix /

then instead of cd /cygdrive/c

cd /c

the earlier posts aliases are still useful for shortening "cd long-path" commands

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .