ohmyzsh/themes/hogwarts.zsh-theme
TheWintersShadow 4c5fa43174 Add Hogwarts Zsh theme
Introduces a new colorful two-line Zsh prompt inspired by Hogwarts houses. The theme displays user@host, time, path, git branch/status, and tmux/screen session info with distinct house colors.
2025-10-08 17:05:25 -04:00

77 lines
2.2 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# =======================================
# Hogwarts Zsh Theme
# Author: TheWinterShadow
# A colorful two-line prompt inspired by Hogwarts houses.
# Shows user@host, time, path, git branch/status, and tmux/screen info.
# =======================================
# Enable prompt substitution (needed for $(...) and colors)
setopt PROMPT_SUBST
# Hogwarts House Colors (ANSI)
user_color="%F{196}" # Scarlet (Gryffindor)
host_color="%F{34}" # Emerald (Slytherin)
screen_color="%F{226}" # Gold (Hufflepuff)
time_color="%F{226}" # Gold (Hufflepuff)
path_color="%F{27}" # Ravenclaw Blue
git_branch_color="%F{196}" # Scarlet
git_status_color="%F{250}" # Light Gray
reset_color="%f"
# Git branch name
parse_git_branch() {
local branch
branch=$(git symbolic-ref --short HEAD 2>/dev/null)
if [[ -n $branch ]]; then
echo "${git_branch_color}git:${branch}${reset_color}"
fi
}
# Git ahead/behind
parse_git_arrows() {
git rev-parse --is-inside-work-tree &>/dev/null || return
local ahead behind
ahead=$(git rev-list --count @{u}..HEAD 2>/dev/null)
behind=$(git rev-list --count HEAD..@{u} 2>/dev/null)
if [[ $ahead -gt 0 || $behind -gt 0 ]]; then
local arrows=""
[[ $ahead -gt 0 ]] && arrows+="${ahead} "
[[ $behind -gt 0 ]] && arrows+="${behind}"
echo "${git_status_color}${arrows}${reset_color}"
fi
}
# Git clean/dirty
parse_git_dirty() {
local git_changes
git_changes=$(git status --porcelain 2>/dev/null)
if [[ -n $git_changes ]]; then
echo "%F{196}✗%f" # Red ✗ for dirty
else
echo "%F{34}✓%f" # Green ✓ for clean
fi
}
# Screen/Tmux session indicator
current_session() {
if [[ -n "$STY" ]]; then
echo "${screen_color}[screen:${STY}]${reset_color}"
elif [[ -n "$TMUX" ]]; then
echo "${screen_color}[tmux:$(tmux display-message -p '#S')]${reset_color}"
fi
}
# First line prompt
PROMPT="%{$user_color%}%n%{$reset_color%}@%{$host_color%}%m%{$reset_color%} \
\$(current_session) \
%{$time_color%}[%*]%{$reset_color%} \
%{$path_color%}%~%{$reset_color%} \
\$(parse_git_branch) \$(parse_git_arrows) \$(parse_git_dirty)
"
# Second line input prompt
PROMPT+="%(?.%F{34}.%F{196})%f "
# No right prompt
RPROMPT=''