Korn Shell Question
Daniel R. Levy
levy at ttrdc.UUCP
Fri Oct 31 04:41:19 AEST 1986
In article <22300001 at ntvax>, mike at ntvax.UUCP writes:
>
>I have a Korn Shell question that perhaps someone can answer. I like to
>have as my system prompt my current path. When I use csh, I set up my
>.cshrc file with these entries:
>
>set prompt = "! `pwd`}" -- this establishes my prompt as my command number
> and current path when i first initiate the shell
>
>alias cd 'chdir \!:1; set prompt=\!\`pwd`}\'
> this sets up my cd command to not only change
> my working directory but to change the prompt.
>
>I would like to have something similar to this in ksh but I'm not sure how
>to change PSx on the fly. Has someone done something similar to this??
>
>Any help would be greatly appreciated.
>
>
>
> |######################################|
> |# J. Michael Flanery #|
> |# Computer Science Dept. #|
> |# North Texas State University #|
> |# UUCP: {ihnp4}!infoswx!ntvax!mike #|
> |######################################|
In ksh, define (say) chdir as a shell function, then alias cd to it.
ksh aliases aren't recursive, so this works:
case $0 in
*ksh) PS1=!$PWD}
chdir()
{
cd $1 # this shell function will return here if the cd fails
PS1=!$PWD\}
}
alias cd=chdir
esac
--
------------------------------- Disclaimer: The views contained herein are
| dan levy | yvel nad | my own and are not at all those of my em-
| an engihacker @ | ployer or the administrator of any computer
| at&t computer systems division | upon which I may hack.
| skokie, illinois |
-------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
go for it! allegra,ulysses,vax135}!ttrdc!levy
More information about the Comp.unix
mailing list