diff options
author | romkatv <roman.perepelitsa@gmail.com> | 2020-02-15 16:35:09 +0300 |
---|---|---|
committer | romkatv <roman.perepelitsa@gmail.com> | 2020-02-15 16:35:09 +0300 |
commit | 84097d907388b37d24b0a3164fab7cfeb68cef4e (patch) | |
tree | 047c470bb2f6abe86fb011c0123675cdeb3f3b69 | |
parent | b8a949498f00eaf2b56b20c133cdffe900fad9b3 (diff) |
speed up laravel_version
-rw-r--r-- | internal/p10k.zsh | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 6dc38561..7e9e0ad2 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2100,12 +2100,16 @@ prompt_vpn_ip() { ################################################################ # Segment to display laravel version prompt_laravel_version() { - local laravel_version="$(php artisan --version 2> /dev/null)" - if [[ -n "${laravel_version}" && "${laravel_version}" =~ "Laravel Framework" ]]; then - # Strip out everything but the version - laravel_version="${laravel_version//Laravel Framework /}" - _p9k_prompt_segment "$0" "maroon" "white" 'LARAVEL_ICON' 0 '' "${laravel_version//\%/%%}" + _p9k_upglob artisan && return + local dir=$_p9k__parent_dirs[$?] + local app=$dir/vendor/laravel/framework/src/Illuminate/Foundation/Application.php + [[ -r $app ]] || return + if ! _p9k_cache_stat_get $0 $dir/artisan $app; then + local v="$(php $dir/artisan --version 2> /dev/null)" + _p9k_cache_stat_set "${${(M)v:#Laravel Framework *}#Laravel Framework }" fi + [[ -n $_p9k__cache_val[1] ]] || return + _p9k_prompt_segment "$0" "maroon" "white" 'LARAVEL_ICON' 0 '' "${_p9k__cache_val[1]//\%/%%}" } _p9k_prompt_laravel_version_init() { |