diff options
author | Christo Kotze <onaforeignshore@hotmail.co.uk> | 2018-02-10 13:46:56 +0300 |
---|---|---|
committer | Christo Kotze <onaforeignshore@hotmail.co.uk> | 2018-02-10 13:46:56 +0300 |
commit | ccba1cc8233143f7e360a3ab3ff61b7175327acf (patch) | |
tree | a5970ad540d39c54875e96d1a3095e1690c00baa /powerlevel9k.zsh-theme | |
parent | 6d25e18779f33cd3339ecd491b3a195a714519ae (diff) |
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`.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 87b453a4..faaa32ec 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -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]}" } |