ssh-colorize 904 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. if [[ -n $SSH_CLIENT ]]; then
  3. case $HOSTNAME in
  4. *.example.com) prompt_user_host_color='1;35';; # magenta on example.com
  5. *) prompt_user_host_color='1;33';; # yellow elsewhere
  6. esac
  7. else
  8. unset prompt_user_host_color;; # omitted on the local machine
  9. fi
  10. if [[ -n $prompt_user_host_color ]]; then
  11. PS1='\[\e['$prompt_user_host_color'm\]\u@\h'
  12. else
  13. PS1=
  14. fi
  15. PS1+='\[\e[1;34m\] \w\[\e[1;31m\]$(__git_ps1)\[\e[1;0;37m\] \$\[\e[0m\] '
  16. if [[ -n $SSH_CLIENT ]]; then
  17. case $HOSTNAME in
  18. *.example.com) prompt_user_host_color='1;35';; # magenta on example.com
  19. *) prompt_user_host_color='1;33';; # yellow elsewhere
  20. esac
  21. else
  22. unset prompt_user_host_color;; # omitted on the local machine
  23. fi
  24. if [[ -n $prompt_user_host_color ]]; then
  25. PS1='\[\e['$prompt_user_host_color'm\]\u@\h'
  26. else
  27. PS1=
  28. fi
  29. PS1+='\[\e[1;34m\] \w\[\e[1;31m\]$(__git_ps1)\[\e[1;0;37m\] \$\[\e[0m\] '