From ab55e0c1fc1af41e548678dab6a6c122b737666d Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Thu, 29 Aug 2024 09:37:36 +0100 Subject: [PATCH] Add symbol to show OS prompt is running on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will mainly be helpful detecting if I’m in an SSH session or not --- zshrc.zsh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/zshrc.zsh b/zshrc.zsh index f32e362..c4c6bad 100644 --- a/zshrc.zsh +++ b/zshrc.zsh @@ -145,7 +145,23 @@ zstyle ':vcs_info:*:*' check-for-changes true # Set the right prompt to the vcs_info message RPROMPT='%F{8}${vcs_info_msg_0_}' -PROMPT='%(?.%F{blue}⏺.%F{red}⏺)%f %2~ %(!.#.$) ' +# First set a dot that changes colour on success/fail or previous command +PROMPT='%(?.%F{blue}⏺.%F{red}⏺)%f ' +# Show a symbol for the OS +# First we set the os_symbol variable we will use in the prompt +if [[ "$OSTYPE" == "darwin"* ]]; then + os_symbol="" +elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + os_symbol="󰣇" +else + os_symbol="" # Fallback symbol if OS is neither macOS nor Linux +fi + +PROMPT+='${os_symbol} ' +# Then show the working directory +PROMPT+='%2~ ' +# Finally we can adjust the prompt to show if we are a user or sudo +PROMPT+='%(!.#.$) ' # Finally we can have zsh auto source this rc file on command # attribution: https://www.reddit.com/r/commandline/comments/12g76v/