Skip to content

Instantly share code, notes, and snippets.

@RayPS
Last active April 11, 2023 11:54
Show Gist options
  • Save RayPS/49b2400e3d5fd74273d00925141d4b04 to your computer and use it in GitHub Desktop.
Save RayPS/49b2400e3d5fd74273d00925141d4b04 to your computer and use it in GitHub Desktop.
A zsh theme made for myself, please use with FiraCode font
# https://github.com/zimfw/git-info
# Requires the `git-info` zmodule to be included in the .zimrc file.
if (( ! ${+MAGENTA} )) typeset -g MAGENTA=magenta
if (( ! ${+YELLOW} )) typeset -g YELLOW=yellow
if (( ! ${+GREEN} )) typeset -g GREEN=green
if (( ! ${+CYAN} )) typeset -g CYAN=cyan
if (( ! ${+RED} )) typeset -g RED=red
if (( ! ${+BLUE} )) typeset -g BLUE=blue
if (( ! ${+BLACK} )) typeset -g BLACK=black
if (( ! ${+WHITE} )) typeset -g WHITE=white
setopt nopromptbang prompt{cr,percent,sp,subst}
typeset -gA git_info
if (( ${+functions[git-info]} )); then
zstyle ':zim:git-info' verbose yes
zstyle ':zim:git-info:ahead' format '↑%A'
zstyle ':zim:git-info:behind' format '↓%B'
zstyle ':zim:git-info:branch' format '%b'
zstyle ':zim:git-info:commit' format '%c'
zstyle ':zim:git-info:dirty' format '%F{${RED}}◯%f '
zstyle ':zim:git-info:clean' format '%F{${CYAN}}●%f '
# zstyle ':zim:git-info:added' format '%F{${GREEN}}✚%f '
# zstyle ':zim:git-info:deleted' format '%F{${RED}}✖%f '
# zstyle ':zim:git-info:modified' format '%F{${YELLOW}}●%f '
# zstyle ':zim:git-info:renamed' format '%F{${YELLOW}}»%f '
# zstyle ':zim:git-info:untracked' format '%F{${GREEN}}✦%u%f'
zstyle ':zim:git-info:indexed' format 'indexed %i'
zstyle ':zim:git-info:unindexed' format 'unindexed %I'
# zstyle ':zim:git-info:remote' format '[%R]'
if [[ -n ${STASHED_IND} ]]; then
zstyle ':zim:git-info:stashed' format '%F{${MAGENTA}} ■'
fi
zstyle ':zim:git-info:keys' format \
'prompt' ' (%F{${MAGENTA}}%C%D%b%c%f)%A%B' \
'rprompt' '%i%I'
autoload -Uz add-zsh-hook && add-zsh-hook precmd git-info
fi
user_host() {
local username=%n
local hostname=%m
echo -n %F{${YELLOW}}${username}%f
echo -n '@'
echo -n %F{${RED}}${hostname}%f
}
current_dir() {
local dir=%~
echo -n %F{${CYAN}}${dir}%f
}
conda_info() {
if [ -n "$CONDA_DEFAULT_ENV" ]; then
echo -n %F{${BLACK}}\<$CONDA_DEFAULT_ENV\>%f
fi
}
PS1='┐
├$(user_host) [$(current_dir)] ${(e)git_info[prompt]} $(conda_info)
└%(!.#.➜) '
RPS1='${(e)git_info[rprompt]}'
# Author:
# rayps
# Updated at:
# 2021-07-08 21:05:54
# Font:
# FiraCode
# Expansions:
# http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html
# List all ZSH_THEME_GIT_PROMPT_*:
# grep -o "ZSH_THEME_GIT_[A-Z_]\+" .oh-my-zsh/lib/git.zsh| sort | uniq
# Colors:
# black|red|blue|green|yellow|magenta|cyan|white
# Symbols:
# ▲ ▼ ■ □ ▢ ● ◯ ◎ ↕ ↑ ↓ ◆ ◇ ✖ ✦ ☼ ※ ✹ ▸ » ✓ ✗ ✚ ✖ ✦ ✹ ⚡
# $(git_prompt_info):
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}◯"
ZSH_THEME_GIT_PROMPT_CLEAN="%{%F{green}%}●"
ZSH_THEME_GIT_PROMPT_AHEAD=""
ZSH_THEME_GIT_PROMPT_BEHIND=""
# $(git_prompt_status):
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[cyan]%} ✹"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[cyan]%} »"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[yellow]%} ✦"
ZSH_THEME_GIT_PROMPT_STASHED="%{$fg[magenta]%} ■"
user_host() {
local name="%n"
if [[ "$USER" == "root" ]]; then
name="%{$fg[red]%}$name%{$reset_color%}"
else
name="%{$fg[green]%}$name%{$reset_color%}"
fi
local machine="%{$fg[red]%}%m%{$reset_color%}"
echo "$name@$machine"
}
current_dir() {
echo "%{$fg[cyan]%}%~%{$reset_color%}"
}
proxy_status() {
if [[ "$http_proxy" != "" ]]; then
echo "🌎 "
fi
}
# Git info
git_info() {
if [[ "$(git_prompt_info)" != "" ]]; then
echo " ($(parse_git_dirty) %{%F{magenta}%}$(git_current_branch)%{$reset_color%})"
fi
}
# Git status
git_status() {
ZSH_THEME_GIT_PROMPT_AHEAD="%{%F{red}%}↑%{$reset_color%} %{$fg[blue]%}$(git_commits_ahead) %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_BEHIND="%{%F{red}%}↓%{$reset_color%} %{$fg[blue]%}$(git_commits_behind) %{$reset_color%}"
echo " $(git_prompt_status)%{$reset_color%}"
}
#Conda info
conda_info() {
if [ -n "$CONDA_DEFAULT_ENV" ]; then
echo -n " %{$fg[black]%}<$CONDA_DEFAULT_ENV>%{$reset_color%}"
fi
}
exit_code="%(?,,↑ exit code: %{$fg[red]%}%?%{$reset_color%})"
PROMPT='┐ $exit_code
├$(user_host) [$(current_dir)]$(git_info)$(git_status)$(conda_info)
└%{$(proxy_status)%}%{$fg[cyan]%}➜ %{$reset_color%}'
@RayPS
Copy link
Author

RayPS commented Apr 11, 2019

Screen Shot 2019-04-11 at 16 36 29
USER@MACHINE [PATH] (BRANCH) INFO/STATUS
↑ AHEAD
↓ BEHIND
◯ DIRTY
● CLEAN
✚ ADDED
✹ MODIFIED
✖ DELETED
» RENAMED
═ UNMERGED
✦ UNTRACKED
■ STASHED

Better use with FiraCode font.

Screen Shot 2019-04-15 at 14 36 24 An earth emoji indicates your
http_proxy variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment