summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2017-02-24 03:24:16 +0300
committerDominik Ritter <dritter03@googlemail.com>2017-02-24 03:24:16 +0300
commitec044c028ae0780a1579c22c72960411c6b59458 (patch)
tree8743b48d048e79090ba5df82da7d05f799562437 /powerlevel9k.zsh-theme
parenta0aa5ccbfcabda100249f710de9297ffa1444fbb (diff)
Add functionality to truncate via `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..b585911f 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 \