点击(此处)折叠或打开
- PROMPT_MAXPWDLEN=20 # The most characters to be shown.
- PROMPT_HIDDENPREFIX=... # Prefix when hiding some characters.
- PROMPT_UPDATE(){
- lastcmd=1
- if [ $1 = 0 ]; then
- lastcmd_indicator='(^_^)'
- PSCOLOR='[32;1m'
- else
- lastcmd_indicator='(@_@)'
- PSCOLOR='[31;1m'
- fi
- if [ ${#PWD} -ge $((${PROMPT_MAXPWDLEN}+${#PROMPT_HIDDENPREFIX})) ]; then
- PWDSHORT="${PROMPT_HIDDENPREFIX}$(pwd|sed -e "s|^.\{$((${#PWD}-${PROMPT_MAXPWDLEN}))\}||g;s|[^/]*/|/|;")"
- else
- PWDSHORT="${PWD}"
- fi
- echo -ne "\033]0;$(hostname -s):${PWDSHORT}\007"
- PS1='${lastcmd:+\[\e${PSCOLOR}\]$lastcmd_indicator\[\e[m\] }\[\e[33;1m\][\!] \[\e[0;36m\]\u\[\e${PSCOLOR}\]@\[\e[0;32m\]\h\[\e${PSCOLOR}\]:\[\e[01;34m\]${PWDSHORT}\[\e[00m\]\$ '
- }
- PROMPT_COMMAND='PROMPT_UPDATE $?'
- # set a fancy prompt (non-color, unless we know we "want" color).
- case "$TERM" in
- xterm-*color)
- PSCOLOR='[00m'
- # set PS1 for system PROMPT_COMMAND unusable
- PS1='${lastcmd:+\[\e${PSCOLOR}\]$lastcmd_indicator\[\e[m\] }\[\e[33;1m\][\!] \[\e[0;36m\]\u\[\e${PSCOLOR}\]@\[\e[0;32m\]\h\[\e${PSCOLOR}\]:\[\e[01;34m\]\w\[\e[00m\]\$ '
- ;;
- *)
- PS1='[\!] \u@\h:\w\$ '
- ;;
- esac