1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-09-21 11:00:08 +00:00

if auto_name_dirs is set, show directory without named directory support

This commit is contained in:
romkatv 2019-09-04 08:40:24 +02:00
parent 4d63712093
commit b394a601a0

View file

@ -1169,8 +1169,14 @@ function _p9k_shorten_delim_len() {
################################################################
# Dir: current working directory
prompt_dir() {
(( _POWERLEVEL9K_DIR_PATH_ABSOLUTE )) && local p=$_p9k_pwd || local p=${(%):-%~}
if (( _POWERLEVEL9K_DIR_PATH_ABSOLUTE )); then
local p=$_p9k_pwd
local -a parts=("${(s:/:)p}")
elif [[ -o auto_name_dirs ]]; then
local p=${_p9k_pwd/#(#b)$HOME(|\/*)/'~'$match[1]}
local -a parts=("${(s:/:)p}")
else
local p=${(%):-%~}
if [[ $p == '~['* ]]; then
# If "${(%):-%~}" expands to "~[a]/]/b", is the first component "~[a]" or "~[a]/]"?
# One would expect "${(%):-%-1~}" to give the right answer but alas it always simply
@ -1194,6 +1200,7 @@ prompt_dir() {
else
local -a parts=("${(s:/:)p}")
fi
fi
local -i fake_first=0 expand=0
local delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'}
@ -1363,7 +1370,7 @@ prompt_dir() {
[[ $_POWERLEVEL9K_DIR_SHOW_WRITABLE == 1 && ! -w $_p9k_pwd ]]
local w=$?
if ! _p9k_cache_get $0 $_p9k_pwd $w $fake_first "${parts[@]}"; then
if ! _p9k_cache_get $0 $_p9k_pwd $p $w $fake_first "${parts[@]}"; then
local state=$0
local icon=''
if (( ! w )); then
@ -4100,7 +4107,6 @@ _p9k_must_init() {
IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}"
IFS=$'\2' eval "param_sig=x\"$param_sig\""
[[ -o transient_rprompt ]] && param_sig+=t
[[ -o auto_name_dirs ]] && param_sig+=d
[[ $param_sig == $_p9k_param_sig ]] && return 1
[[ -n $_p9k_param_sig ]] && _p9k_deinit
_p9k_param_sig=$param_sig