dotfiles/.config/zsh/include/theme

63 lines
1.7 KiB
Bash

#!/bin/env zsh
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
# jj and git support
zstyle ':vcs_info:*' enable jj git
zstyle ':vcs_info:jj:*' formats '%F{5}(jj)  %b %F{1}%c%u %f'
zstyle ':vcs_info:git:*' formats '%F{5}(git)  %b %F{1}%c%u %f'
zstyle ':vcs_info:*' stagedstr 'M'
zstyle ':vcs_info:*' unstagedstr '!'
zstyle ':vcs_info:*' check-for-changes true
# git specific, finding unntracked files
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
+vi-git-untracked() {
# Return early if we're not in git dir
[ $(git rev-parse --is-inside-work-tree 2> /dev/null) = 'true' ] || return 0
# git status ahead
[ ! "$(git status --porcelain -b | grep '^## [^ ]\+ .*ahead')" = "" ] && \
hook_com[unstaged]+='%F{1}⇡%f'
# git untracked
[ $(git ls-files --other --directory --exclude-standard --no-empty-directory | sed q | wc -l | tr -d ' ') = 1 ] && \
hook_com[unstaged]+='%F{1}?%f'
}
function zle-line-init zle-keymap-select {
PS1="""
%B%F{blue}%~ \$vcs_info_msg_0_
${${KEYMAP/vicmd/"%F{cyan}N" }/(main|viins)/"%F{green}I" }$>%f%b """
PS2="%B%F{blue}?>%f%b "
# RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
# RPS2=$RPS1
if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] || [[ ${KEYMAP} == viins ]] || [[ ${KEYMAP} = '' ]] || [[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
_fix_cursor() {
echo -ne '\e[5 q'
}
precmd () {
# Force macOS to be a bit more sane
RPROMPT=""
vcs_info
_fix_cursor
}
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#60C0FF,bold,underline"
ZSH_AUTOSUGGEST_HISTORY_IGNORE="ls *,cd *,z *"