Setting PS1 in ksh?

トップ ページ
添付ファイル:
Eメールのメッセージ
+ (text/plain)
このメッセージを削除
このメッセージに返信
著者: Matt Alexander
日付:  
題目: Setting PS1 in ksh?
In bash, I'm able to set my prompt like so:

PS1="[\u@\h \w]\\$ "

I'd like to achieve the same results, but with ksh. This gets me close:

PS1="[$LOGNAME@`hostname` \$PWD]$ "

But I'd like to have the ~ when I'm in my home directory. I tried this next:


PS1="[$LOGNAME@`hostname` `if [ "$PWD" = "$HOME" ]; then echo '~'; else echo
$PWD; fi`]$ "

But then it's always the ~ and doesn't update to the real current directory
that I'm in as I move around.

Anyone have an idea how to accomplish this?
Thanks,
~Matt

--
Dance like it hurts.
Love like you need money.
Work when people are watching.