mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-12 19:18:28 +02:00
PROMPT_DIR color/bold on last dir & color for sep.
You can now set the last dir to have a custom color with `POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND` and whether it will be bold with `POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true`. You can also set a custom separator color with `POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND`.
This commit is contained in:
parent
6d25e18779
commit
ccba1cc823
@ -421,6 +421,10 @@ You can also configure the `dir` segment to show when you are in a directory wit
|
||||
|----------|---------------|-------------|
|
||||
|`POWERLEVEL9K_DIR_SHOW_WRITABLE`|`false`|If set to `true` and you are in a directory that you do not have write permissions for, this segment will display a lock icon and enter the `NOT_WRITABLE` state (which can be customized per [our usual process](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization)). Note that this functionality is also available in a separate segment, `dir_writable`.|
|
||||
|
||||
If you want to customize the last directory of the path, you can now set `POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND` to a custom color and/or `POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true` to display that part in bold.
|
||||
|
||||
You can also color the separator separately by setting the color using `POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND`.
|
||||
|
||||
##### disk_usage
|
||||
|
||||
The `disk_usage` segment will show the usage level of the partition that your current working directory resides in. It can be configured with the following variables.
|
||||
|
@ -838,18 +838,12 @@ prompt_dir() {
|
||||
esac
|
||||
fi
|
||||
|
||||
local path_opt=$current_path # save state of path for highlighting and bold options
|
||||
|
||||
if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then
|
||||
current_path="${current_path[2,-1]}"
|
||||
fi
|
||||
|
||||
if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" ]]; then
|
||||
current_path="$( echo "${current_path}" | sed "s/\//${POWERLEVEL9K_DIR_PATH_SEPARATOR}/g")"
|
||||
fi
|
||||
|
||||
if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" ]]; then
|
||||
current_path="$( echo "${current_path}" | sed "s/^~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}/")"
|
||||
fi
|
||||
|
||||
typeset -AH dir_states
|
||||
dir_states=(
|
||||
"DEFAULT" "FOLDER_ICON"
|
||||
@ -865,6 +859,34 @@ prompt_dir() {
|
||||
elif [[ $(print -P "%~") == '~'* ]]; then
|
||||
current_state="HOME_SUBFOLDER"
|
||||
fi
|
||||
|
||||
local bd dir_state_foreground dir_state_user_foreground
|
||||
[[ -n "${POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD}" ]] && bd="%B" || bd=""
|
||||
|
||||
local dir_state_user_foreground="POWERLEVEL9K_DIR_${current_state}_FOREGROUND"
|
||||
local dir_state_foreground="${(P)dir_state_user_foreground}"
|
||||
[[ -z "${dir_state_foreground}" ]] && dir_state_foreground="${DEFAULT_COLOR}"
|
||||
|
||||
if [[ -n "${POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}" ]]; then
|
||||
if [[ $path_opt == "/" || $path_opt == "~" || $(dirname $path_opt) == "/" || ${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER} ]]; then
|
||||
current_path="$bd%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}$current_path%F{$dir_state_foreground}"
|
||||
else
|
||||
current_path="$(dirname $current_path)/$bd%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}$(basename $current_path)%F{$dir_state_foreground}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "${POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND}" && $path_opt != "/" ]]; then
|
||||
current_path="$( echo "${current_path}" | sed "s/\//%F{$POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND}\/%F{$dir_state_foreground}/g")"
|
||||
fi
|
||||
|
||||
if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" && $path_opt != "/" ]]; then
|
||||
current_path="$( echo "${current_path}" | sed "s/\//${POWERLEVEL9K_DIR_PATH_SEPARATOR}/g")"
|
||||
fi
|
||||
|
||||
if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" && ! ${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER} ]]; then
|
||||
current_path="$( echo "${current_path}" | sed "s/~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}/1")"
|
||||
fi
|
||||
|
||||
"$1_prompt_segment" "$0_${current_state}" "$2" "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user