Open boyska opened 10 years ago
simple, no colors, exit code at line beginning
export PS1='[\u ($?)] \w \$ '
advanced, colors, timestamp, exit code, directory
export PS1="${debian_chroot:+($debian_chroot)}[\e[00;33m][\t][\e[0m] $(tput rev)[$(tput sgr0)] \u@\h:[$(tput rev)]\w[$(tput sgr0)][$(tput bold)] \$ [$(tput sgr0)]"
What about that?
PS1="\[\e[00;37m\]┌─[\t][\[\e[0m\]\[\e[01;31m\]\\$\[\e[0m\]\[\e[00;37m\]]\n└─\\[\e[0m\]\[\e[01;32m\]\u\[\e[0m\]\[\e[00;37m\]@\[\e[0m\]\[\e[01;33m\]\h\[\e[0m\]\[\e[00;37m\]:[\[\e[0m\]\[\e[00;36m\]\w\[\e[0m\]\[\e[00;37m\]]\[\e[0m\]
is a lil more colorful.. but miss the exitcode D:
errorc(){
exit_=$?
if [ $exit_ -ne 0 ]; then
echo -e "\033[01;31m✘ $exit_\033[0m"
else echo -e "\033[01;32m✓\033[0m"
fi
}
who_(){
if [ "$EUID" -ne 0 ]; then
echo -e "$"
else
echo -e "\033[01;31m#\033[0m"
fi
}
PS1="\u[\[\e[34m\]\w\[\e[m\]]\`errorc\` \`who_\` "
on my computer it does not work properly: it wraps in a strange & wrong way when the line exceeds the width of the window.
In wich way? What commands u use?
And wich terminal emu? I tested on guake and it works properly
here is a screenshot of how it is "wrong"
this seems to work fine
promptunicode=1
freeptoprompt() {
exit_=$?
if [[ $promptunicode -eq 1 ]]; then
ok_symbol=$'\u2713'
no_symbol=$'\u2717'
else
ok_symbol="."
no_symbol="x"
fi
LIGHTGREEN="\[\033[1;32m\]"
LIGHTRED="\[\033[1;31m\]"
CYAN='\e[0;36m'
WHITE="\[\033[0;37m\]"
RESET="\[\033[0;00m\]"
dollar="\\$"
[[ $EUID -eq 0 ]] && dollar="$LIGHTRED$dollar$RESET"
if [[ $exit_ -eq 0 ]]; then
last="${LIGHTGREEN}$ok_symbol$RESET"
else
last="${LIGHTRED}$no_symbol:$exit_$RESET"
fi
PS1="\u[$CYAN\w$RESET]$last $dollar "
}
PROMPT_COMMAND=freeptoprompt
It can run in two modes: the default is unicode the other is ascii-compatible
The default is unicode, but at any time you can switch just setting promptunicode=0
b39ef4a8e0f8f59304dc42fa7 should be ok, with also some minor improvement on the previously-posted screenshot (cyan dirname, better user color handling, local variables everywhere).
I'm wondering if a separate package (submodule) would be appropriate for such a small enhancement. Pro: modular, updatable for previous freepto users Con: a package for one file with one dependency (bash-completion) ? Maybe we could aggregate some more stuff in there.
Our current bash prompt is rather basic. An improved one is not just a vanity feature: it also aids in testing. Especially, it would be good to see the last exit code appear in the prompt.