[packages/rpm-build-tools] include current VERSION from spec in PS1

glen glen at pld-linux.org
Sat Jan 9 16:55:33 CET 2016


commit 4299a37c54933882ebe40d95637c361aa18d3d95
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sat Jan 9 17:54:55 2016 +0200

    include current VERSION from spec in PS1

 shrc.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/shrc.sh b/shrc.sh
index 05ec24c..d0f91f7 100755
--- 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
+}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/4299a37c54933882ebe40d95637c361aa18d3d95



More information about the pld-cvs-commit mailing list