]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
include current VERSION from spec in PS1
authorElan Ruusamäe <glen@delfi.ee>
Sat, 9 Jan 2016 15:54:55 +0000 (17:54 +0200)
committerElan Ruusamäe <glen@delfi.ee>
Sat, 9 Jan 2016 15:54:55 +0000 (17:54 +0200)
shrc.sh

diff --git a/shrc.sh b/shrc.sh
index 05ec24ca5db1c2e26a877ed3fefdfc44c6f1e68d..d0f91f7b6fb9a18739da061b53fd24b903eb3df4 100755 (executable)
--- a/shrc.sh
+++ b/shrc.sh
@@ -286,7 +286,8 @@ __bash_prompt_command() {
        local LIGHT_GRAY="\[\033[0;37m\]"
        local COLOR_NONE="\[\e[0m\]"
 
-       local prompt="${BLUE}[${RED}\w${GREEN}$(__bash_parse_git_branch)${BLUE}]${COLOR_NONE} "
+       local rpmver=$(__package_rpmversion)
+       local prompt="${BLUE}[${RED}\w${GREEN}${rpmver:+($rpmver)}$(parse_git_branch)${BLUE}]${COLOR_NONE} "
        if [ $previous_return_value -eq 0 ]; then
                PS1="${prompt}➔ "
        else
@@ -331,3 +332,11 @@ __bash_parse_git_branch() {
                echo " (${branch})${remote}${state}"
        fi
 }
+
+# if we are in rpm subdir and have exactly one .spec in the dir, include package version
+__package_rpmversion() {
+       if [[ $PWD =~ $(rpm -E %_topdir) ]] && [ "$(echo *.spec | wc -w)" = 1 ]; then
+               # give only first version (ignore subpackages)
+               rpm --specfile *.spec -q --qf '%{VERSION}\n' | head -n1
+       fi
+}
This page took 0.031162 seconds and 4 git commands to generate.