The prompt in ash.
Hi: I am using ash (just for fun). How do I do to have a prompt like the default in bash? That is, username@hostname:working directory path$. I've read the manual but cannot find the way to do it.
|
Just set the environment variables PS1 and PS2 as indicated in the manual.
Only the default value of PS1 differ between ash and bash as it is \s-\v\$ in bash but $ or # in ash for a regular user or root respectively, as stated in the manuals. |
Run these in ash prompt:
Code:
export PS1='\u@\h \w $' |
What I had done was to modify part of /etc/profile, namely:
Code:
I made the system to use ash instead of bash. I presume I used chsh. |
ash does not accept the escapes in PS1 that bash accepts.
But a similar thing can be accomplished by overriding "cd" with a shell function so that it modifies the prompt whenever you change directory. For example: cd() { command cd "$@" && PS1="$USER@$HOSTNAME:$PWD\$ "; } cd . # Set the prompt the first time. The above assumes $USER and $HOSTNAME are set appropriately. The "command" command in ash allows the shell function to invoke the built-in "cd" command; it is the equivalent of "builtin" in bash. |
All times are GMT -5. The time now is 01:49 AM. |