From 95afe1e8b78b79be319d04fae59d1b39d7b62bac Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sun, 29 Jun 2008 13:47:07 +0300 Subject: added VIM session detection --- README | 11 +++++++++-- git-demo | 41 +++++++++++++++++++++-------------------- prompt | 19 +++++++++++++++++++ 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/README b/README index 8f5b39b..4b4c359 100644 --- a/README +++ b/README @@ -1,3 +1,10 @@ -Lvv's prompt +GIT Prompt + + Picture worth a thousand words, see wiki for screenshots + + +TODO + limit number of files displayed + VIM module needs to be moved out of GIT module + make module -Picture worth a thousand words, see wiki for screenshots diff --git a/git-demo b/git-demo index e03c939..e14b820 100644 --- a/git-demo +++ b/git-demo @@ -7,31 +7,32 @@ clear mkdir demo cd demo git init -echo "1st line" > FOO -git add FOO -touch untracked.o -rm untracked.o -git commit -q -m "FOO's 1st line" -git checkout -b test -echo "added 2nd line in test" >> FOO -git add FOO +echo 'main() {puts("Hello World!");}' > hello.c +make hello && ./hello +git add hello.c +git commit -q -m "1st hello" +git checkout -b universe; git clean -f +echo 'main() {puts("Hello Universe!");}' > hello.c +git add hello.c echo "1st BAR" > BAR git add BAR -echo "added 3nd line" >> FOO -git add FOO -git commit -q -m "FOO moded, BAR added" +echo "// FIXME: includes" >> hello.c +git add hello.c +git commit -q -m "hello.c moded, BAR added" git checkout master -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 +cat hello.c +echo 'main() {puts("Hello Universe!"); exit(0);}' > hello.c +git add hello.c +git commit -q -m "fixed exit code" +git merge universe +git-cat-file -p universe:hello.c > hello.c +git add hello.c git commit -q -m "merged" -cat FOO +cat hello.c git checkout HEAD^ -cat FOO +cat hello.c git checkout master +sleep 2; echo "this emulates unsaved vim session" > .hello.c.swp +git clean -f : ------------------------------------------------------------------------ cd .. diff --git a/prompt b/prompt index e8f9217..56e0090 100644 --- a/prompt +++ b/prompt @@ -387,13 +387,32 @@ parse_vcs_dir() { eval vcs_color="\${${status}_vcs_color}" # no def: vcs_color=${vcs_color:-$WHITE} # default + + ### VIM ( not yet works for multiple files ) + + unset vim_glob vim_file vim_files + old_nullglob=`shopt -p nullglob` + shopt -s nullglob + vim_glob=`echo .*.swp` + eval $old_nullglob + + if [[ $vim_glob ]]; then + vim_file=${vim_glob#.} + vim_file=${vim_file%.swp} + # if swap is newer, then unsaved vim session + [[ .${vim_file}.swp -nt $vim_file ]] && vim_files=$vim_file + fi + + ### file list unset file_list file_list+=${added_files:+$added_vcs_color$added_files} file_list+=${modified_files:+$modified_vcs_color$modified_files} file_list+=${untracked_files:+$untracked_vcs_color$untracked_files} + file_list+=${vim_files:+ ${RED}VIM:$vim_files} file_list=${file_list:+:$file_list} + tail_local="($vcs_info$vcs_color${file_list}$vcs_color)" ### fringes (added depended on location) -- cgit v1.2.3