Skip to content

Commit bd66b11

Browse files
committed
Revert 9cd652d..8f9dc33
This rolls back to commit 9cd652d.
1 parent 8f9dc33 commit bd66b11

File tree

5 files changed

+57
-10
lines changed

5 files changed

+57
-10
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ bashrc\_repo
1313
---
1414
Provides repo branch/status PS1 function.
1515

16-
By default, it reads bashrc\_foo to load the repo status function for
17-
foo version control system.
16+
By default, it reads bashrc\_foo to load the repo status function for foo version
17+
control system.
1818

1919
###bashrc\_git
2020
Provides git branch and status info in the PS1.
@@ -32,8 +32,8 @@ The master branch of this repo can be easily ported to other platforms with bash
3232

3333
If you use BSD coreutils, just change `ls --color=auto` to `ls -G`.<br />
3434
If you use OS X or wants to make an OS X distribution, you had better
35-
include the workaround mentioned [Here](https://github.com/AOSC-Dev/BASH_PS1_MISC/issues/3),
36-
the issue #3, in order to avoid "Please install XCode
37-
Developer Tools" from appearing too many times.
35+
include the workaround mentioned [Here](https://github.com/AOSC-Dev/BASH_PS
36+
1_MISC/issues/3), the issue #3, in order to avoid "Please install XCode
37+
Developer Tools" from appearing too many times.
3838

3939
This package provides an example: [Bash 4.3 for OS X](http://pan.baidu.com/s/1c0xlkFu)

bashrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ _ret_prompt() {
5656
}
5757

5858
_ret_same() { return $?; }
59-
. /etc/bashrc_repo &>/dev/null || alias _git_branch='_ret_same' # Fallback
59+
. /etc/bashrc_repo &>/dev/null || alias _repo_status='_ret_same' # Fallback
6060
# To be shipped together. See comments in bashrc_repo on _ret and _ret_status().
6161

6262
# Use "\w" if you want the script to display full path
6363
# How about using cut to "\w($PWD)" to give path of a certain depth?
6464
# Well, forget it.
6565
if [[ $EUID == 0 ]] ; then
66-
PS1="$RED\u $NORMAL[ \W\$(_git_branch) ]$RED \$(_ret_prompt) $NORMAL"
66+
PS1="$RED\u $NORMAL[ \W\$(_repo_status) ]$RED \$(_ret_prompt) $NORMAL"
6767
else
68-
PS1="$GREEN\u $NORMAL[ \W\$(_git_branch) ]$GREEN \$(_ret_prompt) $NORMAL"
68+
PS1="$GREEN\u $NORMAL[ \W\$(_repo_status) ]$GREEN \$(_ret_prompt) $NORMAL"
6969
fi
7070

7171
# Extra Aliases for those lazy ones :)

bashrc_git

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,15 @@ alias __git_branch="git branch 2>/dev/null | grep '*' | sed 's/*\ //g'"
3434
# From http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt
3535
# Modified.
3636
_git_branch() {
37-
_ret=$?
3837
if (git branch &>/dev/null)
3938
then if (LANG=C git status | grep "nothing to commit" &>/dev/null)
4039
then printf "\e[1m@\e[0;32m$(__git_branch)\e[0m"
4140
elif (LANG=C git status | grep "nothing added to commit" &>/dev/null) # Untracked
4241
then printf "\e[1m@\e[0;35m$(__git_branch)\e[0m"
4342
else printf "\e[1m@$IRED$(__git_branch)\e[0m" # Change not added/not merged yet
4443
fi
44+
else false # Necessary, read bashrc_repo.
4545
fi
46-
return $_ret
4746
}
4847

4948

bashrc_hg

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# bashrc extra functions written for AOSC OSes, package "hg"
2+
# by Arthur Wang
3+
4+
[ "$TERMCOLOR"=="8" ] && IRED="\e[0;31m" || IRED="\e[0;91m"
5+
6+
# Aliases from https://gist.github.com/shukydvir/1112265
7+
alias hl='hg pull'
8+
alias hp='hg push'
9+
alias hd='hg diff'
10+
alias hc='hg commit'
11+
alias hco='hg checkout'
12+
alias hb='hg branch'
13+
alias hs='hg status'
14+
alias ha='hg add .'
15+
16+
# From http://mediadoneright.com/content/ultimate-hg-ps1-bash-prompt
17+
# Modified for hg.
18+
_hg_branch() {
19+
if (hg branch &>/dev/null)
20+
then if (LANG=C hg status | grep " " &>/dev/null)
21+
then printf "\e[1m@\e[0;32m$(hg branch)\e[0m"
22+
else printf "\e[1m@$IRED$(hg branch)\e[0m"
23+
fi
24+
else false
25+
fi
26+
}
27+
28+
# A shorter one without color
29+
# alias _hg_branch="echo \" \$(hg branch 2>/dev/null)\""

bashrc_repo

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# bashrc_repo, 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+
# Get functions
8+
. /etc/bashrc_git &>/dev/null
9+
. /etc/bashrc_hg &>/dev/null
10+
11+
# Output
12+
_repo_status() {
13+
_ret=$?
14+
_git_branch 2>/dev/null || _hg_branch 2>/dev/null
15+
retuen $_ret
16+
}
17+
18+
# If this file is simply copied into bashrc, then we don't need `return $_ret`.
19+
# Simply delete the `_ret=$?` in _ret_prompt().

0 commit comments

Comments
 (0)