要来的一个linux命令提示符的配置,一切为了得瑟

3140阅读 1评论2012-04-28 playmud
分类:LINUX


点击(此处)折叠或打开

  1. PROMPT_MAXPWDLEN=20 # The most characters to be shown.
  2. PROMPT_HIDDENPREFIX=... # Prefix when hiding some characters.
  3. PROMPT_UPDATE(){
  4. lastcmd=1
  5. if [ $1 = 0 ]; then
  6. lastcmd_indicator='(^_^)'
  7. PSCOLOR='[32;1m'
  8. else
  9. lastcmd_indicator='(@_@)'
  10. PSCOLOR='[31;1m'
  11. fi
  12. if [ ${#PWD} -ge $((${PROMPT_MAXPWDLEN}+${#PROMPT_HIDDENPREFIX})) ]; then
  13. PWDSHORT="${PROMPT_HIDDENPREFIX}$(pwd|sed -e "s|^.\{$((${#PWD}-${PROMPT_MAXPWDLEN}))\}||g;s|[^/]*/|/|;")"
  14. else
  15. PWDSHORT="${PWD}"
  16. fi
  17. echo -ne "\033]0;$(hostname -s):${PWDSHORT}\007"
  18. 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\]\$ '
  19. }
  20. PROMPT_COMMAND='PROMPT_UPDATE $?'
  21. # set a fancy prompt (non-color, unless we know we "want" color).
  22. case "$TERM" in
  23. xterm-*color)
  24. PSCOLOR='[00m'
  25. # set PS1 for system PROMPT_COMMAND unusable
  26. 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\]\$ '
  27. ;;
  28. *)
  29. PS1='[\!] \u@\h:\w\$ '
  30. ;;
  31. esac

上一篇:修改linux bash的提示符
下一篇:twitter4j-2.2.5.zip 下载

文章评论