I'm trying to figure out how to tell the shell (tcsh) to remember when I've gone into a symlinked folder, and allow 'cd ..' to navigate back out of the symlink rather than just navigate to the parent directory of the linked-to folder...

For example:

$ ls -al /jobs
tech -> /mnt/projects1/tech
temp -> /mnt/projects2/temp

$ cd /jobs/tech
$ cd ../temp
../temp: No such file or directory.

$ pwd
/mnt/projects1/tech

Any idea how to do this? I have a feeling that it's a shell setting that you can set somewhere....

Cheers

link|improve this question

75% accept rate
updated my answer to be probably more what you're looking for...haven't tested it yet – aking1012 Dec 10 '10 at 13:39
feedback

2 Answers

up vote 2 down vote accepted

if you don't have to do it for more than one "step" you could use cd - instead

so it looks like setting the symlink env variable to ignore might get your desired response
from the man page:
"symlinks (+) Can be set to several different values to control symbolic link (`symlink') resolution:

           If  set to `chase', whenever the current directory changes to a
           directory containing a symbolic link, it  is  expanded  to  the
           real name of the directory to which the link points.  This does
           not work for the user's home directory; this is a bug.

           If set to `ignore', the shell  tries  to  construct  a  current
           directory relative to the current directory before the link was
           crossed.  This means that cding through  a  symbolic  link  and
           then  `cd  ..'ing  returns one to the original directory.  This
           affects only builtin commands and filename completion.

           If set to `expand', the shell tries to fix  symbolic  links  by
           actually  expanding arguments which look like path names.  This
           affects any command, not just  builtins.   Unfortunately,  this
           does  not  work  for hard-to-recognize filenames, such as those
           embedded in command options.  Expansion  may  be  prevented  by
           quoting.  While this setting is usually the most convenient, it
           is sometimes misleading and sometimes confusing when  it  fails
           to  recognize  an argument which should be expanded.  A compro-
           mise is to use `ignore' and use the editor  command  normalize-
           path (bound by default to ^X-n) when necessary.

           Some  examples  are  in  order.   First, let's set up some play
           directories:

"

link|improve this answer
That's been my method so far, but it's not an ideal workflow... – Hugh Dec 10 '10 at 13:31
I think we both found the same answer at the same time there! :D – Hugh Dec 10 '10 at 13:40
looks like, give yourself the check – aking1012 Dec 10 '10 at 13:41
Nah, it's yours... I should have done a search through the manpage before posting on here in the first place... Cheers! – Hugh Dec 10 '10 at 20:31
feedback

I think I've just managed to answer my own question here, at least for tcsh, anyway...

On the tcsh manpage, it talks about the 'symlinks' variable...

So, I can now do:

$ set symlinks=expand

$ cd /jobs/tech
$ pwd
/mnt/projects1/tech
$ echo $cwd
/jobs/tech

$ cd ..
$ echo $cwd
/jobs

Because of all of this, I'm quite tempted to just alias pwd to 'echo $cwd', as it'll give the user a more accurate view of where they can consider themselves to be in the filesystem...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.