X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/973a276791506b72aa9013190b6d9366ab9fd17f..975ad64b1891b5653db9816fd95550896ae2a7a8:/base/.zsh/functions/Prompts/prompt_arrows_setup?ds=sidebyside diff --git a/base/.zsh/functions/Prompts/prompt_arrows_setup b/base/.zsh/functions/Prompts/prompt_arrows_setup index 08f3646..b026822 100644 --- a/base/.zsh/functions/Prompts/prompt_arrows_setup +++ b/base/.zsh/functions/Prompts/prompt_arrows_setup @@ -22,33 +22,38 @@ EOF local prompt_arrows_vimode= function prompt_arrows_setup() { - # TODO: check for color terminal. never will use B&W term but still a XXX - local n p _p s r c d u + prompt_opts=( cr sp percent subst ) + + + # XXX: no checks for color terminal or if escapes work, except for echotc + local m n p s r c d u #TODO remove n? - m="${1:-2line}" # Mode - n="${2:-white}" # Normal - p="${3:-green}" # Prompt - s="${4:-random}" # Ssh prompt - r="${5:-red}" # uRgent - c="${6:-blue}" # Comment - d="${7:-yellow}" # Dir - u="${8:-darkyellow}" # Unwritable + m=${1:-2line} # Mode + n=${2:-white} # Normal + p=${3:-green} # Prompt + s=${4:-random} # Ssh prompt + r=${5:-red} # uRgent + c=${6:-blue} # Comment + d=${7:-yellow} # Dir + u=${8:-darkyellow} # Unwritable # [AC]CURSED COMMAND # concatenate the numerical values of each letter of the hostname, # moduloing by the number of possible colors. - generated=$(uname -n | od -An -td1 | awk -F' ' \ - "{for (i=1; i<=NF; i++) {sum+=1; sum*=\$i; sum%=`echotc Co`} print sum}") - [[ "$p" = 'random' ]] && p=$generated - [[ "$s" = 'random' ]] && s=$generated + x=$(echotc Co) + [[ -z $x ]] && x=8 + local generated=$(uname -n | od -An -td1 | awk -F' ' \ + "{for (i=1; i<=NF; i++) {sum+=1; sum*=\$i; sum%=$(echotc Co)} print sum}") + [[ $p = random ]] && p=$generated + [[ $s = random ]] && s=$generated # use ssh color if connected - p="${${SSH_CLIENT+$s}:-$p}" + [[ -v SSH_CLIENT ]] && p=$s local clock="%F{$n}%T%f" dirvcs="%F{$d}"'${vcs_info_msg_0_:-%~}'"%f" # XXX: linux only local battery=/sys/class/power_supply/BAT0/capacity - [[ -e "$battery" ]] && clock+=" `cat $battery`%%" + [[ -e "$battery" ]] && clock+=' $(cat $battery)%%' local vicol='%F{${${prompt_arrows_vimode:+'"$r"'}:-'"$c"'}}' local hist="%F{$n}%h" case "$m" { @@ -66,7 +71,7 @@ function prompt_arrows_setup() { ;; } PROMPT="$PROMPT%(1j,%F{$c}%j,)$vicol%#%F{$p}%n%F{$n}@%F{$p}%2m%(?..%F{$n}/%F{$r}\$?)%F{$n}: " - POSTEDIT="`print -P "%F{$n}%f"`" + POSTEDIT="$(print -P "%F{$n}%f")" autoload -Uz vcs_info zstyle ':vcs_info:git*' formats "%c%u%%F{$p}%r/%b%%F{$n}/%%F{$d}%S%%f" zstyle ':vcs_info:git*' actionformats "%%F{$r}(%a)%f %c%u%%F{$p}%r/%b%f/%%F{$d}%S%f" @@ -95,5 +100,17 @@ function prompt_arrows_preexec { print -Pn "%F{red}<<<%f " } +function prompt_arrows_preview { + if (( ! $#* )); then + prompt_preview_theme arrows 2line + print '\n' + prompt_preview_theme arrows right + print + else + prompt_preview_theme arrows "$@" + print + fi +} + prompt_arrows_setup "$@" # vim: set et fenc=utf-8 ft=zsh sts=4 sw=4 ts=8 tw=0 :