Advertisement
Guest User

Untitled

a guest
Nov 8th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.69 KB | None | 0 0
  1. # ~/.zprompt
  2.  
  3. function zprompt_user() {
  4.   if [[ $UID == '0' ]]; then
  5.     echo '#'
  6.   else
  7.     echo '$'
  8.   fi
  9. }
  10.  
  11. function zprompt_pwd() {
  12.   echo "%~"
  13. }
  14.  
  15. function zprompt_git_status() {
  16.   local git_status=$(git status --porcelain 2> /dev/null)
  17.   [[ ! -z $git_status ]] && echo '*'
  18. }
  19.  
  20. function zprompt_context() {
  21.   [[ -n $SSH_TTY ]] || [[ -n $SSH_CLIENT ]] && echo '%n@%m'
  22. }
  23.  
  24. function zprompt_git_branch() {
  25.   local branch=$(git symbolic-ref HEAD --short 2> /dev/null)
  26.   [[ -n $branch ]] && echo " $branch "
  27. }
  28.  
  29. setopt prompt_subst
  30.  
  31. PROMPT='$(zprompt_context)'
  32. PROMPT+='$(zprompt_pwd)'
  33. PROMPT+='$(zprompt_git_branch)'
  34. PROMPT+='$(zprompt_git_status)'
  35. PROMPT+=' $(zprompt_user) '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement