mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-23 22:30:07 +00:00
Better placement of Fossil prompt info
Instead of blindly tacking `$fossil_prompt_info` onto the end of the prompt string and making assumptions about whether `$PROMPT` or `$RPROMPT` are in use here, assume the user is using a theme that puts `$git_prompt_info` in there somewhere and inject our info immediately afterward. The theme creator decided that's a good place for Git prompt info, so that's a good place for Fossil prompt info, too. This also replaces some calls out to `grep` with internal Zsh string manipulation for less overhead.
This commit is contained in:
parent
6d48309cd7
commit
033b095212
1 changed files with 17 additions and 12 deletions
|
@ -35,18 +35,23 @@ function fossil_prompt_info() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _fossil_prompt () {
|
function _fossil_prompt () {
|
||||||
local current=`echo $PROMPT $RPROMPT | grep fossil`
|
if [ -z "$_FOSSIL_PROMPT" ]; then
|
||||||
|
# Use substitutions to work out what other plugins and themes have
|
||||||
if [ "$_FOSSIL_PROMPT" = "" -o "$current" = "" ]; then
|
# done ahead of us so we don't duplicate their work.
|
||||||
local _prompt=${PROMPT}
|
#
|
||||||
local _rprompt=${RPROMPT}
|
# If $fossil_prompt_info isn't in the prompt strings already but we
|
||||||
|
# can find $git_prompt_info, put it immediately afterward so that
|
||||||
local is_prompt=`echo $PROMPT | grep git`
|
# one or the other appears in the prompt. We're gambling that you
|
||||||
|
# aren't in a directory that's a checkout for both a Git repo and a
|
||||||
if [ "$is_prompt" = "" ]; then
|
# Fossil repo.
|
||||||
RPROMPT="$_rprompt"'$(fossil_prompt_info)'
|
#
|
||||||
else
|
# Otherwise, don't guess about where the user wants our prompt info
|
||||||
PROMPT="$_prompt"'$(fossil_prompt_info) '
|
# placed. They can edit their theme to place it manually.
|
||||||
|
if [ "${PROMPT/fossil_prompt_info//}" = "$PROMPT" ]; then
|
||||||
|
PROMPT="${PROMPT/git_prompt_info/git_prompt_info)\$(fossil_prompt_info}"
|
||||||
|
fi
|
||||||
|
if [ "${RPROMPT/fossil_prompt_info//}" = "$RPROMPT" ]; then
|
||||||
|
RPROMPT="${RPROMPT/git_prompt_info/git_prompt_info)\$(fossil_prompt_info}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_FOSSIL_PROMPT="1"
|
_FOSSIL_PROMPT="1"
|
||||||
|
|
Loading…
Reference in a new issue