ksh prompt

Mario D'Alessio dalessio at motcid.UUCP
Tue Mar 5 07:14:17 AEST 1991


herrage at brchh107.BNR.CA (Robert Herrage) writes:

>I have the following defined in my .profile:

>  alias prompt="PS1=\"--> \`pwd\` <--
>  hostname> \""
>  
>This sets my prompt to put my current directory on one line
>and my prompt below it on the next line.  I also want to have
>an alias (or something) for "cd" so that when I use "cd" to 
>change directories, my prompt will update accordingly.  The
>problem is that when I alias "cd", ksh doesn't parse for any
>imbedded aliases.  Therefore,

>  alias cd='cd $*;prompt'
>  

To change the prompt using the cd command, I use a ksh function
and alias combination. Notice the backslash preceeding the cd
in the function:

	function _cd
	{
		\cd $*
		export PS1="${PWD}-> "
	}
	alias cd=_cd

******************************************************************
* ************************************************************** *
* *                                                            * *
* *  Mario D'Alessio            Motorola, Inc.                 * *
* *  dalessio at motcid.UUCP       Cellular Infrastructure Group  * *
* *                                                            * *
* ************************************************************** *
******************************************************************



More information about the Comp.unix.shell mailing list