themes/agnoster: Refactor the new codes

This commit is contained in:
Koichi Murase
2023-02-16 16:25:06 +09:00
parent a6b655b136
commit f085e5718d

View File

@@ -358,13 +358,13 @@ function prompt_git {
# Mercurial: clean, modified and uncomitted files
function prompt_hg {
local rev st branch
if $(hg id >/dev/null 2>&1); then
if $(hg prompt >/dev/null 2>&1); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
if hg id &>/dev/null; then
if hg prompt &>/dev/null; then
if [[ $(hg prompt "{status|unknown}") == '?' ]]; then
# if files are not added
prompt_segment red white
st='±'
elif [[ -n $(hg prompt "{status|modified}") ]]; then
elif [[ $(hg prompt "{status|modified}") ]]; then
# if any modification
prompt_segment yellow black
st='±'
@@ -377,10 +377,10 @@ function prompt_hg {
st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null)
if `hg st | grep -q "^\?"`; then
if hg st | grep -q "^\?"; then
prompt_segment red white
st='±'
elif `hg st | grep -q "^[MA]"`; then
elif hg st | grep -q "^[MA]"; then
prompt_segment yellow black
st='±'
else