zsh-workers
 help / color / mirror / code / Atom feed
* Re: Problem with the redefinition of "cd" command.
  1997-09-11 15:49 Problem with the redefinition of "cd" command Andres Gomez Navarro
@ 1997-09-11 12:14 ` Andrew Main
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Main @ 1997-09-11 12:14 UTC (permalink / raw)
  To: Andres Gomez Navarro; +Cc: zsh-workers, aj.gomez

Andres Gomez Navarro wrote:
>alias cd 'set ul=$cwd; chdir \!*;set prompt=$cwd"~>"'

A direct translation is

function cd {
  ul=$PWD
  chdir $@
  PROMPT="$PWD~>"
}

but there are some zsh features that make this easier.  The shell variable
$OLDPWD is always automatically set to the previous directory visited,
so your $ul is unnecessary.  Also, a magic sequence in the prompt can
expand to the current directory, without having to change it all the time.
So what you want, idiomatically, is

PROMPT="%/~>"

or you could replace "%/" with "%~" to have the directory abbreviated
using ~ sequences.

-zefram


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Problem with the redefinition of "cd" command.
@ 1997-09-11 15:49 Andres Gomez Navarro
  1997-09-11 12:14 ` Andrew Main
  0 siblings, 1 reply; 2+ messages in thread
From: Andres Gomez Navarro @ 1997-09-11 15:49 UTC (permalink / raw)
  To: 'zsh-workers@math.gatech.edu'; +Cc: 'aj.gomez@iberdrola.es'


Hello!
	I installed tne zsh-3.1.0 in my HP-ws and I am grateful for the adventages of it, the main is the possibility of editing commands with the cursor keys. But I have a problem: when I translated my original .login (c-shell) to the .zlogin I was unable to get this line to work properly:

alias cd 'set ul=$cwd; chdir \!*;set prompt=$cwd"~>"'

in c-shell this redefinition of the "cd" command stores in the variable
"ul" the previous directory (before changing), makes the change of directory to the new one, and constructs a new prompt with the new directory. In my opinion, the problem  is in the sequence "\!*" that is not properly interpreted by the zshell, and I do not know other way of taking the argument of the "cd" command to be used as argument of the "chdir" command in the last part of the alias.
	Could you give me a solution? Thanks in advance. If you need aditional 
data or explanations let me know.
	Best regards,
			Andres Gomez.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-09-11 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-11 15:49 Problem with the redefinition of "cd" command Andres Gomez Navarro
1997-09-11 12:14 ` Andrew Main

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).