Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Handling of .. in command line parameters

On Tue, Jun 17, 2008 at 10:12:39AM +0200, Michal Sojka wrote:
> I have a small problem with zsh. Is there a possibility for .. in command line 
> to count with symbolic links?
> More specifically, I have symblic link ~/link that points to another 
> directory, let's say ~/somedir/target. If I do
> cd ~/link
> vi ../file.txt
> It tries to open ~/somedir/file.txt instead of ~/file.txt, what I want.
> Maybe this is not only "problem" of zsh, but also of all other programs (vi in 
> this example). Do you know about any solution to this?

That's not up to the shell in that case. That's vi that opens
the "../file.txt" file and the shell has nothing to do with it.

What you could do is bind a zsh key that expands the
"../file.txt" to "~/somedir"

The confusing thing I find is that "cd" by default behaves
differently from other commands. That's because zsh maintains a
/logical/ current directory stored in $PWD and cd .. doesn't do
a chdir(".."), but just strips one trailing component off that
$PWD and does a chdir(of that). zsh can do if for cd because
it's zsh that does the cd.

You can disable that fancy behavior of cd, by doing a:

alias cd='cd -P'

Then if you have %~ is your PS1, you're least likely to have


Messages sorted by: Reverse Date, Date, Thread, Author