From c47ac2d86d1aec3dcc3106c58d3ef0a91aa8cc3c Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Wed, 25 Aug 2021 10:25:26 +0200 Subject: [PATCH] feat(mlh): let users configure the official MLH theme (#9997) --- themes/mlh.zsh-theme | 51 +++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/themes/mlh.zsh-theme b/themes/mlh.zsh-theme index 33f238ed9..baff3fb63 100644 --- a/themes/mlh.zsh-theme +++ b/themes/mlh.zsh-theme @@ -12,17 +12,40 @@ # # # Feel free to customize! # # # # # # # # # # # # # # # # # # # # # +# To customize symbols (e.g MLH_AT_SYMBOL), simply set them as environment variables +# for example in your ~/.zshrc file, like this: +# MLH_AT_SYMBOL=" at " +# +# Settings *must* be set before sourcing oh-my-zsh.sh the .zshrc file. +# # To easily discover colors and their codes, type `spectrum_ls` in the terminal -# enable or disable particular elements -PRINT_EXIT_CODE=true -PRINT_TIME=true +# right prompt default settings +if [ -z "$MLH_PRINT_EXIT_CODE" ]; then + MLH_PRINT_EXIT_CODE=true +fi -# symbols -AT_SYMBOL=" @ " -IN_SYMBOL=" in " -ON_SYMBOL=" on " -SHELL_SYMBOL="$" +if [ -z "$MLH_PRINT_TIME" ]; then + MLH_PRINT_TIME=false +fi + +# left prompt symbols default settings + +if [ -z "$MLH_AT_SYMBOL" ]; then + MLH_AT_SYMBOL="@" +fi + +if [ -z "$MLH_IN_SYMBOL" ]; then + MLH_IN_SYMBOL=" in " +fi + +if [ -z "$MLH_ON_SYMBOL" ]; then + MLH_ON_SYMBOL=" on " +fi + +if [ -z "$MLH_SHELL_SYMBOL" ]; then + MLH_SHELL_SYMBOL="$ " +fi # colors USER_COLOR="%F{001}" @@ -47,24 +70,28 @@ directory() { # Prints current time current_time() { - if [ "$PRINT_TIME" = true ]; then + if [ "$MLH_PRINT_TIME" = true ]; then echo " $TIME_COLOR%*%f" fi } # Prints exit code of the last executed command exit_code() { - if [ "$PRINT_EXIT_CODE" = true ]; then + if [ "$MLH_PRINT_EXIT_CODE" = true ]; then echo "%(?..%F{001}exit %?)%f" fi } +prompt_end() { + printf "\n$MLH_SHELL_SYMBOL" +} + # Set git_prompt_info text -ZSH_THEME_GIT_PROMPT_PREFIX="${ON_SYMBOL}${BRANCH_COLOR}" +ZSH_THEME_GIT_PROMPT_PREFIX="${MLH_ON_SYMBOL}${BRANCH_COLOR}" ZSH_THEME_GIT_PROMPT_SUFFIX="%f" ZSH_THEME_GIT_PROMPT_DIRTY="" ZSH_THEME_GIT_PROMPT_CLEAN="" # %B and %b make the text bold -PROMPT='%b$(username)$AT_SYMBOL$(device)$IN_SYMBOL$(directory)$(git_prompt_info)%b $SHELL_SYMBOL ' +PROMPT='%b$(username)$MLH_AT_SYMBOL$(device)$MLH_IN_SYMBOL$(directory)$(git_prompt_info)%b$(prompt_end)' RPROMPT="$(exit_code)$(current_time)"