Last active
July 24, 2023 11:05
-
-
Save leekiernan/c59198e91a24ee02e39633b531bba08e to your computer and use it in GitHub Desktop.
lee.zsh-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
function theme_precmd { | |
local TERMWIDTH=$(( COLUMNS - ${ZLE_RPROMPT_INDENT:-3} )) | |
# local TERMWIDTH=20 | |
PR_FILLBAR="" | |
PR_PWDLEN="" | |
local promptsize=${#${(%):---(%D{%H:%M:%S})---()--}} | |
local pwdsize=${#${(%):-%~}} | |
# Truncate the path if it's too long. | |
if (( promptsize + pwdsize > TERMWIDTH )); then | |
(( PR_PWDLEN = TERMWIDTH - promptsize )) | |
elif [[ "${langinfo[CODESET]}" = UTF-8 ]]; then | |
PR_FILLBAR="\${(l:$(( TERMWIDTH - (promptsize + pwdsize) ))::─:)}" | |
else | |
PR_FILLBAR="${PR_SHIFT_IN}\${(l:$(( TERMWIDTH - (promptsize + pwdsize) ))::${altchar[q]:-x-}:)}${PR_SHIFT_OUT}" | |
fi | |
} | |
autoload -U add-zsh-hook | |
add-zsh-hook precmd theme_precmd | |
# Set the prompt | |
# Need this so the prompt will work. | |
setopt prompt_subst | |
# See if we can use colors. | |
autoload zsh/terminfo | |
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do | |
typeset -g PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}" | |
typeset -g PR_LIGHT_$color="%{$fg[${(L)color}]%}" | |
done | |
COLOR_RESET="%{$terminfo[sgr0]%}" | |
COLOR_LINE="${PR_GREY}" | |
COLOR_PWD="${PR_YELLOW}" | |
COLOR_TIME="${PR_GREEN}" | |
COLOR_GIT="${PR_BLUE}" | |
# Modify Git prompt | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} %{%G✹%}" | |
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} %{%G✚%}" | |
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} %{%G✖%}" | |
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} %{%G➜%}" | |
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} %{%G═%}" | |
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} %{%G✭%}" | |
# Finally, the prompt. | |
PROMPT='${COLOR_LINE}┌─( ${COLOR_PWD}%${PR_PWDLEN}<...<%~%<<${COLOR_LINE} )\ | |
${COLOR_LINE}──${(e)PR_FILLBAR}─( ${COLOR_TIME}%D{%H:%M:%S}${COLOR_LINE} )-\ | |
${COLOR_LINE}└─( ${COLOR_GIT}$(git_prompt_info)$(git_prompt_status)\ | |
${COLOR_LINE} )-->\ | |
${COLOR_RESET} ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment