#15590: Pimp my Shell
-------------------------------------+-------------------------------------
Reporter: vbraun | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.4
Component: scripts | Resolution:
Keywords: | Merged in:
Authors: Volker Braun | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/vbraun/pimp_my_shell | d1f915465475938ee8cb97987fe8db7a464b6a94
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by ppurka):
I use a much shorter function in my zshrc to set up the git status, the
idea being that the shell should be fast in initialization and in
returning
the prompt. So, the only command that is run is `git status` and
everything
else is gleaned from that using shell operations. Also, I use `RPROMPT` so
that the left prompt is short. The `RPROMPT` disappears automatically once
the user starts typing too long commands.
{{{#!sh
function __check_git__() {
local _s="$( git status 2>&1 )"
[[ "${_s}" = "fatal:"* ]] && echo "" && return
_s="$( echo "${_s}" | sed -e '/^#.*modified:.*(untracked content)$/d'
)"
local _g_s="$( echo "$_s" | sed -n -e '1s@^On branch @@p;q' )"
if [[ "$_s" = *modified:* || \
"$_s" = *"new file:"* || \
"$_s" = *"Your branch is behind"* || \
"$_s" = *deleted:* || \
"$_s" = *renamed:* \
]]; then
echo "[%20>...>%{$fg[red]%}$_g_s%{$fg[white]%}%>>]"
elif [[ -n "$_g_s" ]]; then
echo "[%20>...>%{$fg[green]%}$_g_s%{$fg[white]%}%>>]"
else
echo "%{$fg[yellow]%}[?]%{$fg[white]%}"
fi
}
RPROMPT="%{$fg[white]%}•$(__check_git__)%{$fg[cyan]%}%n%{$fg[white]%}|%{$fg[green]%}%m%{$reset_color%}"
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/15590#comment:24>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.