How to display current path in command prompt in linux's sh (not bash)?
Command substitutions in double quotes
" get expanded immediately. That is not what you want for your prompt. Single quotes
' will preserve the substitutions in
$PS1 which then get only expanded when displaying the prompt. Hence this should work:
If you want the usual dollar sign and a space at the end of your prompt, simply add
$ at the end (no escaping necessary):
export PS1='$(whoami)@$(hostname):$(pwd)$ '
sh-4.2$ export PS1="\u@\h:\w>" [email protected]:~>cd /usr/local [email protected]:/usr/local>
This command works for me.
export PS1="\u@\h: \W:$"
\u = username
\h = hostname
\W Name of present folder (not full path)