|
|
|
|
|
by mmphosis
2157 days ago
|
|
Here's a snippet from my bash_aliases ... ### PROMPT ###
function user_host_pwd() {
printf "%c " '-'
user -n
printf "%c" '@'
violet
printf "%s" "${HOSTNAME%%.*}"
normal
printf "%c" ':'
path "${PWD}"
}
-() { user_host_pwd ; }
prompt_command() {
local current="$USER@$HOSTNAME:$PWD"
local last_cmd
if [ "$current" == "$USER_HOSTNAME_PWD" ]; then
last_cmd="#$(history | tail -n 1 | sed -e 's/.*[0-9] //' | cut -d ' ' -f 1)"
for cmd in $COMMANDS_USER_HOST_PWD_PROMPT
do
if [ "#${cmd}" == "$last_cmd" ]; then
USER_HOSTNAME_PWD=""
break
fi
done
fi
if [ "$current" != "$USER_HOSTNAME_PWD" ]; then
export USER_HOSTNAME_PWD="$current"
user_host_pwd
fi
}
COMMANDS_USER_HOST_PWD_PROMPT="cd ssh sudo su login $(sed -e '/^#.*$/d' -e '/^$/d' -e 's@^.*/@@' /etc/shells | uniq | xargs)"
PROMPT_COMMAND=prompt_command
PS1='$ '
[ "`id -u`" -eq 0 ] && PS1='# '
|
|