From 608ae3752a8719cb43120c9baf706d17b124d9ae Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 4 May 2016 10:47:48 +0200 Subject: Makefile neu, Versionsupdate --- .gitignore | 1 + Makefile | 40 +++++++++++++++++++++++++++++++++ bash-git-prompt | 64 ---------------------------------------------------- bash-git-prompt.in | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 64 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile delete mode 100755 bash-git-prompt create mode 100755 bash-git-prompt.in diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d611c9e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bash-git-prompt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7c29718 --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +# +# bash-git-prompt - nice, git-aware prompt for bash +# +# Copyright (c) 2016 Erich Eckner +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +# USA. +# + +DESTDIR = +BINDIR = /usr/bin + +VERSION = 0.9 + +all: bash-git-prompt + +%: %.in + sed "s/#VERSION#/$(VERSION)/" $< > $@ + +.PHONY: install clean + +install: all + install -D -m0755 -t $(DESTDIR)$(BINDIR) bash-git-prompt + +clean: + rm -f bash-git-prompt + +# End of file diff --git a/bash-git-prompt b/bash-git-prompt deleted file mode 100755 index bc3c3d2..0000000 --- a/bash-git-prompt +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -[[ "$TERM" = *color ]] && mitFarbe=true || mitFarbe=false - -[ -z "$PS1Start" ] && [ -z "$PS1Ende" ] && - if echo "$PS1" | grep -q "\S" - then - PS1Ende="$(echo "$PS1" | sed 's|^.*[^\]\(\\\?[$#>]\s*\([]\\[0-9m]\)*\s*\)$|\1|')" - PS1Start="$(echo "$PS1" | sed 's|\\\?[$#>]\s*\([]\\[0-9m]\)*\s*$||')" - else - PS1Ende="" - PS1Start="$PS1" - fi - -PS1="$PS1Start" - -if status=$(git status --porcelain 2> /dev/null) -then - PS1="$PS1 " - branch="$(git symbolic-ref HEAD 2> /dev/null | sed "s|^.*/||")" - echo "$status" | grep -q "^.\S" && wtClean=false || wtClean=true - echo "$status" | grep -q "^\S" && idxClean=false || idxClean=true - - [ $(git show-ref HEAD "${branch}" --head -s | \ - uniq | \ - wc -l - ) -eq 1 ] && \ - remClean=true || \ - remClean=false - - if $mitFarbe - then - if ! $wtClean - then - PS1="$PS1\[\033[01;31m\]" - elif ! $idxClean - then - PS1="$PS1\[\033[01;33m\]" - elif ! $remClean - then - PS1="$PS1\[\033[01;34m\]" - else - PS1="$PS1\[\033[01;32m\]" - fi - fi - PS1="$PS1$branch" - if $mitFarbe - then - PS1="$PS1\[\033[00m\]" - else - if ! $wtClean - then - PS1="$PS1!" - elif ! $idxClean - then - PS1="$PS1+" - elif ! $remClean - then - PS1="$PS1^" - fi - fi -fi - -PS1="$PS1$PS1Ende" diff --git a/bash-git-prompt.in b/bash-git-prompt.in new file mode 100755 index 0000000..a8ef63b --- /dev/null +++ b/bash-git-prompt.in @@ -0,0 +1,66 @@ +#!/bin/bash + +# bash-git-prompt version #VERSION# + +[[ "$TERM" = *color ]] && mitFarbe=true || mitFarbe=false + +[ -z "$PS1Start" ] && [ -z "$PS1Ende" ] && + if echo "$PS1" | grep -q "\S" + then + PS1Ende="$(echo "$PS1" | sed 's|^.*[^\]\(\\\?[$#>]\s*\([]\\[0-9m]\)*\s*\)$|\1|')" + PS1Start="$(echo "$PS1" | sed 's|\\\?[$#>]\s*\([]\\[0-9m]\)*\s*$||')" + else + PS1Ende="" + PS1Start="$PS1" + fi + +PS1="$PS1Start" + +if status=$(git status --porcelain 2> /dev/null) +then + PS1="$PS1 " + branch="$(git symbolic-ref HEAD 2> /dev/null | sed "s|^.*/||")" + echo "$status" | grep -q "^.\S" && wtClean=false || wtClean=true + echo "$status" | grep -q "^\S" && idxClean=false || idxClean=true + + [ $(git show-ref HEAD "${branch}" --head -s | \ + uniq | \ + wc -l + ) -eq 1 ] && \ + remClean=true || \ + remClean=false + + if $mitFarbe + then + if ! $wtClean + then + PS1="$PS1\[\033[01;31m\]" + elif ! $idxClean + then + PS1="$PS1\[\033[01;33m\]" + elif ! $remClean + then + PS1="$PS1\[\033[01;34m\]" + else + PS1="$PS1\[\033[01;32m\]" + fi + fi + PS1="$PS1$branch" + if $mitFarbe + then + PS1="$PS1\[\033[00m\]" + else + if ! $wtClean + then + PS1="$PS1!" + elif ! $idxClean + then + PS1="$PS1+" + elif ! $remClean + then + PS1="$PS1^" + fi + fi +fi + +PS1="$PS1$PS1Ende" -- cgit v1.2.3-70-g09d2