mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-29 06:40:08 +00:00
Incorporated @dritter 's changes into next
These are the changes made by @dritter on `async_all_the_segments`
This commit is contained in:
parent
fd3d234354
commit
085a78b9b8
1 changed files with 9 additions and 38 deletions
|
@ -718,21 +718,20 @@ prompt_command_execution_time() {
|
||||||
# Dir: current working directory
|
# Dir: current working directory
|
||||||
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/"
|
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/"
|
||||||
set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~"
|
set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~"
|
||||||
set_default POWERLEVEL9K_DIR_SHOW_WRITABLE false
|
# Parameters:
|
||||||
|
# * $1 Alignment: string - left|right
|
||||||
|
# * $2 Index: integer
|
||||||
prompt_dir() {
|
prompt_dir() {
|
||||||
local tmp="$IFS"
|
local current_path="$(print -P "%~")"
|
||||||
local IFS=""
|
|
||||||
local current_path=$(pwd | sed -e "s,^$HOME,~,")
|
|
||||||
local IFS="$tmp"
|
|
||||||
if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then
|
if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then
|
||||||
set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026'
|
set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026'
|
||||||
|
|
||||||
case "$POWERLEVEL9K_SHORTEN_STRATEGY" in
|
case "$POWERLEVEL9K_SHORTEN_STRATEGY" in
|
||||||
truncate_middle)
|
truncate_middle)
|
||||||
current_path=$(echo "$current_path" | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\2\//g")
|
current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\2\//g")
|
||||||
;;
|
;;
|
||||||
truncate_from_right)
|
truncate_from_right)
|
||||||
current_path=$(truncatePathFromRight "$current_path" )
|
current_path=$(truncatePathFromRight "$(pwd | sed -e "s,^$HOME,~,")" )
|
||||||
;;
|
;;
|
||||||
truncate_with_package_name)
|
truncate_with_package_name)
|
||||||
local name repo_path package_path current_dir zero
|
local name repo_path package_path current_dir zero
|
||||||
|
@ -782,12 +781,8 @@ prompt_dir() {
|
||||||
# Instead of printing out the full path, print out the name of the package
|
# Instead of printing out the full path, print out the name of the package
|
||||||
# from the package.json and append the current subdirectory
|
# from the package.json and append the current subdirectory
|
||||||
current_path="`echo $packageName | tr -d '"'`$subdirectory_path"
|
current_path="`echo $packageName | tr -d '"'`$subdirectory_path"
|
||||||
if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then
|
|
||||||
# add space before the packageName to allow for removing the "first" character, without messing up the package name.
|
|
||||||
current_path=" ${current_path}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
current_path=$(truncatePathFromRight "$current_path" )
|
current_path=$(truncatePathFromRight "$(pwd | sed -e "s,^$HOME,~,")" )
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
truncate_with_folder_marker)
|
truncate_with_folder_marker)
|
||||||
|
@ -816,27 +811,6 @@ prompt_dir() {
|
||||||
# the current path.
|
# the current path.
|
||||||
current_path=$current_path${PWD#${last_marked_folder}*}
|
current_path=$current_path${PWD#${last_marked_folder}*}
|
||||||
;;
|
;;
|
||||||
truncate_to_unique)
|
|
||||||
# for each parent path component find the shortest unique beginning
|
|
||||||
# characters sequence. Source: https://stackoverflow.com/a/45336078
|
|
||||||
paths=(${(s:/:)PWD})
|
|
||||||
cur_path='/'
|
|
||||||
cur_short_path='/'
|
|
||||||
for directory in ${paths[@]}
|
|
||||||
do
|
|
||||||
cur_dir=''
|
|
||||||
for (( i=0; i<${#directory}; i++ )); do
|
|
||||||
cur_dir+="${directory:$i:1}"
|
|
||||||
matching=("$cur_path"/"$cur_dir"*/)
|
|
||||||
if [[ ${#matching[@]} -eq 1 ]]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
cur_short_path+="$cur_dir/"
|
|
||||||
cur_path+="$directory/"
|
|
||||||
done
|
|
||||||
current_path="${cur_short_path: : -1}"
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")"
|
current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")"
|
||||||
;;
|
;;
|
||||||
|
@ -852,7 +826,7 @@ prompt_dir() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" ]]; then
|
if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" ]]; then
|
||||||
current_path=${current_path/#\~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}}
|
current_path="$( echo "${current_path}" | sed "s/^~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}/")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
typeset -AH dir_states
|
typeset -AH dir_states
|
||||||
|
@ -860,12 +834,9 @@ prompt_dir() {
|
||||||
"DEFAULT" "FOLDER_ICON"
|
"DEFAULT" "FOLDER_ICON"
|
||||||
"HOME" "HOME_ICON"
|
"HOME" "HOME_ICON"
|
||||||
"HOME_SUBFOLDER" "HOME_SUB_ICON"
|
"HOME_SUBFOLDER" "HOME_SUB_ICON"
|
||||||
"NOT_WRITABLE" "LOCK_ICON"
|
|
||||||
)
|
)
|
||||||
local current_state="DEFAULT"
|
local current_state="DEFAULT"
|
||||||
if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then
|
if [[ $(print -P "%~") == '~' ]]; then
|
||||||
current_state="NOT_WRITABLE"
|
|
||||||
elif [[ $(print -P "%~") == '~' ]]; then
|
|
||||||
current_state="HOME"
|
current_state="HOME"
|
||||||
elif [[ $(print -P "%~") == '~'* ]]; then
|
elif [[ $(print -P "%~") == '~'* ]]; then
|
||||||
current_state="HOME_SUBFOLDER"
|
current_state="HOME_SUBFOLDER"
|
||||||
|
|
Loading…
Reference in a new issue