Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to show git status info on the right side of the terminal?
- PS1='$(printf "%*sr%s" $(( COLUMNS-1 )) "[$(git branch 2>/dev/null | grep '^*' | sed s/..//)] $(date +%H:%M:%S)" "heipei@wavefront:$PWD$ ")'
- left="[${status}]u@h:w$ "
- right="$(git symbolic-ref HEAD) $(date +%T)"
- spaces="$(( $(tput cols) - ${#left} - ${#right} ))"
- export PS1="$(printf "%s%${spaces}sn" "$left" "$right")"
- preprompt() {
- rc=$?
- c=31
- [ $rc -eq 0 ] && c=32
- PS1="[$(color $c)]$rc[$(color 0)] t w $ "
- # right "prompt"
- # We cannot use $COLUMNS here, since in new shells the first prompt
- # will get garbled then. Seems like the correct value of COLUMNS is
- # in the shell init.
- printf "%`tput cols`s`tput cr`" "${USER}@${HOST}"
- }
- PROMPT_COMMAND=preprompt
Add Comment
Please, Sign In to add comment