diff options
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | demo-script | 59 | ||||
-rwxr-xr-x | prompt | 50 | ||||
-rw-r--r-- | screen-shot.png | bin | 32374 -> 0 bytes | |||
-rw-r--r-- | screenshot-prompt-basic.png | bin | 0 -> 24791 bytes | |||
-rw-r--r-- | screenshot-prompt-git.png | bin | 0 -> 186582 bytes |
6 files changed, 77 insertions, 38 deletions
@@ -1,3 +1,3 @@ -bug: default host not works (eval leaves "$" if $host is empty) -bug: extranious "$" is displayed (again) at just init-ed repo -bug: when two branched head are equal, then git-name-rev shows last edited branch (not current branch) +Lvv's prompt + +Picture worth a thousand words, see wiki for screenshots diff --git a/demo-script b/demo-script index 2fa37a2..58e269a 100644 --- a/demo-script +++ b/demo-script @@ -1,38 +1,33 @@ -# git -. /t/prompt/prompt -rm -rf tiny.git/ -mkdir tiny.git -cd tiny.git -git init -echo v1 > a-file -git add a-file -touch an-untracked -rm an-untracked -git commit -m v1 a-file - - -.. +<<<<<<< HEAD:demo-script . /t/prompt/prompt +test -d demo && rm -rf demo/ +test -d ../demo && cd .. && rm -rf demo/ clear -rm -rf tiny.git/ -mkdir tiny.git -cd tiny.git +mkdir demo +cd demo git init -echo v1 > file -git add file -touch untracked-file -rm untracked-file -git commit -m v1 file +echo "1st line" > FOO +git add FOO +touch untracked.o +rm untracked.o +git commit -q -m "1st line" FOO git checkout -b test -echo 'added 2nd line in test' >> file -git add file -git commit -m v2test +echo "added 2nd line in test" >> FOO +git add FOO +echo "2nd FOO" > BAR +git add BAR +echo "added 3nd line" >> FOO +git add FOO +git commit -q -m "FOO moded, BAR added" git checkout master -cat file -echo 'now added 2nd line in master' >> file -git add file -echo 'added 3nd line in master' >> file -git add file -git commit -m v2 +cat FOO +echo "now added 2nd line in master" >> FOO +git add FOO +git commit -q -m "2nd line" git merge test - +git-cat-file -p test:FOO > FOO +git add FOO +git commit -q -m "merged" +cat FOO +git checkout HEAD^ +cat FOO @@ -242,6 +242,43 @@ PROMPT_COMMAND=' # LOCALS # SVN # ... + + if [[ -d .svn ]]; then + + ### get rev + eval ` + svn info | + sed -n " + s@^URL[^/]*//@repo_dir=@p + s/^Revision: /rev=/p + " + ` + ### get status + + eval `svn -q status 2>/dev/null | + sed -n " + s/^A /modified=modified; git_modified_files+=\" \"/p + s/^M /modified=modified; git_modified_files+=\" \"/p + " + ` + + ### sort statuses, choose primary (for branch color) + status=${op+op} + status=${status:-$detached} + status=${status:-$clean} + status=${status:-$modified} + status=${status:-$added} + status=${status:-$untracked} + # at least one should be set + : ${status?prompt internal error: git status} + eval git_color="\${git_$status}" + git_color=${git_color:-$WHITE} # default + + ### compose + tail_local="($git_status$rev)" + tail_local="${tail_local+$git_color $tail_local}${dir_color}" + fi + # make # ... @@ -315,12 +352,19 @@ PROMPT_COMMAND=' ### branch - #head_tail=`echo $head | sed 's/[^^~]*//'` # we cut head to leave only ^~, and reattach to branch name branch=${branch/master/M} grep -q "^ref:" $git_dir/HEAD 2>/dev/null || detached=detached [[ -n "$detached" ]] && branch="<detached:`git-name-rev --name-only HEAD 2>/dev/null`>" + if [[ "$op" == "merge" ]] ; then + branch="$op: $branch <~ $(git-name-rev --name-only $(<$git_dir/MERGE_HEAD))" + + elif [[ -n "$op" ]]; then + branch="<$op:$branch>" + + fi + head_rev=`git-rev-parse HEAD 2>/dev/null` head_rev=${head_rev/HEAD/} head_rev=${head_rev:0:6} @@ -336,7 +380,7 @@ PROMPT_COMMAND=' # at least one should be set : ${status?prompt internal error: git status} eval git_color="\${git_$status}" - git_color=${git_color:-$WHITE} + git_color=${git_color:-$WHITE} # default ### compose local label @@ -345,7 +389,7 @@ PROMPT_COMMAND=' file_list+="${git_modified_files+$git_modified$git_modified_files}" file_list+="${git_untracked_files+$git_untracked$git_untracked_files}" [[ $file_list ]] && file_list=":${file_list}" # ${+ does not works (?) - tail_local="(${branch} $white$head_rev$git_color${op+ / $op}$git_color${file_list}$git_color)" + tail_local="(${branch} $white$head_rev$git_color$git_color${file_list}$git_color)" ### fringes (added depended on location) head_local="${head_local+$git_color $head_local\n}" diff --git a/screen-shot.png b/screen-shot.png Binary files differdeleted file mode 100644 index c1bc2e3..0000000 --- a/screen-shot.png +++ /dev/null diff --git a/screenshot-prompt-basic.png b/screenshot-prompt-basic.png Binary files differnew file mode 100644 index 0000000..9a0cbfe --- /dev/null +++ b/screenshot-prompt-basic.png diff --git a/screenshot-prompt-git.png b/screenshot-prompt-git.png Binary files differnew file mode 100644 index 0000000..4ede981 --- /dev/null +++ b/screenshot-prompt-git.png |