File tree Expand file tree Collapse file tree 5 files changed +57
-10
lines changed Expand file tree Collapse file tree 5 files changed +57
-10
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ bashrc\_repo
13
13
---
14
14
Provides repo branch/status PS1 function.
15
15
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.
18
18
19
19
###bashrc\_ git
20
20
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
32
32
33
33
If you use BSD coreutils, just change ` ls --color=auto ` to ` ls -G ` .<br />
34
34
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.
38
38
39
39
This package provides an example: [ Bash 4.3 for OS X] ( http://pan.baidu.com/s/1c0xlkFu )
Original file line number Diff line number Diff line change @@ -56,16 +56,16 @@ _ret_prompt() {
56
56
}
57
57
58
58
_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
60
60
# To be shipped together. See comments in bashrc_repo on _ret and _ret_status().
61
61
62
62
# Use "\w" if you want the script to display full path
63
63
# How about using cut to "\w($PWD)" to give path of a certain depth?
64
64
# Well, forget it.
65
65
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 "
67
67
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 "
69
69
fi
70
70
71
71
# Extra Aliases for those lazy ones :)
Original file line number Diff line number Diff line change @@ -34,16 +34,15 @@ alias __git_branch="git branch 2>/dev/null | grep '*' | sed 's/*\ //g'"
34
34
# From http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt
35
35
# Modified.
36
36
_git_branch() {
37
- _ret=$?
38
37
if (git branch &>/dev/null)
39
38
then if (LANG=C git status | grep "nothing to commit" &>/dev/null)
40
39
then printf "\e[1m@\e[0;32m$(__git_branch)\e[0m"
41
40
elif (LANG=C git status | grep "nothing added to commit" &>/dev/null) # Untracked
42
41
then printf "\e[1m@\e[0;35m$(__git_branch)\e[0m"
43
42
else printf "\e[1m@$IRED$(__git_branch)\e[0m" # Change not added/not merged yet
44
43
fi
44
+ else false # Necessary, read bashrc_repo.
45
45
fi
46
- return $_ret
47
46
}
48
47
49
48
Original file line number Diff line number Diff line change
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)\""
Original file line number Diff line number Diff line change
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().
You can’t perform that action at this time.
0 commit comments