Skip to content

Commit

Permalink
util: show all dirty status indicators (#349)
Browse files Browse the repository at this point in the history
Summary:
Instead of just showing `?` or `*`, show one of each symbol in the
dirty status.  This means there will be a maximum of 5 characters at the end of
the prompt, which is fine.

Pull Request resolved: #349

Test Plan:
Seems to work:

```
fbsource>scm % setopt PROMPT_SUBST
fbsource>scm % source contrib/scm-prompt.sh
fbsource>scm % export SHOW_DIRTY_STATE=1
fbsource>scm % export PS1='$(_scm_prompt)$USER@%m:%~%% '
(158b00d6b? M)muirdm@muirdm-mbp:~/fbsource/fbcode/eden/scm%

Reviewed By: muirdm

Differential Revision: D43326525

Pulled By: quark-zju

fbshipit-source-id: 94c0a85e4cf4ffcc5c7c8db9ed64f6ea6d1564a2
  • Loading branch information
vegerot authored and facebook-github-bot committed Feb 17, 2023
1 parent 6f1900c commit 17b8c31
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions eden/scm/contrib/scm-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ _hg_prompt() {
# cf. https://www.internalfb.com/intern/qa/4964/how-do-i-show-the-mercurial-bookmarkgit-branch-in?answerID=540621130023036
_hg_dirty() {
if [ -n "${SHOW_DIRTY_STATE}" ] &&
[ "$(hg config shell.showDirtyState)" != "false" ]; then
command hg status 2> /dev/null \
| command awk '$1 == "?" { print "?" } $1 != "?" { print "*" }' \
| command sort | command uniq | command head -c1
[ "$(command sl config shell.showDirtyState)" != "false" ]; then
command sl status 2> /dev/null \
| command awk '{print $1}'\
| command sort\
| command uniq\
| command paste -sd ' ' -
fi
}

Expand Down

0 comments on commit 17b8c31

Please sign in to comment.