aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2017-03-08 23:04:36 +0300
committerGitHub <noreply@github.com>2017-03-08 23:04:36 +0300
commit349b2c315f296a0de6c294cb803a9c691600ed6c (patch)
treeda9f4c1082d329eb186b562726f20b79b802ec75 /powerlevel9k.zsh-theme
parent136a5217e3e3edda968ca191777ffb0408fffa10 (diff)
parent622c04eee3452d753024a488ed4c1b3539e8389f (diff)
Merge pull request #412 from dritter/truncate_composer_json
Truncate via name in composer json
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme11
1 files changed, 10 insertions, 1 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index b6fef65a..f8367e85 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -655,7 +655,16 @@ prompt_dir() {
subdirectory_path=$(truncatePathFromRight "${current_dir:${#${(S%%)package_path//$~zero/}}}")
# Parse the 'name' from the package.json; if there are any problems, just
# print the file path
- local pkgFile="${package_path}/package.json"
+ defined POWERLEVEL9K_DIR_PACKAGE_FILES || POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)
+
+ local pkgFile="unknown"
+ for file in "${POWERLEVEL9K_DIR_PACKAGE_FILES[@]}"; do
+ if [[ -f "${package_path}/${file}" ]]; then
+ pkgFile="${package_path}/${file}"
+ break;
+ fi
+ done
+
local packageName=$(jq '.name' ${pkgFile} 2> /dev/null \
|| node -e 'console.log(require(process.argv[1]).name);' ${pkgFile} 2>/dev/null \
|| cat "${pkgFile}" 2> /dev/null | grep -m 1 "\"name\"" | awk -F ':' '{print $2}' | awk -F '"' '{print $2}' 2>/dev/null \