From 708705599d7aff9d445607e8b5f7ff14a591dd35 Mon Sep 17 00:00:00 2001 From: Julien Falque Date: Fri, 31 Mar 2017 08:13:11 +0200 Subject: [PATCH] Make home abbreviation configurable for dir prompt --- README.md | 6 ++++++ powerlevel9k.zsh-theme | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 342792f8..ad2a3e9f 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,12 @@ POWERLEVEL9K_DIR_PATH_SEPARATOR="%F{red} $(print_icon 'LEFT_SUBSEGMENT_SEPARATOR To omit the first character (usually a slash that gets replaced if you set `POWERLEVEL9K_DIR_PATH_SEPARATOR`), you could set `POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true`. +You can also customize the leading tilde character when you are in `$HOME` using: +```zsh +# Double quotes are important here! +POWERLEVEL9K_HOME_FOLDER_ABBREVIATION="%F{red} $(print_icon 'HOME_ICON') %F{black}" +``` + ##### disk_usage diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bbd1ec44..2a9a159f 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -613,6 +613,7 @@ prompt_command_execution_time() { # Dir: current working directory set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" +set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" prompt_dir() { local current_path="$(print -P "%~")" if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then @@ -717,6 +718,10 @@ prompt_dir() { 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"