Last active
November 4, 2023 17:39
-
-
Save rsmets/27f798fbdc30820dba78b83dc1105411 to your computer and use it in GitHub Desktop.
My custom (and favorite) zsh shell theme.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Great Scott! Aliens, arrows and paths! | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}|%{$reset_color%}%{$reset_color%}%{$fg_bold[magenta]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%}%{$fg_bold[blue]%}|%{$reset_color%}👽" | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$reset_color%}%{$fg_bold[blue]%}|" | |
# Create a function to get the prompt path and show absolute path when in $HOME dir | |
prompt_path() { | |
local dir="$PWD" | |
if [[ "$dir" == "$HOME" ]]; then | |
# If in the home directory, print the full path to the home directory | |
echo "${HOME%/*}" | |
return | |
fi | |
# If the path is within the home directory, but not the home directory itself, replace $HOME with ~ | |
dir="${dir/$HOME\//~/}" | |
# Return the full path minus the current directory | |
echo "${dir%/*}" | |
} | |
PROMPT='%{$fg[cyan]%}$(prompt_path)/%{$fg_bold[cyan]%}$(basename $PWD)%{$reset_color%} $(git_prompt_info)' | |
# Show a red arrow if the last command failed, green if succeeded | |
PROMPT+="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )%{$reset_color%}" |
Just for the record the way recommended way to set up this theme is to:
- Put it into your
~/.oh-my-zsh/themes
directory. - Set your
ZSH_THEME
in~/.zshrc
to the theme filename, i.e.razor
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Screenshot of prompt in different scenarios. Clearly, a minimal look but has the relevant bits.