Skip to content

Instantly share code, notes, and snippets.

@gabldotink
Last active November 5, 2023 16:02
Show Gist options
  • Save gabldotink/a3c66d67d48be62f8ab9e5c14dee6e29 to your computer and use it in GitHub Desktop.
Save gabldotink/a3c66d67d48be62f8ab9e5c14dee6e29 to your computer and use it in GitHub Desktop.
POSIX PS1 and PS2. a bit slow. CC0 1.0
PS1_FUNC(){
if [ "$(id -u)" = 0 ]
then PS1_FUNC_SYMBOL='#'
else PS1_FUNC_SYMBOL='$'
fi
printf 'gab@gabuntu %s %s
%s> ' "$PWD" "$(date '+%Y-%m-%d %H:%M:%S %Z UTC%z')" $PS1_FUNC_SYMBOL
}
PS2_FUNC(){
printf '=> '
}
PS1='$(PS1_FUNC)'
PS2='$(PS2_FUNC)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment