summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-prompt.sh47
-rw-r--r--index.txt20
2 files changed, 32 insertions, 35 deletions
diff --git a/git-prompt.sh b/git-prompt.sh
index d71d9b4..306d96b 100755
--- a/git-prompt.sh
+++ b/git-prompt.sh
@@ -1,4 +1,3 @@
-
# don't set prompt if this is not interactive shell
[[ $- != *i* ]] && return
@@ -309,7 +308,7 @@ set_shell_label() {
host_color=${uphost}_host_color
host_color=${!host_color}
if [[ -z $host_color && -x /usr/bin/cksum ]] ; then
- cksum_color_no=`echo $uphost | cksum | awk '{print $1%7}'`
+ cksum_color_no=`echo $uphost | cksum | awk '{print $1%6}'`
color_index=(green yellow blue magenta cyan white) # FIXME: bw, color-256
host_color=${color_index[cksum_color_no]}
fi
@@ -424,7 +423,7 @@ parse_git_status() {
freshness="$dim"
unset branch status modified added clean init added mixed untracked op detached
- # quoting hell
+ # info not in porcelain status
eval " $(
git status 2>/dev/null |
sed -n '
@@ -435,41 +434,21 @@ parse_git_status() {
s/^# Your branch is ahead of .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${WHITE}↑/p
s/^# Your branch is behind .[/[:alnum:]]\+. by [[:digit:]]\+ commit.*/freshness=${YELLOW}↓/p
s/^# Your branch and .[/[:alnum:]]\+. have diverged.*/freshness=${YELLOW}↕/p
+ '
+ )"
- /^# Changes to be committed:/,/^# [A-Z]/ {
- s/^# Changes to be committed:/added=added;/p
-
- s/^# modified: '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p
- s/^# new file: '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p
- s/^# renamed:[^>]*> '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p
- s/^# copied:[^>]*> '"$file_regex"'/ [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p
- }
-
- /^# Changed but not updated:/,/^# [A-Z]/ {
- s/^# Changed but not updated:/modified=modified;/p
- s/^# modified: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
- s/^# unmerged: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
- }
-
- /^# Changes not staged for commit:/,/^# [A-Z]/ {
- s/^# Changes not staged for commit:/modified=modified;/p
- s/^# modified: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
- s/^# unmerged: '"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
- }
-
- /^# Unmerged paths:/,/^[^#]/ {
- s/^# Unmerged paths:/modified=modified;/p
- s/^# both modified:\s*'"$file_regex"'/ [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
- }
-
- /^# Untracked files:/,/^[^#]/{
- s/^# Untracked files:/untracked=untracked;/p
- s/^# '"$file_regex"'/ [[ \" ${untracked_files[*]} ${modified_files[*]} ${added_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p
- }
+ # porcelain file list
+ # TODO: sed-less -- http://tldp.org/LDP/abs/html/arrays.html -- Example 27-5
+ eval " $(
+ git status --porcelain 2>/dev/null |
+ sed -n '
+ s/^[MARC]. \(.*\)/ added=added; [[ \" ${added_files[*]} \" =~ \" \1 \" ]] || added_files[${#added_files[@]}]=\"\1\"/p
+ s/^.[MAU] \(.*\)/ modified=modified; [[ \" ${modified_files[*]} \" =~ \" \1 \" ]] || modified_files[${#modified_files[@]}]=\"\1\"/p
+ s/^?? \(.*\)/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p
'
)"
- if ! grep -q "^ref:" $git_dir/HEAD 2>/dev/null; then
+ if ! grep -q "^ref:" "$git_dir/HEAD" 2>/dev/null; then
detached=detached
fi
diff --git a/index.txt b/index.txt
index 4ed975b..a48ab80 100644
--- a/index.txt
+++ b/index.txt
@@ -2,6 +2,9 @@
= GIT Prompt
+* Repo: httpx://github.com/lvv/scc[GitHub], httpx://bitbucket.org/lvv/scc[BitBucket] +
+* License: httpx://www.gnu.org/licenses/gpl-3.0.html[GPL3]
+
:v-p: http://volnitsky.com/project
:compact-option: compact
@@ -105,7 +108,19 @@ Some distros also have `/etc/bashrc` or `/etc/bash/bashrc` with distro default
prompt.
-== Config
+
+== GIT config
+
+GIT-PROMPT requires following GIT's option to be set:
+
+-------------------------
+git config [--global] core.quotepath off
+git config [--global] --unset svn.pathnameencoding
+git config [--global] --unset i18n.logoutputencoding
+-----------------------------
+
+
+== GIT-PROMPT config
[[config]]
Is optional. If config file is not found then git-prompt uses defaults.
@@ -158,6 +173,9 @@ dependencies are standard unix utils.
== Todo
+* httpx://jonisalonen.com/2012/your-bash-prompt-needs-this/[]
+* httpx://tldp.org/HOWTO/Bash-Prompt-HOWTO/x810.html[Beep after long running command]
+* httpx://briancarper.net/blog/248/[Sync bash history]
* VIM module needs to be moved out of GIT module
include::../volnitsky.com/project/howto-submit-patch.txt[]