views:

31

answers:

2

Hello,

Just wanted to know if it is possible to switch to an aliased directory using shell script.

To switch to a directory there is cd command. But i have aliased the directory and wanted to know as how to switch to the aliased directory.

Could someone please help me?

A: 

If you aliased the directory with a symlink pointing to it, cd will work fine.

If you used the alias command, well, that's not the way to do it.

Frédéric Hamidi
The directory does point to the Original directory, but if the do cd, it tells me that it is not a directory.
Does your symlink point to the absolute path of the original directory? Can you `ls -l` the symlink and `ls -ld` the original directory and post the result?
Frédéric Hamidi
I have 2 directories, one is the original directory and the other is an alias to the original directory. The alias directory was created by right clicking on the original directory and choosing 'Make Alias' from the Contextual menu. Now, i want to list the contents of the alias directory.
You mean that's a [MacOS alias](http://en.wikipedia.org/wiki/Alias_%28Mac_OS%29)? Sorry, I don't know those... they should *just work*, though ;) Seriously, they probably don't work with the shell, like the `.lnk` shortcuts on Windows.
Frédéric Hamidi
A: 

An alias is meant to be a shortcut for a command.

You can't cd to an aliased directory.

But if you have a variable referencing that directory, you can. e.g.

dev="/path/to/my/dev"    
cd $dev

Or set up an alias to cd to the directory:

alias dev='cd /path/to/my/dev'
dogbane
I am using Mac OS and i have created an alias of a directory by right clicking on the directory and choosing Make Alias menu. Now, i want to cd the aliased directory which i am unable to do.
I tried assigning the path of the aliased directory to a variable and then cd it. But its still not working.