Skip to content

Instantly share code, notes, and snippets.

@JaxxArmstrong
Last active July 19, 2023 17:36
Show Gist options
  • Save JaxxArmstrong/a58e6233a09e8a9e0288536bd61dab5f to your computer and use it in GitHub Desktop.
Save JaxxArmstrong/a58e6233a09e8a9e0288536bd61dab5f to your computer and use it in GitHub Desktop.
OH-MY-ZSH terminal theme
# OH-MY-ZSH (https://ohmyz.sh/) terminal theme
local black=$fg[black]
local red=$fg[red]
local blue=$fg[blue]
local green=$fg[green]
local yellow=$fg[yellow]
local magenta=$fg[magenta]
local cyan=$fg[cyan]
local white=$fg[white]
local grey=$fg[grey]
local black_bold=$fg_bold[black]
local red_bold=$fg_bold[red]
local blue_bold=$fg_bold[blue]
local green_bold=$fg_bold[green]
local yellow_bold=$fg_bold[yellow]
local magenta_bold=$fg_bold[magenta]
local cyan_bold=$fg_bold[cyan]
local white_bold=$fg_bold[white]
local grey_bold=$fg_bold[grey]
local highlight_bg=$bg[red]
# Git info.
ZSH_THEME_GIT_PROMPT_PREFIX="%{$blue_bold%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$green_bold%} ✔ "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$red_bold%} ✘ "
# Git status.
ZSH_THEME_GIT_PROMPT_ADDED="%{$green_bold%}+"
ZSH_THEME_GIT_PROMPT_DELETED="%{$red_bold%}-"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$magenta_bold%}*"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$blue_bold%}>"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$cyan_bold%}="
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$yellow_bold%}?"
function prompt_char {
if [ $UID -eq 0 ]; then
echo "%{$fg[red]%}❯❯%{$reset_color%}"
else
# echo "🎅 ❯❯" # Santa
echo "❯❯"
fi
}
# Works when being root as well, in comparison to other solutions.
function ssh_status_prompt () {
if [[ $(who am i) =~ "\([-a-zA-Z0-9\.]+\)$" ]]; then
echo "%{$fg[magenta]%}(ssh)%{$reset_color%}"
fi
}
function get_time_stamp {
echo "%*"
}
function get_docker_host {
if [ "$DOCKER_HOST" ]; then
echo "🐳"
fi
}
local NEWLINE=$'\n'
local myuserhost="${NEWLINE}%F{012}%n%{$reset_color%}@%F{012}%m%{$reset_color%}"
local git_branch='$(git_prompt_status)%{$reset_color%}$(git_prompt_info)%{$reset_color%}'
local ssh_info='$(ssh_status_prompt)'
local docker_host='$(get_docker_host)'
local date_time='%{$grey_bold%}[$(get_time_stamp)]%{$reset_color%}'
PROMPT='${myuserhost}: %F{010}${PWD/#$HOME/~}%{$reset_color%}${NEWLINE}$(prompt_char)%{$reset_color%} '
RPROMPT="${docker_host} ${ssh_info} ${git_branch} ${date_time}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment