diff options
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0bbeb7c5..ef6d0a5a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -481,7 +481,7 @@ 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 - if name=$( cat "$package_path/package.json" 2> /dev/null | grep "\"name\""); then + if name=$( cat "$package_path/package.json" 2> /dev/null | grep -m 1 "\"name\""); then name=$(echo $name | awk -F ':' '{print $2}' | awk -F '"' '{print $2}') # Instead of printing out the full path, print out the name of the package @@ -927,6 +927,22 @@ prompt_virtualenv() { fi } +# pyenv: current active python version (with restrictions) +# More information on pyenv (Python version manager like rbenv and rvm): +# https://github.com/yyuu/pyenv +# the prompt parses output of pyenv version and only displays the first word +prompt_pyenv() { + local pyenv_version="$(pyenv version 2>/dev/null)" + pyenv_version="${pyenv_version%% *}" + # XXX: The following should return the same as above. + # This reads better for devs familiar with sed/awk/grep/cut utilities + # Using shell expansion/substitution may hamper future maintainability + #local pyenv_version="$(pyenv version 2>/dev/null | head -n1 | cut -d' ' -f1)" + if [[ -n "$pyenv_version" && "$pyenv_version" != "system" ]]; then + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$pyenv_version" 'PYTHON_ICON' + fi +} + ################################################################ # Prompt processing and drawing ################################################################ |