Skip to content

Commit 5b07e84

Browse files
committed
feat: add A parse
1 parent eaade91 commit 5b07e84

File tree

2 files changed

+76
-24
lines changed

2 files changed

+76
-24
lines changed

.vcs_git

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# bashrc extra functions written for AOSC OSes, package "git"
2+
# by Arthur Wang
3+
4+
# Aliases, mostly from http://blog.sina.com.cn/s/blog_630c58cb01011uid.html
5+
alias g="git status"
6+
alias ga="git add"
7+
alias gaa="git add ."
8+
alias gau="git add -u"
9+
alias gct="git commit"
10+
alias gcm="git commit -m"
11+
alias gca="git commit -am"
12+
alias gb="git branch"
13+
alias gbd="git branch -d"
14+
alias gco="git checkout"
15+
alias gcob="git checkout -b"
16+
alias gt="git stash"
17+
alias gta="git stash apply"
18+
alias gmg="git merge"
19+
alias gr="git rebase"
20+
alias gl="git log --oneline --decorate --graph"
21+
alias gsh="git show"
22+
alias gd="git diff"
23+
alias gdc="git diff --cached"
24+
alias gbl="git blame"
25+
alias gps="git push"
26+
alias gpl="git pull"
27+
28+
29+
# Prompt
30+
#alias __ps1_git_branch="git branch 2>/dev/null | grep '*' | sed 's/*\ //g'"
31+
alias __ps1_git_branch="/usr/local/bin/git-head-name"
32+
33+
# From http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt
34+
# Modified.
35+
_ps1_git_status() {
36+
local gbr
37+
gbr=$(git-head-name)
38+
case "$?" in
39+
5)
40+
echo -e "\01\e[1m\02@\01\e[0;32m\0002$gbr\01\e[0m\02"
41+
;;
42+
6)
43+
echo -e "\01\e[1m\02@\01$IRED\0002$gbr\01\e[0m\02"
44+
;;
45+
7)
46+
echo -e "\01\e[1m\02@\01\e[0;35m\0002$gbr\01\e[0m\02"
47+
;;
48+
8)
49+
echo -e "\01\e[1m\02@\01\e[0;37m\0002$gbr\01\e[0m\02"
50+
;;
51+
esac
52+
}
53+
54+
# A shorter one without color
55+
# alias _git_status='_st="$(__git_branch)"; ((!PIPESTATUS[0])) && echo "@$_st"'
56+
# For users of the contrib/completion __git_ps1
57+
# _git_status(){ git branch &>/dev/null || return 1; echo -n ' '; __git_ps1; }

src/main.rs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,33 +51,28 @@ fn main() {
5151
if let Ok(cmd) = cmd {
5252
if cmd.status.success() {
5353
let out = String::from_utf8_lossy(&cmd.stdout);
54-
let out = out
54+
let mut out = out
5555
.trim()
5656
.split('\n')
57-
.map(|x| x.rsplit_once(" ").map(|x| x.0.trim()));
58-
59-
match out {
57+
.map(|x| x.rsplit_once(" "))
58+
.flatten()
59+
.map(|x| x.0.trim());
60+
61+
match out.next() {
62+
None => {
63+
println!("{s}");
64+
status = 5;
65+
}
66+
Some("M") | Some("A") => {
67+
println!("{s}");
68+
status = 6;
69+
}
70+
Some("??") => {
71+
println!("{s}");
72+
status = 7;
73+
}
6074
_ => {
61-
for i in out {
62-
match i {
63-
None => {
64-
println!("{s}");
65-
status = 5;
66-
break;
67-
}
68-
Some("M") => {
69-
println!("{s}");
70-
status = 6;
71-
break;
72-
}
73-
Some("??") => {
74-
println!("{s}");
75-
status = 7;
76-
break;
77-
}
78-
_ => continue,
79-
}
80-
}
75+
println!("{s}");
8176
}
8277
}
8378
} else {

0 commit comments

Comments
 (0)