Skip to content

Commit 1142cfa

Browse files
committed
bashrc: sane vcs naming
1 parent 0c77892 commit 1142cfa

File tree

5 files changed

+36
-26
lines changed

5 files changed

+36
-26
lines changed

bashrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ _ret_same() { return $?; }
7777
# Base functions ready. Let's load bashrc.d.
7878
for c in /etc/bashrc.d/*; do . $c; done
7979

80-
# The prompt depends on repo_status! Get one backup anyway.
81-
declare -f _repo_status >/dev/null || ! echo _repo_status not declared, making stub.. || alias _repo_status=_ret_same
80+
# The prompt depends on vcs_status! Get one backup anyway.
81+
declare -f _vcs_status >/dev/null || ! echo _vcs_status not declared, making stub.. || alias _vcs_status=_ret_same
8282

8383
# To be shipped together. See comments in bashrc_repo on _ret and _ret_status().
8484

@@ -87,9 +87,9 @@ declare -f _repo_status >/dev/null || ! echo _repo_status not declared, making s
8787
# Well, forget it.
8888

8989
if [[ "$EUID" == 0 ]] ; then
90-
PS1="$RED\u $NORMAL[ \W\$(_repo_status) ]$RED \$(_ret_prompt) $NORMAL"
90+
PS1="$RED\u $NORMAL[ \W\$(_vcs_status) ]$RED \$(_ret_prompt) $NORMAL"
9191
else
92-
PS1="$GREEN\u $NORMAL[ \W\$(_repo_status) ]$GREEN \$(_ret_prompt) $NORMAL"
92+
PS1="$GREEN\u $NORMAL[ \W\$(_vcs_status) ]$GREEN \$(_ret_prompt) $NORMAL"
9393
fi
9494

9595
# Completion, wow.
File renamed without changes.
File renamed without changes.

bashrc.d/20-vcs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 20-vcs, the version control display for AOSC OSes PS1.
2+
# by Arthur Wang
3+
4+
# This module is highly extensible. Just read the source.
5+
# Long-term TODO: svn, vns and bzr.
6+
7+
# We are not POSIX-compatible.
8+
_is_posix && return
9+
10+
# Get functions
11+
_vcs_files="$(echo /etc/bashrc.d/.vcs_*)"
12+
if [ "$_vcs_files" == "/etc/bashrc.d/.vcs_*" ]; then
13+
_vcs_status(){ true; }
14+
unset _vcs_files
15+
return
16+
else
17+
for _vcs in $_vcs_files; do
18+
. "$_vcs"
19+
_vcs_mods+=" ${_vcs/\/etc\/bashrc.d\/.vcs_}"
20+
done
21+
fi
22+
unset _vcs _vcs_files
23+
24+
# Output
25+
_vcs_status() {
26+
_ret=$?
27+
local _vcs
28+
for _vcs in $_vcs_mods; do
29+
"$_vcs"_status && break
30+
done
31+
return $_ret
32+
}

bashrc.d/bashrc_repo

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)