From b5a40bf31a0adead6194129b1e92d364e842a45a Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Thu, 14 Mar 2019 19:15:15 +0100 Subject: [PATCH 1/2] feat(utilities): add p9k::reset_prompt function This function clears every variable from p9k (`egrep -i "^p9k_"`, it's case insensitive) and reloads the default p9k settings (taken from a clean useraccount with only p9k installed and no configuration) closes #1172 --- functions/defaults.zsh | 39 +++++++++++++++++++++++++++++++++++++++ functions/utilities.zsh | 16 ++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 functions/defaults.zsh diff --git a/functions/defaults.zsh b/functions/defaults.zsh new file mode 100644 index 000000000..caed34d81 --- /dev/null +++ b/functions/defaults.zsh @@ -0,0 +1,39 @@ + P9K_BACKGROUND_JOBS_EXPANDED=false + P9K_BACKGROUND_JOBS_VERBOSE=true + P9K_BACKGROUND_JOBS_VERBOSE_ALWAYS=false + P9K_CONTEXT_ALWAYS_SHOW=false + P9K_CONTEXT_ALWAYS_SHOW_USER=false + P9K_CONTEXT_TEMPLATE=%n@%m + P9K_DIR_HOME_FOLDER_ABBREVIATION='~' + P9K_DIR_PACKAGE_FILES=( package.json composer.json ) + P9K_DIR_PATH_ABSOLUTE=false + P9K_DIR_PATH_HIGHLIGHT_BOLD=false + P9K_DIR_PATH_SEPARATOR=/ + P9K_DIR_SHORTEN_DELIMITER='\u2026' + P9K_DIR_SHORTEN_FOLDER_MARKER=.shorten_folder_marker + P9K_IGNORE_TERM_COLORS=false + P9K_IGNORE_TERM_LANG=false + P9K_LEFT_PROMPT_ELEMENTS=( context dir vcs ) + P9K_MIDDLE_WHITESPACE_OF_LEFT_SEGMENTS=' ' + P9K_MIDDLE_WHITESPACE_OF_RIGHT_SEGMENTS=' ' + P9K_PROMPT_ADD_NEWLINE=false + P9K_PROMPT_ELEMENTS=( '' ) + P9K_RIGHT_PROMPT_ELEMENTS=( status root_indicator background_jobs history time ) + P9K_STATUS_CROSS=false + P9K_STATUS_HIDE_SIGNAME=false + P9K_STATUS_OK=true + P9K_STATUS_OK_IN_NON_VERBOSE=false + P9K_STATUS_SHOW_PIPESTATUS=true + P9K_STATUS_VERBOSE=true + P9K_VCS_ACTIONFORMAT_FOREGROUND=red + P9K_VCS_DIR_SHORTEN_DELIMITER=… + P9K_VCS_GIT_ALWAYS_SHOW_REMOTE_BRANCH=false + P9K_VCS_GIT_HOOKS=( vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-gitdir git-tagname ) + P9K_VCS_HG_HOOKS=( vcs-detect-changes ) + P9K_VCS_HIDE_TAGS=false + P9K_VCS_INTERNAL_HASH_LENGTH=8 + P9K_VCS_SHOW_SUBMODULE_DIRTY=true + P9K_VCS_SVN_HOOKS=( vcs-detect-changes svn-detect-changes ) + P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=' ' + P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=' ' + diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 84df6c64d..21f18d973 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -449,3 +449,19 @@ function p9k::parseIp() { return 1 } +############################################################### +# @description +# Unsets every P9K Variable and restores installation defaults +# @noargs +## +function p9k::reset_prompt() { + while read p9kVariablePair; do + local p9kVariable=(${(@s/=/)p9kVariablePair}) + local p9kVariableName=${p9kVariable[1]} + if [[ "${p9kVariableName}" != "P9K_VERSION" ]]; then + unset $p9kVariableName; + fi + done < <(setopt ; set | egrep -i "^p9k_") + + source "${__P9K_DIRECTORY}/functions/defaults.zsh" +} From 602f2eaabdb583fbf53630851e18de7b524dfb7a Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Thu, 14 Mar 2019 21:00:58 +0100 Subject: [PATCH 2/2] fix: add --color=never to egrep refers to #1184 --- functions/utilities.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 21f18d973..6039b3423 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -461,7 +461,7 @@ function p9k::reset_prompt() { if [[ "${p9kVariableName}" != "P9K_VERSION" ]]; then unset $p9kVariableName; fi - done < <(setopt ; set | egrep -i "^p9k_") + done < <(setopt ; set | egrep --color=never -i "^p9k_") source "${__P9K_DIRECTORY}/functions/defaults.zsh" }