I would like to learn how to make my shell look like this:
[user@host ~/Folder] $ instead of (the default):
[user@host ~/Folder]$. Also, I'd like to have color on user@host and Folder. How can I do this?
Note: This prompt is my model.
I would like to learn how to make my shell look like this:
[user@host ~/Folder] $ instead of (the default):
[user@host ~/Folder]$. Also, I'd like to have color on user@host and Folder. How can I do this?
Note: This prompt is my model.
Here's a script that I personally use:
### ### Set the prompting to my liking ### # Save the old prompt OLD_PS1="$PS1" # Put the "non-printing" characters between \[ and \] for the prompt so # that the shell can properly determine the length of the prompt. if [ -z "$TERM" ] || [ "$TERM" = "dumb" ] then BOLD="" NORM="" BLUE="" BLACK="" RED="" else BOLD="\\[$(tput bold)\\]" NORM="\\[$(tput sgr0)\\]" BLUE="\\[$(tput setf 1)\\]" BLACK="\\[$(tput setf 0)\\]" RED="\\[$(tput setf 4)\\]" fi PS1="$NORM"'\n'"$BOLD"'\w'"$NORM"'\n'"$BLUE"'\u@\h, $?>'"$NORM"' ' # For use with set_prompt_comment: BASE_PS1="$PS1" ## ## ## set_prompt_comment () { typeset comments if [ -z "$BASE_PS1" ] then echo "Need BASE_PS1 to be defined to proceed!" >&2 else comments="$*" if [ -z "$comments" ] then PS1="$BASE_PS1" else PS1="\\n${RED}${comments}${BASE_PS1}" fi fi } Working with this, the following may give what you want:
PS1="[${RED}user@host${NORM} ${BLUE}~/Folder${NORM}]\\n$ " setf to setaf.