show maven project in current directory
This commit is contained in:
parent
45cbd4d7f1
commit
4be4063ec7
34
.zshrc
34
.zshrc
@ -20,6 +20,12 @@ CROSS="\u2718"
|
|||||||
LIGHTNING="\u26a1"
|
LIGHTNING="\u26a1"
|
||||||
GEAR="\u2699"
|
GEAR="\u2699"
|
||||||
BULLET="\u2022"
|
BULLET="\u2022"
|
||||||
|
CROSSING="\u292c"
|
||||||
|
|
||||||
|
# Project in current directory
|
||||||
|
MAVEN_PROJECT_ARTIFACT=""
|
||||||
|
MAVEN_PROJECT_VERSION=""
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------- Tab completion ----------------------------
|
#---------------------------------- Tab completion ----------------------------
|
||||||
|
|
||||||
@ -147,8 +153,14 @@ prompt_vcs() {
|
|||||||
local ref
|
local ref
|
||||||
ref="$vcs_info_msg_0_"
|
ref="$vcs_info_msg_0_"
|
||||||
if [[ -n "$ref" ]]; then
|
if [[ -n "$ref" ]]; then
|
||||||
prompt_segment yellow $PRIMARY_FG
|
prompt_segment yellow $PRIMARY_FG " $ref "
|
||||||
print -Pn " $ref"
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dir: current working directory
|
||||||
|
prompt_mvn() {
|
||||||
|
if [[ -n "$MAVEN_PROJECT_ARTIFACT" ]]; then
|
||||||
|
prompt_segment magenta $PRIMARY_FG " $MAVEN_PROJECT_ARTIFACT@$MAVEN_PROJECT_VERSION "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,6 +205,7 @@ prompt_main() {
|
|||||||
prompt_user
|
prompt_user
|
||||||
prompt_host
|
prompt_host
|
||||||
prompt_dir
|
prompt_dir
|
||||||
|
prompt_mvn
|
||||||
prompt_vcs
|
prompt_vcs
|
||||||
prompt_end
|
prompt_end
|
||||||
}
|
}
|
||||||
@ -385,6 +398,23 @@ mvn-color()
|
|||||||
}
|
}
|
||||||
alias mvn='mvn-color'
|
alias mvn='mvn-color'
|
||||||
|
|
||||||
|
MAVEN_PROJECT_ARTIFACT=""
|
||||||
|
MAVEN_PROJECT_VERSION=""
|
||||||
|
|
||||||
|
maven_read_project() {
|
||||||
|
local pom_contents
|
||||||
|
if [[ ! -r "pom.xml" ]]; then
|
||||||
|
MAVEN_PROJECT_ARTIFACT=""
|
||||||
|
MAVEN_PROJECT_VERSION=""
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
pom_contents=$(cat pom.xml)
|
||||||
|
MAVEN_PROJECT_ARTIFACT=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='artifactId']/text()" - <<< "$pom_contents")
|
||||||
|
MAVEN_PROJECT_VERSION=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" - <<< "$pom_contents")
|
||||||
|
}
|
||||||
|
|
||||||
|
add-zsh-hook chpwd maven_read_project
|
||||||
|
|
||||||
#---------------------------------- Miscellaneous ----------------------------
|
#---------------------------------- Miscellaneous ----------------------------
|
||||||
|
|
||||||
setopt autocd
|
setopt autocd
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user