Unverified Commit c1b798af authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

agnoster: fix bzr prompt with breezy installed (#8646)

* Change indentation to 2 spaces in prompt_bzr function
* Check if in a bzr repository and optimize bzr calls in prompt_bzr
parent eeb49bf5
...@@ -140,24 +140,30 @@ prompt_git() { ...@@ -140,24 +140,30 @@ prompt_git() {
} }
prompt_bzr() { prompt_bzr() {
(( $+commands[bzr] )) || return (( $+commands[bzr] )) || return
if (bzr status >/dev/null 2>&1); then
status_mod=`bzr status | head -n1 | grep "modified" | wc -m` # Test if bzr repository in directory hierarchy
status_all=`bzr status | head -n1 | wc -m` local dir="$PWD"
revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` while [[ ! -d "$dir/.bzr" ]]; do
if [[ $status_mod -gt 0 ]] ; then [[ "$dir" = "/" ]] && return
prompt_segment yellow black dir="${dir:h}"
echo -n "bzr@"$revision "✚ " done
else
if [[ $status_all -gt 0 ]] ; then local bzr_status status_mod status_all revision
prompt_segment yellow black if bzr_status=$(bzr status 2>&1); then
echo -n "bzr@"$revision status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
else status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
prompt_segment green black revision=$(bzr log -r-1 --log-format line | cut -d: -f1)
echo -n "bzr@"$revision if [[ $status_mod -gt 0 ]] ; then
fi prompt_segment yellow black "bzr@$revision ✚"
fi else
if [[ $status_all -gt 0 ]] ; then
prompt_segment yellow black "bzr@$revision"
else
prompt_segment green black "bzr@$revision"
fi
fi fi
fi
} }
prompt_hg() { prompt_hg() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment