I'd like to have bash always print the full path, rather than using ~ to denote the user's home folder. My desire here may be unusual, but the question pertains to anybody who wants a fully custom prompt that can change significantly between commands. I have found a way to do it, but it's not foolproof:
PROMPT_COMMAND='PS1=`echo -n $PWD \#`'
what this does is re-write the prompt every time a new command is executed. 90% of the time it works great. But sometimes, when the prompt is shown, my cursor is placed at the start of the line, rather than at the end, so that my typing overwrites the prompt. What's going on ?!? How do I get the cursor to always start after the # in the prompt in this example?
CodePudding user response:
Why not simply do a
PS1='$PWD #'
instead of fiddling with PROMPT_COMMAND
?
Using single quotes is crucial here, since you want the variable to be evaluated by the time the prompt is generated.