Skip to content

Instantly share code, notes, and snippets.

@rsmets
Last active November 4, 2023 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsmets/27f798fbdc30820dba78b83dc1105411 to your computer and use it in GitHub Desktop.
Save rsmets/27f798fbdc30820dba78b83dc1105411 to your computer and use it in GitHub Desktop.
My custom (and favorite) zsh shell theme.
# 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%}"
@rsmets
Copy link
Author

rsmets commented Aug 11, 2023

Screenshot of prompt in different scenarios. Clearly, a minimal look but has the relevant bits.

Screenshot 2023-08-11 at 9 09 43 AM

@rsmets
Copy link
Author

rsmets commented Nov 4, 2023

Just for the record the way recommended way to set up this theme is to:

  1. Put it into your ~/.oh-my-zsh/themes directory.
  2. 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