diff --git a/.config/nvim b/.config/nvim index 8fb1afa..54fe9c5 160000 --- a/.config/nvim +++ b/.config/nvim @@ -1 +1 @@ -Subproject commit 8fb1afa21aad5f078797e373ebb64fb506dfe19e +Subproject commit 54fe9c5a793a2fe57cb99f4c466fe92aa5208c9e diff --git a/.gitignore b/.gitignore index 4f8d624..a32dde6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,9 +7,13 @@ !.config/nvim !.config/nvim/** !.config/kitty -!.config/kitty/* +!.config/kitty/** !.gitignore !.zsh !.zsh/** !.tmux.conf !.gitconfig +!.local/fzf +!.local/fzf/** +!.local/nvim +!.local/nvim/** diff --git a/.local/share/fzf/completion.bash b/.local/share/fzf/completion.bash new file mode 100644 index 0000000..51687a0 --- /dev/null +++ b/.local/share/fzf/completion.bash @@ -0,0 +1,381 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ completion.bash +# +# - $FZF_TMUX (default: 0) +# - $FZF_TMUX_OPTS (default: empty) +# - $FZF_COMPLETION_TRIGGER (default: '**') +# - $FZF_COMPLETION_OPTS (default: empty) + +if [[ $- =~ i ]]; then + +# To use custom commands instead of find, override _fzf_compgen_{path,dir} +if ! declare -f _fzf_compgen_path > /dev/null; then + _fzf_compgen_path() { + echo "$1" + command find -L "$1" \ + -name .git -prune -o -name .hg -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } +fi + +if ! declare -f _fzf_compgen_dir > /dev/null; then + _fzf_compgen_dir() { + command find -L "$1" \ + -name .git -prune -o -name .hg -prune -o -name .svn -prune -o -type d \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } +fi + +########################################################### + +# To redraw line after fzf closes (printf '\e[5n') +bind '"\e[0n": redraw-current-line' 2> /dev/null + +__fzf_comprun() { + if [[ "$(type -t _fzf_comprun 2>&1)" = function ]]; then + _fzf_comprun "$@" + elif [[ -n "${TMUX_PANE-}" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "${FZF_TMUX_OPTS-}" ]]; }; then + shift + fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- "$@" + else + shift + fzf "$@" + fi +} + +__fzf_orig_completion() { + local l comp f cmd + while read -r l; do + if [[ "$l" =~ ^(.*\ -F)\ *([^ ]*).*\ ([^ ]*)$ ]]; then + comp="${BASH_REMATCH[1]}" + f="${BASH_REMATCH[2]}" + cmd="${BASH_REMATCH[3]}" + [[ "$f" = _fzf_* ]] && continue + printf -v "_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}" "%s" "${comp} %s ${cmd} #${f}" + if [[ "$l" = *" -o nospace "* ]] && [[ ! "${__fzf_nospace_commands-}" = *" $cmd "* ]]; then + __fzf_nospace_commands="${__fzf_nospace_commands-} $cmd " + fi + fi + done +} + +_fzf_opts_completion() { + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts=" + -x --extended + -e --exact + --algo + -i +i + -n --nth + --with-nth + -d --delimiter + +s --no-sort + --tac + --tiebreak + -m --multi + --no-mouse + --bind + --cycle + --no-hscroll + --jump-labels + --height + --literal + --reverse + --margin + --inline-info + --prompt + --pointer + --marker + --header + --header-lines + --ansi + --tabstop + --color + --no-bold + --history + --history-size + --preview + --preview-window + -q --query + -1 --select-1 + -0 --exit-0 + -f --filter + --print-query + --expect + --sync" + + case "${prev}" in + --tiebreak) + COMPREPLY=( $(compgen -W "length begin end index" -- "$cur") ) + return 0 + ;; + --color) + COMPREPLY=( $(compgen -W "dark light 16 bw" -- "$cur") ) + return 0 + ;; + --history) + COMPREPLY=() + return 0 + ;; + esac + + if [[ "$cur" =~ ^-|\+ ]]; then + COMPREPLY=( $(compgen -W "${opts}" -- "$cur") ) + return 0 + fi + + return 0 +} + +_fzf_handle_dynamic_completion() { + local cmd orig_var orig ret orig_cmd orig_complete + cmd="$1" + shift + orig_cmd="$1" + orig_var="_fzf_orig_completion_$cmd" + orig="${!orig_var-}" + orig="${orig##*#}" + if [[ -n "$orig" ]] && type "$orig" > /dev/null 2>&1; then + $orig "$@" + elif [[ -n "${_fzf_completion_loader-}" ]]; then + orig_complete=$(complete -p "$orig_cmd" 2> /dev/null) + _completion_loader "$@" + ret=$? + # _completion_loader may not have updated completion for the command + if [[ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]]; then + __fzf_orig_completion < <(complete -p "$orig_cmd" 2> /dev/null) + if [[ "${__fzf_nospace_commands-}" = *" $orig_cmd "* ]]; then + eval "${orig_complete/ -F / -o nospace -F }" + else + eval "$orig_complete" + fi + fi + return $ret + fi +} + +__fzf_generic_path_completion() { + local cur base dir leftover matches trigger cmd + cmd="${COMP_WORDS[0]}" + if [[ $cmd == \\* ]]; then + cmd="${cmd:1}" + fi + cmd="${cmd//[^A-Za-z0-9_=]/_}" + COMPREPLY=() + trigger=${FZF_COMPLETION_TRIGGER-'**'} + cur="${COMP_WORDS[COMP_CWORD]}" + if [[ "$cur" == *"$trigger" ]]; then + base=${cur:0:${#cur}-${#trigger}} + eval "base=$base" + + dir= + [[ $base = *"/"* ]] && dir="$base" + while true; do + if [[ -z "$dir" ]] || [[ -d "$dir" ]]; then + leftover=${base/#"$dir"} + leftover=${leftover/#\/} + [[ -z "$dir" ]] && dir='.' + [[ "$dir" != "/" ]] && dir="${dir/%\//}" + matches=$(eval "$1 $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-} $2" __fzf_comprun "$4" -q "$leftover" | while read -r item; do + printf "%q " "${item%$3}$3" + done) + matches=${matches% } + [[ -z "$3" ]] && [[ "${__fzf_nospace_commands-}" = *" ${COMP_WORDS[0]} "* ]] && matches="$matches " + if [[ -n "$matches" ]]; then + COMPREPLY=( "$matches" ) + else + COMPREPLY=( "$cur" ) + fi + printf '\e[5n' + return 0 + fi + dir=$(dirname "$dir") + [[ "$dir" =~ /$ ]] || dir="$dir"/ + done + else + shift + shift + shift + _fzf_handle_dynamic_completion "$cmd" "$@" + fi +} + +_fzf_complete() { + # Split arguments around -- + local args rest str_arg i sep + args=("$@") + sep= + for i in "${!args[@]}"; do + if [[ "${args[$i]}" = -- ]]; then + sep=$i + break + fi + done + if [[ -n "$sep" ]]; then + str_arg= + rest=("${args[@]:$((sep + 1)):${#args[@]}}") + args=("${args[@]:0:$sep}") + else + str_arg=$1 + args=() + shift + rest=("$@") + fi + + local cur selected trigger cmd post + post="$(caller 0 | awk '{print $2}')_post" + type -t "$post" > /dev/null 2>&1 || post=cat + + cmd="${COMP_WORDS[0]//[^A-Za-z0-9_=]/_}" + trigger=${FZF_COMPLETION_TRIGGER-'**'} + cur="${COMP_WORDS[COMP_CWORD]}" + if [[ "$cur" == *"$trigger" ]]; then + cur=${cur:0:${#cur}-${#trigger}} + + selected=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-} $str_arg" __fzf_comprun "${rest[0]}" "${args[@]}" -q "$cur" | $post | tr '\n' ' ') + selected=${selected% } # Strip trailing space not to repeat "-o nospace" + if [[ -n "$selected" ]]; then + COMPREPLY=("$selected") + else + COMPREPLY=("$cur") + fi + printf '\e[5n' + return 0 + else + _fzf_handle_dynamic_completion "$cmd" "${rest[@]}" + fi +} + +_fzf_path_completion() { + __fzf_generic_path_completion _fzf_compgen_path "-m" "" "$@" +} + +# Deprecated. No file only completion. +_fzf_file_completion() { + _fzf_path_completion "$@" +} + +_fzf_dir_completion() { + __fzf_generic_path_completion _fzf_compgen_dir "" "/" "$@" +} + +_fzf_complete_kill() { + _fzf_proc_completion "$@" +} + +_fzf_proc_completion() { + _fzf_complete -m --preview 'echo {}' --preview-window down:3:wrap --min-height 15 -- "$@" < <( + command ps -ef | sed 1d + ) +} + +_fzf_proc_completion_post() { + awk '{print $2}' +} + +_fzf_host_completion() { + _fzf_complete +m -- "$@" < <( + command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') \ + <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \ + <(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') | + awk '{if (length($2) > 0) {print $2}}' | sort -u + ) +} + +_fzf_var_completion() { + _fzf_complete -m -- "$@" < <( + declare -xp | sed -En 's|^declare [^ ]+ ([^=]+).*|\1|p' + ) +} + +_fzf_alias_completion() { + _fzf_complete -m -- "$@" < <( + alias | sed -En 's|^alias ([^=]+).*|\1|p' + ) +} + +# fzf options +complete -o default -F _fzf_opts_completion fzf +# fzf-tmux is a thin fzf wrapper that has only a few more options than fzf +# itself. As a quick improvement we take fzf's completion. Adding the few extra +# fzf-tmux specific options (like `-w WIDTH`) are left as a future patch. +complete -o default -F _fzf_opts_completion fzf-tmux + +d_cmds="${FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir}" +a_cmds=" + awk cat diff diff3 + emacs emacsclient ex file ftp g++ gcc gvim head hg java + javac ld less more mvim nvim patch perl python ruby + sed sftp sort source tail tee uniq vi view vim wc xdg-open + basename bunzip2 bzip2 chmod chown curl cp dirname du + find git grep gunzip gzip hg jar + ln ls mv open rm rsync scp + svn tar unzip zip" + +# Preserve existing completion +__fzf_orig_completion < <(complete -p $d_cmds $a_cmds 2> /dev/null) + +if type _completion_loader > /dev/null 2>&1; then + _fzf_completion_loader=1 +fi + +__fzf_defc() { + local cmd func opts orig_var orig def + cmd="$1" + func="$2" + opts="$3" + orig_var="_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}" + orig="${!orig_var-}" + if [[ -n "$orig" ]]; then + printf -v def "$orig" "$func" + eval "$def" + else + complete -F "$func" $opts "$cmd" + fi +} + +# Anything +for cmd in $a_cmds; do + __fzf_defc "$cmd" _fzf_path_completion "-o default -o bashdefault" +done + +# Directory +for cmd in $d_cmds; do + __fzf_defc "$cmd" _fzf_dir_completion "-o nospace -o dirnames" +done + +unset cmd d_cmds a_cmds + +_fzf_setup_completion() { + local kind fn cmd + kind=$1 + fn=_fzf_${1}_completion + if [[ $# -lt 2 ]] || ! type -t "$fn" > /dev/null; then + echo "usage: ${FUNCNAME[0]} path|dir|var|alias|host|proc COMMANDS..." + return 1 + fi + shift + __fzf_orig_completion < <(complete -p "$@" 2> /dev/null) + for cmd in "$@"; do + case "$kind" in + dir) __fzf_defc "$cmd" "$fn" "-o nospace -o dirnames" ;; + var) __fzf_defc "$cmd" "$fn" "-o default -o nospace -v" ;; + alias) __fzf_defc "$cmd" "$fn" "-a" ;; + *) __fzf_defc "$cmd" "$fn" "-o default -o bashdefault" ;; + esac + done +} + +# Environment variables / Aliases / Hosts / Process +_fzf_setup_completion 'var' export unset +_fzf_setup_completion 'alias' unalias +_fzf_setup_completion 'host' ssh telnet +_fzf_setup_completion 'proc' kill + +fi diff --git a/.local/share/fzf/completion.zsh b/.local/share/fzf/completion.zsh new file mode 100644 index 0000000..807d7b3 --- /dev/null +++ b/.local/share/fzf/completion.zsh @@ -0,0 +1,324 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ completion.zsh +# +# - $FZF_TMUX (default: 0) +# - $FZF_TMUX_OPTS (default: '-d 40%') +# - $FZF_COMPLETION_TRIGGER (default: '**') +# - $FZF_COMPLETION_OPTS (default: empty) + +# Both branches of the following `if` do the same thing -- define +# __fzf_completion_options such that `eval $__fzf_completion_options` sets +# all options to the same values they currently have. We'll do just that at +# the bottom of the file after changing options to what we prefer. +# +# IMPORTANT: Until we get to the `emulate` line, all words that *can* be quoted +# *must* be quoted in order to prevent alias expansion. In addition, code must +# be written in a way works with any set of zsh options. This is very tricky, so +# careful when you change it. +# +# Start by loading the builtin zsh/parameter module. It provides `options` +# associative array that stores current shell options. +if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then + # This is the fast branch and it gets taken on virtually all Zsh installations. + # + # ${(kv)options[@]} expands to array of keys (option names) and values ("on" + # or "off"). The subsequent expansion# with (j: :) flag joins all elements + # together separated by spaces. __fzf_completion_options ends up with a value + # like this: "options=(shwordsplit off aliases on ...)". + __fzf_completion_options="options=(${(j: :)${(kv)options[@]}})" +else + # This branch is much slower because it forks to get the names of all + # zsh options. It's possible to eliminate this fork but it's not worth the + # trouble because this branch gets taken only on very ancient or broken + # zsh installations. + () { + # That `()` above defines an anonymous function. This is essentially a scope + # for local parameters. We use it to avoid polluting global scope. + 'local' '__fzf_opt' + __fzf_completion_options="setopt" + # `set -o` prints one line for every zsh option. Each line contains option + # name, some spaces, and then either "on" or "off". We just want option names. + # Expansion with (@f) flag splits a string into lines. The outer expansion + # removes spaces and everything that follow them on every line. __fzf_opt + # ends up iterating over option names: shwordsplit, aliases, etc. + for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do + if [[ -o "$__fzf_opt" ]]; then + # Option $__fzf_opt is currently on, so remember to set it back on. + __fzf_completion_options+=" -o $__fzf_opt" + else + # Option $__fzf_opt is currently off, so remember to set it back off. + __fzf_completion_options+=" +o $__fzf_opt" + fi + done + # The value of __fzf_completion_options here looks like this: + # "setopt +o shwordsplit -o aliases ..." + } +fi + +# Enable the default zsh options (those marked with in `man zshoptions`) +# but without `aliases`. Aliases in functions are expanded when functions are +# defined, so if we disable aliases here, we'll be sure to have no pesky +# aliases in any of our functions. This way we won't need prefix every +# command with `command` or to quote every word to defend against global +# aliases. Note that `aliases` is not the only option that's important to +# control. There are several others that could wreck havoc if they are set +# to values we don't expect. With the following `emulate` command we +# sidestep this issue entirely. +'emulate' 'zsh' '-o' 'no_aliases' + +# This brace is the start of try-always block. The `always` part is like +# `finally` in lesser languages. We use it to *always* restore user options. +{ + +# Bail out if not interactive shell. +[[ -o interactive ]] || return 0 + +# To use custom commands instead of find, override _fzf_compgen_{path,dir} +if ! declare -f _fzf_compgen_path > /dev/null; then + _fzf_compgen_path() { + echo "$1" + command find -L "$1" \ + -name .git -prune -o -name .hg -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } +fi + +if ! declare -f _fzf_compgen_dir > /dev/null; then + _fzf_compgen_dir() { + command find -L "$1" \ + -name .git -prune -o -name .hg -prune -o -name .svn -prune -o -type d \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } +fi + +########################################################### + +__fzf_comprun() { + if [[ "$(type _fzf_comprun 2>&1)" =~ function ]]; then + _fzf_comprun "$@" + elif [ -n "${TMUX_PANE-}" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "${FZF_TMUX_OPTS-}" ]; }; then + shift + if [ -n "${FZF_TMUX_OPTS-}" ]; then + fzf-tmux ${(Q)${(Z+n+)FZF_TMUX_OPTS}} -- "$@" + else + fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%} -- "$@" + fi + else + shift + fzf "$@" + fi +} + +# Extract the name of the command. e.g. foo=1 bar baz** +__fzf_extract_command() { + local token tokens + tokens=(${(z)1}) + for token in $tokens; do + token=${(Q)token} + if [[ "$token" =~ [[:alnum:]] && ! "$token" =~ "=" ]]; then + echo "$token" + return + fi + done + echo "${tokens[1]}" +} + +__fzf_generic_path_completion() { + local base lbuf cmd compgen fzf_opts suffix tail dir leftover matches + base=$1 + lbuf=$2 + cmd=$(__fzf_extract_command "$lbuf") + compgen=$3 + fzf_opts=$4 + suffix=$5 + tail=$6 + + setopt localoptions nonomatch + eval "base=$base" + [[ $base = *"/"* ]] && dir="$base" + while [ 1 ]; do + if [[ -z "$dir" || -d ${dir} ]]; then + leftover=${base/#"$dir"} + leftover=${leftover/#\/} + [ -z "$dir" ] && dir='.' + [ "$dir" != "/" ] && dir="${dir/%\//}" + matches=$(eval "$compgen $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-}" __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" | while read item; do + item="${item%$suffix}$suffix" + echo -n "${(q)item} " + done) + matches=${matches% } + if [ -n "$matches" ]; then + LBUFFER="$lbuf$matches$tail" + fi + zle reset-prompt + break + fi + dir=$(dirname "$dir") + dir=${dir%/}/ + done +} + +_fzf_path_completion() { + __fzf_generic_path_completion "$1" "$2" _fzf_compgen_path \ + "-m" "" " " +} + +_fzf_dir_completion() { + __fzf_generic_path_completion "$1" "$2" _fzf_compgen_dir \ + "" "/" "" +} + +_fzf_feed_fifo() ( + command rm -f "$1" + mkfifo "$1" + cat <&0 > "$1" & +) + +_fzf_complete() { + setopt localoptions ksh_arrays + # Split arguments around -- + local args rest str_arg i sep + args=("$@") + sep= + for i in {0..${#args[@]}}; do + if [[ "${args[$i]-}" = -- ]]; then + sep=$i + break + fi + done + if [[ -n "$sep" ]]; then + str_arg= + rest=("${args[@]:$((sep + 1)):${#args[@]}}") + args=("${args[@]:0:$sep}") + else + str_arg=$1 + args=() + shift + rest=("$@") + fi + + local fifo lbuf cmd matches post + fifo="${TMPDIR:-/tmp}/fzf-complete-fifo-$$" + lbuf=${rest[0]} + cmd=$(__fzf_extract_command "$lbuf") + post="${funcstack[1]}_post" + type $post > /dev/null 2>&1 || post=cat + + _fzf_feed_fifo "$fifo" + matches=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-} $str_arg" __fzf_comprun "$cmd" "${args[@]}" -q "${(Q)prefix}" < "$fifo" | $post | tr '\n' ' ') + if [ -n "$matches" ]; then + LBUFFER="$lbuf$matches" + fi + command rm -f "$fifo" +} + +_fzf_complete_telnet() { + _fzf_complete +m -- "$@" < <( + command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0' | + awk '{if (length($2) > 0) {print $2}}' | sort -u + ) +} + +_fzf_complete_ssh() { + _fzf_complete +m -- "$@" < <( + setopt localoptions nonomatch + command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') \ + <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \ + <(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') | + awk '{if (length($2) > 0) {print $2}}' | sort -u + ) +} + +_fzf_complete_export() { + _fzf_complete -m -- "$@" < <( + declare -xp | sed 's/=.*//' | sed 's/.* //' + ) +} + +_fzf_complete_unset() { + _fzf_complete -m -- "$@" < <( + declare -xp | sed 's/=.*//' | sed 's/.* //' + ) +} + +_fzf_complete_unalias() { + _fzf_complete +m -- "$@" < <( + alias | sed 's/=.*//' + ) +} + +_fzf_complete_kill() { + _fzf_complete -m --preview 'echo {}' --preview-window down:3:wrap --min-height 15 -- "$@" < <( + command ps -ef | sed 1d + ) +} + +_fzf_complete_kill_post() { + awk '{print $2}' +} + +fzf-completion() { + local tokens cmd prefix trigger tail matches lbuf d_cmds + setopt localoptions noshwordsplit noksh_arrays noposixbuiltins + + # http://zsh.sourceforge.net/FAQ/zshfaq03.html + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags + tokens=(${(z)LBUFFER}) + if [ ${#tokens} -lt 1 ]; then + zle ${fzf_default_completion:-expand-or-complete} + return + fi + + cmd=$(__fzf_extract_command "$LBUFFER") + + # Explicitly allow for empty trigger. + trigger=${FZF_COMPLETION_TRIGGER-'**'} + [ -z "$trigger" -a ${LBUFFER[-1]} = ' ' ] && tokens+=("") + + # When the trigger starts with ';', it becomes a separate token + if [[ ${LBUFFER} = *"${tokens[-2]-}${tokens[-1]}" ]]; then + tokens[-2]="${tokens[-2]-}${tokens[-1]}" + tokens=(${tokens[0,-2]}) + fi + + lbuf=$LBUFFER + tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))} + + # Trigger sequence given + if [ ${#tokens} -gt 1 -a "$tail" = "$trigger" ]; then + d_cmds=(${=FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir}) + + [ -z "$trigger" ] && prefix=${tokens[-1]} || prefix=${tokens[-1]:0:-${#trigger}} + [ -n "${tokens[-1]}" ] && lbuf=${lbuf:0:-${#tokens[-1]}} + + if eval "type _fzf_complete_${cmd} > /dev/null"; then + prefix="$prefix" eval _fzf_complete_${cmd} ${(q)lbuf} + zle reset-prompt + elif [ ${d_cmds[(i)$cmd]} -le ${#d_cmds} ]; then + _fzf_dir_completion "$prefix" "$lbuf" + else + _fzf_path_completion "$prefix" "$lbuf" + fi + # Fall back to default completion + else + zle ${fzf_default_completion:-expand-or-complete} + fi +} + +[ -z "$fzf_default_completion" ] && { + binding=$(bindkey '^I') + [[ $binding =~ 'undefined-key' ]] || fzf_default_completion=$binding[(s: :w)2] + unset binding +} + +zle -N fzf-completion +bindkey '^I' fzf-completion + +} always { + # Restore the original options. + eval $__fzf_completion_options + 'unset' '__fzf_completion_options' +} diff --git a/.local/share/fzf/key-bindings.bash b/.local/share/fzf/key-bindings.bash new file mode 100644 index 0000000..d83f9d3 --- /dev/null +++ b/.local/share/fzf/key-bindings.bash @@ -0,0 +1,102 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ key-bindings.bash +# +# - $FZF_TMUX_OPTS +# - $FZF_CTRL_T_COMMAND +# - $FZF_CTRL_T_OPTS +# - $FZF_CTRL_R_OPTS +# - $FZF_ALT_C_COMMAND +# - $FZF_ALT_C_OPTS + +# Key bindings +# ------------ +__fzf_select__() { + local cmd opts + cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + -o -type f -print \ + -o -type d -print \ + -o -type l -print 2> /dev/null | cut -b3-"}" + opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore --reverse ${FZF_DEFAULT_OPTS-} ${FZF_CTRL_T_OPTS-} -m" + eval "$cmd" | + FZF_DEFAULT_OPTS="$opts" $(__fzfcmd) "$@" | + while read -r item; do + printf '%q ' "$item" # escape special chars + done +} + +if [[ $- =~ i ]]; then + +__fzfcmd() { + [[ -n "${TMUX_PANE-}" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "${FZF_TMUX_OPTS-}" ]]; } && + echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf" +} + +fzf-file-widget() { + local selected="$(__fzf_select__ "$@")" + READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$selected${READLINE_LINE:$READLINE_POINT}" + READLINE_POINT=$(( READLINE_POINT + ${#selected} )) +} + +__fzf_cd__() { + local cmd opts dir + cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + -o -type d -print 2> /dev/null | cut -b3-"}" + opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore --reverse ${FZF_DEFAULT_OPTS-} ${FZF_ALT_C_OPTS-} +m" + dir=$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" $(__fzfcmd)) && printf 'builtin cd -- %q' "$dir" +} + +__fzf_history__() { + local output opts script + opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} -n2..,.. --scheme=history --bind=ctrl-r:toggle-sort ${FZF_CTRL_R_OPTS-} +m --read0" + script='BEGIN { getc; $/ = "\n\t"; $HISTCOUNT = $ENV{last_hist} + 1 } s/^[ *]//; print $HISTCOUNT - $. . "\t$_" if !$seen{$_}++' + output=$( + builtin fc -lnr -2147483648 | + last_hist=$(HISTTIMEFORMAT='' builtin history 1) perl -n -l0 -e "$script" | + FZF_DEFAULT_OPTS="$opts" $(__fzfcmd) --query "$READLINE_LINE" + ) || return + READLINE_LINE=${output#*$'\t'} + if [[ -z "$READLINE_POINT" ]]; then + echo "$READLINE_LINE" + else + READLINE_POINT=0x7fffffff + fi +} + +# Required to refresh the prompt after fzf +bind -m emacs-standard '"\er": redraw-current-line' + +bind -m vi-command '"\C-z": emacs-editing-mode' +bind -m vi-insert '"\C-z": emacs-editing-mode' +bind -m emacs-standard '"\C-z": vi-editing-mode' + +if (( BASH_VERSINFO[0] < 4 )); then + # CTRL-T - Paste the selected file path into the command line + bind -m emacs-standard '"\C-t": " \C-b\C-k \C-u`__fzf_select__`\e\C-e\er\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"' + bind -m vi-command '"\C-t": "\C-z\C-t\C-z"' + bind -m vi-insert '"\C-t": "\C-z\C-t\C-z"' + + # CTRL-R - Paste the selected command from history into the command line + bind -m emacs-standard '"\C-r": "\C-e \C-u\C-y\ey\C-u"$(__fzf_history__)"\e\C-e\er"' + bind -m vi-command '"\C-r": "\C-z\C-r\C-z"' + bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"' +else + # CTRL-T - Paste the selected file path into the command line + bind -m emacs-standard -x '"\C-t": fzf-file-widget' + bind -m vi-command -x '"\C-t": fzf-file-widget' + bind -m vi-insert -x '"\C-t": fzf-file-widget' + + # CTRL-R - Paste the selected command from history into the command line + bind -m emacs-standard -x '"\C-r": __fzf_history__' + bind -m vi-command -x '"\C-r": __fzf_history__' + bind -m vi-insert -x '"\C-r": __fzf_history__' +fi + +# ALT-C - cd into the selected directory +bind -m emacs-standard '"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"' +bind -m vi-command '"\ec": "\C-z\ec\C-z"' +bind -m vi-insert '"\ec": "\C-z\ec\C-z"' + +fi diff --git a/.local/share/fzf/key-bindings.zsh b/.local/share/fzf/key-bindings.zsh new file mode 100644 index 0000000..458a3a4 --- /dev/null +++ b/.local/share/fzf/key-bindings.zsh @@ -0,0 +1,121 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ key-bindings.zsh +# +# - $FZF_TMUX_OPTS +# - $FZF_CTRL_T_COMMAND +# - $FZF_CTRL_T_OPTS +# - $FZF_CTRL_R_OPTS +# - $FZF_ALT_C_COMMAND +# - $FZF_ALT_C_OPTS + +# Key bindings +# ------------ + +# The code at the top and the bottom of this file is the same as in completion.zsh. +# Refer to that file for explanation. +if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then + __fzf_key_bindings_options="options=(${(j: :)${(kv)options[@]}})" +else + () { + __fzf_key_bindings_options="setopt" + 'local' '__fzf_opt' + for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do + if [[ -o "$__fzf_opt" ]]; then + __fzf_key_bindings_options+=" -o $__fzf_opt" + else + __fzf_key_bindings_options+=" +o $__fzf_opt" + fi + done + } +fi + +'emulate' 'zsh' '-o' 'no_aliases' + +{ + +[[ -o interactive ]] || return 0 + +# CTRL-T - Paste the selected file path(s) into the command line +__fsel() { + local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + -o -type f -print \ + -o -type d -print \ + -o -type l -print 2> /dev/null | cut -b3-"}" + setopt localoptions pipefail no_aliases 2> /dev/null + local item + eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_CTRL_T_OPTS-}" $(__fzfcmd) -m "$@" | while read item; do + echo -n "${(q)item} " + done + local ret=$? + echo + return $ret +} + +__fzfcmd() { + [ -n "${TMUX_PANE-}" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "${FZF_TMUX_OPTS-}" ]; } && + echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf" +} + +fzf-file-widget() { + LBUFFER="${LBUFFER}$(__fsel)" + local ret=$? + zle reset-prompt + return $ret +} +zle -N fzf-file-widget +bindkey -M emacs '^T' fzf-file-widget +bindkey -M vicmd '^T' fzf-file-widget +bindkey -M viins '^T' fzf-file-widget + +# ALT-C - cd into the selected directory +fzf-cd-widget() { + local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + -o -type d -print 2> /dev/null | cut -b3-"}" + setopt localoptions pipefail no_aliases 2> /dev/null + local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_ALT_C_OPTS-}" $(__fzfcmd) +m)" + if [[ -z "$dir" ]]; then + zle redisplay + return 0 + fi + zle push-line # Clear buffer. Auto-restored on next prompt. + BUFFER="builtin cd -- ${(q)dir}" + zle accept-line + local ret=$? + unset dir # ensure this doesn't end up appearing in prompt expansion + zle reset-prompt + return $ret +} +zle -N fzf-cd-widget +bindkey -M emacs '\ec' fzf-cd-widget +bindkey -M vicmd '\ec' fzf-cd-widget +bindkey -M viins '\ec' fzf-cd-widget + +# CTRL-R - Paste the selected command from history into the command line +# EDIT BY plex: removed --scheme-history , as it causes errors on some debian based systems as it seems. +fzf-history-widget() { + local selected num + setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null + selected=( $(fc -rl 1 | awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' | + FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} ${FZF_DEFAULT_OPTS-} -n2..,.. --bind=ctrl-r:toggle-sort,ctrl-z:ignore ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) ) + local ret=$? + if [ -n "$selected" ]; then + num=$selected[1] + if [ -n "$num" ]; then + zle vi-fetch-history -n $num + fi + fi + zle reset-prompt + return $ret +} +zle -N fzf-history-widget +bindkey -M emacs '^R' fzf-history-widget +bindkey -M vicmd '^R' fzf-history-widget +bindkey -M viins '^R' fzf-history-widget + +} always { + eval $__fzf_key_bindings_options + 'unset' '__fzf_key_bindings_options' +} diff --git a/.local/share/nnn/plugins/.cbcp b/.local/share/nnn/plugins/.cbcp new file mode 100755 index 0000000..70f9b75 --- /dev/null +++ b/.local/share/nnn/plugins/.cbcp @@ -0,0 +1,51 @@ +#!/usr/bin/env sh + +# Description: Copy selection to system clipboard as newline-separated entries +# Dependencies: +# - tr +# - xclip/xsel (Linux) +# - pbcopy (macOS) +# - termux-clipboard-set (Termux) +# - clip.exe (WSL) +# - clip (Cygwin) +# - wl-copy (Wayland) +# - clipboard (Haiku) +# +# Limitation: breaks if a filename has newline in it +# +# Note: For a space-separated list: +# xargs -0 < "$SELECTION" +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +[ -s "$selection" ] || { echo "plugin .cbcp error: empty selection" >&2 ; exit 1; } + +if type xsel >/dev/null 2>&1; then + # Linux + tr '\0' '\n' < "$selection" | xsel -bi +elif type xclip >/dev/null 2>&1; then + # Linux + tr '\0' '\n' < "$selection" | xclip -sel clip +elif type pbcopy >/dev/null 2>&1; then + # macOS + tr '\0' '\n' < "$selection" | pbcopy +elif type termux-clipboard-set >/dev/null 2>&1; then + # Termux + tr '\0' '\n' < "$selection" | termux-clipboard-set +elif type clip.exe >/dev/null 2>&1; then + # WSL + tr '\0' '\n' < "$selection" | clip.exe +elif type clip >/dev/null 2>&1; then + # Cygwin + tr '\0' '\n' < "$selection" | clip +elif type wl-copy >/dev/null 2>&1; then + # Wayland + tr '\0' '\n' < "$selection" | wl-copy +elif type clipboard >/dev/null 2>&1; then + # Haiku + tr '\0' '\n' < "$selection" | clipboard --stdin +fi diff --git a/.local/share/nnn/plugins/.iconlookup b/.local/share/nnn/plugins/.iconlookup new file mode 100755 index 0000000..d48d676 --- /dev/null +++ b/.local/share/nnn/plugins/.iconlookup @@ -0,0 +1,428 @@ +#!/usr/bin/env sh + +# Description: Print icons in front of list of directories/files + +# Dependencies: awk + +# Usage +# 1. Set colors and/or icons to your liking +# 2. Pipe any directory listing to iconlookup and it will output prepended icons +# 3. preview-tui uses the script to prepend icon to directory listings +# 4. Aditionally you can consider adding it to your PATH and/or FZF_DEFAULT_COMMAND to +# make it work with various fzf plugins (make sure you also add --ansi to your FZF_DEFAULT_OPTS) + +# Shell: POSIX compliant + +# Author: Luuk van Baal (https://github.com/luukvbaal/iconlookup) + +icon_lookup() { +awk 'BEGIN { +# Set your ANSI colorscheme below (https://en.wikipedia.org/wiki/ANSI_escape_code#Colors). +# Default uses standard nnn icon colors, 8 and 24-bit nord themes are commented out. + colordepth=8 #colordepth=8 #colordepth=24 + color_dirtxt=39 #color_dirtxt=111 #color_dirtxt="129;161;193" + color_filetxt=15 #color_filetxt=111 #color_filetxt="129;161;193" + color_default=39 #color_default=111 #color_default="129;161;193" + color_video=93 #color_video=110 #color_video="136;192;208" + color_audio=220 #color_audio=150 #color_audio="163;190;140" + color_image=82 #color_image=150 #color_image="163;190;140" + color_docs=202 #color_docs=173 #color_docs="208;135;112" + color_archive=209 #color_archive=179 #color_archive="235;203;139" + color_c=81 #color_c=150 #color_c="163;190;140" + color_java=32 #color_java=139 #color_java="180;142;173" + color_js=47 #color_js=109 #color_js="143;188;187" + color_react=39 #color_react=111 #color_react="129;161;193" + color_css=199 #color_css=110 #color_css="136;192;208" + color_python=227 #color_python=68 #color_python="94;129;172" + color_lua=19 #color_lua=167 #color_lua="191;97;106" + color_document=15 #color_document=173 #color_document="208;135;112" + color_fsharp=31 #color_fsharp=179 #color_fsharp="180;142;173" + color_ruby=160 #color_ruby=150 #color_ruby="163;190;140" + color_scala=196 #color_scala=139 #color_scala="143;188;187" + color_shell=47 #color_shell=109 #color_shell="143;188;187" + color_vim=28 #color_vim=109 #color_vim="143;188;187" + +# icons[][1] contains icon and icons[][2] contains color + icons["directory"][1] = ""; icons["directory"][2] = color_default + icons["file"][1] = ""; icons["file"][2] = color_default + icons["exec"][1] = ""; icons["exec"][2] = color_default + icons["manual"][1] = ""; icons["manual"][2] = color_docs + icons["pipe"][1] = "ﳣ"; icons["pipe"][2] = color_default + icons["socket"][1] = "ﳧ"; icons["socket"][2] = color_default + icons["door"][1] = "➡"; icons["door"][2] = color_default + +# top level and common icons + icons[".git"][1] = ""; icons[".git"][2] = color_default + icons["desktop"][1] = "ﲾ"; icons["desktop"][2] = color_default + icons["briefcase"][1] = ""; icons["briefcase"][2] = color_default + icons["document"][1] = ""; icons["document"][2] = color_default + icons["downloads"][1] = ""; icons["downloads"][2] = color_default + icons["music"][1] = ""; icons["music"][2] = color_default + icons["musicfile"][1] = ""; icons["musicfile"][2] = color_audio + icons["pictures"][1] = ""; icons["pictures"][2] = color_default + icons["picturefile"][1] = ""; icons["picturefile"][2] = color_image + icons["public"][1] = ""; icons["public"][2] = color_default + icons["templates"][1] = "陼"; icons["templates"][2] = color_default + icons["videos"][1] = ""; icons["videos"][2] = color_default + icons["videofile"][1] = "ﳜ"; icons["videofile"][2] = color_video + icons["changelog"][1] = ""; icons["changelog"][2] = color_docs + icons["configure"][1] = ""; icons["configure"][2] = color_default + icons["license"][1] = ""; icons["license"][2] = color_docs + icons["makefile"][1] = ""; icons["makefile"][2] = color_default + icons["archive"][1] = ""; icons["archive"][2] = color_archive + icons["script"][1] = ""; icons["script"][2] = color_shell + icons["cplusplus"][1] = ""; icons["cplusplus"][2] = color_c + icons["java"][1] = ""; icons["java"][2] = color_java + icons["clojure"][1] = ""; icons["clojure"][2] = color_default + icons["js"][1] = ""; icons["js"][2] = color_js + icons["linux"][1] = ""; icons["linux"][2] = color_default + icons["fsharp"][1] = ""; icons["fsharp"][2] = color_fsharp + icons["ruby"][1] = ""; icons["ruby"][2] = color_ruby + icons["c"][1] = ""; icons["c"][2] = color_c + icons["chess"][1] = ""; icons["chess"][2] = color_default + icons["haskell"][1] = ""; icons["haskell"][2] = color_vim + icons["html"][1] = ""; icons["html"][2] = color_default + icons["react"][1] = ""; icons["react"][2] = color_react + icons["python"][1] = ""; icons["python"][2] = color_python + icons["database"][1] = ""; icons["database"][2] = color_default + icons["worddoc"][1] = ""; icons["worddoc"][2] = color_document + icons["playlist"][1] = "蘿"; icons["playlist"][2] = color_audio + icons["opticaldisk"][1] = ""; icons["opticaldisk"][2] = color_archive + +# numbers + icons["1"][1] = icons["manual"][1]; icons["1"][2] = icons["manual"][2] + icons["7z"][1] = icons["archive"][1]; icons["7z"][2] = icons["archive"][2] + +# a + icons["a"][1] = icons["manual"][1]; icons["a"][2] = icons["manual"][2] + icons["apk"][1] = icons["archive"][1]; icons["apk"][2] = icons["archive"][2] + icons["asm"][1] = icons["file"][1]; icons["asm"][2] = icons["file"][2] + icons["aup"][1] = icons["musicfile"][1]; icons["aup"][2] = icons["musicfile"][2] + icons["avi"][1] = icons["videofile"][1]; icons["avi"][2] = icons["videofile"][2] + +# b + icons["bat"][1] = icons["script"][1]; icons["bat"][2] = icons["script"][2] + icons["bin"][1] = ""; icons["bin"][2] = color_default + icons["bmp"][1] = icons["picturefile"][1]; icons["bmp"][2] = icons["picturefile"][2] + icons["bz2"][1] = icons["archive"][1]; icons["bz2"][2] = icons["archive"][2] + +# c + icons["cplusplus"][1] = icons["cplusplus"][1]; icons["cplusplus"][2] = icons["cplusplus"][2] + icons["cabal"][1] = icons["haskell"][1]; icons["cab"][2] = icons["haskell"][2] + icons["cab"][1] = icons["archive"][1]; icons["cab"][2] = icons["archive"][2] + icons["cbr"][1] = icons["archive"][1]; icons["cbr"][2] = icons["archive"][2] + icons["cbz"][1] = icons["archive"][1]; icons["cbz"][2] = icons["archive"][2] + icons["cc"][1] = icons["cplusplus"][1]; icons["cc"][2] = icons["cplusplus"][2] + icons["class"][1] = icons["java"][1]; icons["class"][2] = icons["java"][2] + icons["clj"][1] = icons["clojure"][1]; icons["clj"][2] = icons["clojure"][2] + icons["cljc"][1] = icons["clojure"][1]; icons["cljc"][2] = icons["clojure"][2] + icons["cljs"][1] = icons["clojure"][1]; icons["cljs"][2] = icons["clojure"][2] + icons["cmake"][1] = icons["makefile"][1]; icons["cmake"][2] = icons["makefile"][2] + icons["coffee"][1] = ""; icons["coffee"][2] = color_default + icons["conf"][1] = icons["configure"][1]; icons["conf"][2] = icons["configure"][2] + icons["cpio"][1] = icons["archive"][1]; icons["cpio"][2] = icons["archive"][2] + icons["cpp"][1] = icons["cplusplus"][1]; icons["cpp"][2] = icons["cplusplus"][2] + icons["css"][1] = ""; icons["css"][2] = color_css + icons["cue"][1] = icons["playlist"][1]; icons["cue"][2] = icons["playlist"][2] + icons["cvs"][1] = icons["configure"][1]; icons["cvs"][2] = icons["configure"][2] + icons["cxx"][1] = icons["cplusplus"][1]; icons["cxx"][2] = icons["cplusplus"][2] + +# d + icons["db"][1] = icons["database"][1]; icons["db"][2] = icons["database"][2] + icons["deb"][1] = ""; icons["deb"][2] = color_archive + icons["diff"][1] = ""; icons["diff"][2] = color_default + icons["dll"][1] = icons["script"][1]; icons["dll"][2] = icons["script"][2] + icons["doc"][1] = icons["worddoc"][1]; icons["doc"][2] = icons["worddoc"][2] + icons["docx"][1] = icons["worddoc"][1]; icons["docx"][2] = icons["worddoc"][2] + +# e + icons["ejs"][1] = icons["js"][1]; icons["ejs"][2] = icons["js"][2] + icons["elf"][1] = icons["linux"][1]; icons["elf"][2] = icons["linux"][2] + icons["epub"][1] = icons["manual"][1]; icons["epub"][2] = icons["manual"][2] + icons["exe"][1] = icons["exec"][1]; icons["exe"][2] = icons["exec"][2] + +# f + icons["fsharp"][1] = icons["fsharp"][1]; icons["fsharp"][2] = icons["fsharp"][2] + icons["flac"][1] = icons["musicfile"][1]; icons["flac"][2] = icons["musicfile"][2] + icons["fen"][1] = icons["chess"][1]; icons["fen"][2] = icons["chess"][2] + icons["flv"][1] = icons["videofile"][1]; icons["flv"][2] = icons["videofile"][2] + icons["fs"][1] = icons["fsharp"][1]; icons["fs"][2] = icons["fsharp"][2] + icons["fsi"][1] = icons["fsharp"][1]; icons["fsi"][2] = icons["fsharp"][2] + icons["fsscript"][1] = icons["fsharp"][1]; icons["fsscript"][2] = icons["fsharp"][2] + icons["fsx"][1] = icons["fsharp"][1]; icons["fsx"][2] = icons["fsharp"][2] + +# g + icons["gem"][1] = icons["ruby"][1]; icons["gem"][2] = icons["ruby"][2] + icons["gif"][1] = icons["picturefile"][1]; icons["gif"][2] = icons["picturefile"][2] + icons["go"][1] = "ﳑ"; icons["go"][2] = color_default + icons["gz"][1] = icons["archive"][1]; icons["gz"][2] = icons["archive"][2] + icons["gzip"][1] = icons["archive"][1]; icons["gzip"][2] = icons["archive"][2] + +# h + icons["h"][1] = icons["c"][1]; icons["h"][2] = icons["c"][2] + icons["hh"][1] = icons["cplusplus"][1]; icons["hh"][2] = icons["cplusplus"][2] + icons["hpp"][1] = icons["cplusplus"][1]; icons["hpp"][2] = icons["cplusplus"][2] + icons["hs"][1] = icons["haskell"][1]; icons["hs"][2] = icons["haskell"][2] + icons["htaccess"][1] = icons["configure"][1]; icons["htaccess"][2] = icons["configure"][2] + icons["htpasswd"][1] = icons["configure"][1]; icons["htpasswd"][2] = icons["configure"][2] + icons["htm"][1] = icons["html"][1]; icons["htm"][2] = icons["html"][2] + icons["hxx"][1] = icons["cplusplus"][1]; icons["hxx"][2] = icons["cplusplus"][2] + +# i + icons["ico"][1] = icons["picturefile"][1]; icons["ico"][2] = icons["picturefile"][2] + icons["img"][1] = icons["opticaldisk"][1]; icons["img"][2] = icons["opticaldisk"][2] + icons["ini"][1] = icons["configure"][1]; icons["ini"][2] = icons["configure"][2] + icons["iso"][1] = icons["opticaldisk"][1]; icons["iso"][2] = icons["opticaldisk"][2] + +# j + icons["jar"][1] = icons["java"][1]; icons["jar"][2] = icons["java"][2] + icons["java"][1] = icons["java"][1]; icons["java"][2] = icons["java"][2] + icons["jl"][1] = icons["configure"][1]; icons["jl"][2] = icons["configure"][2] + icons["jpeg"][1] = icons["picturefile"][1]; icons["jpeg"][2] = icons["picturefile"][2] + icons["jpg"][1] = icons["picturefile"][1]; icons["jpg"][2] = icons["picturefile"][2] + icons["json"][1] = "ﬥ"; icons["json"][2] = color_js + icons["jsx"][1] = icons["react"][1]; icons["jsx"][2] = icons["react"][2] + +# k + +# l + icons["lha"][1] = icons["archive"][1]; icons["lha"][2] = icons["archive"][2] + icons["lhs"][1] = icons["haskell"][1]; icons["lhs"][2] = icons["haskell"][2] + icons["ilog"][1] = icons["document"][1]; icons["ilog"][2] = icons["document"][2] + icons["lua"][1] = ""; icons["lua"][2] = color_lua + icons["lzh"][1] = icons["archive"][1]; icons["lzh"][2] = icons["archive"][2] + icons["lzma"][1] = icons["archive"][1]; icons["lzma"][2] = icons["archive"][2] + +# m + icons["m"][1] = "ﴜ"; icons["mat"][2] = color_c + icons["m4a"][1] = icons["musicfile"][1]; icons["m4a"][2] = icons["musicfile"][2] + icons["m4v"][1] = icons["videofile"][1]; icons["m4v"][2] = icons["videofile"][2] + icons["mat"][1] = ""; icons["mat"][2] = color_c + icons["markdown"][1] = ""; icons["markdown"][2] = color_docs + icons["md"][1] = ""; icons["md"][2] = color_docs + icons["mk"][1] = icons["makefile"][1]; icons["mk"][2] = icons["makefile"][2] + icons["mkv"][1] = icons["videofile"][1]; icons["mkv"][2] = icons["videofile"][2] + icons["mov"][1] = icons["videofile"][1]; icons["mov"][2] = icons["videofile"][2] + icons["mp3"][1] = icons["musicfile"][1]; icons["mp3"][2] = icons["musicfile"][2] + icons["mp4"][1] = icons["videofile"][1]; icons["mp4"][2] = icons["videofile"][2] + icons["mpeg"][1] = icons["videofile"][1]; icons["mpeg"][2] = icons["videofile"][2] + icons["mpg"][1] = icons["videofile"][1]; icons["mpg"][2] = icons["videofile"][2] + icons["msi"][1] = ""; icons["msi"][2] = color_default + +# n + icons["nix"][1] = ""; icons["nix"][2] = color_fsharp + +# o + icons["o"][1] = icons["manual"][1]; icons["o"][2] = icons["manual"][2] + icons["ogg"][1] = icons["musicfile"][1]; icons["ogg"][2] = icons["musicfile"][2] + icons["odownload"][1] = icons["download"][1]; icons["odownload"][2] = icons["download"][2] + icons["out"][1] = icons["linux"][1]; icons["out"][2] = icons["linux"][2] + +# p + icons["part"][1] = icons["download"][1]; icons["part"][2] = icons["download"][2] + icons["patch"][1] = icons["diff"][1]; icons["patch"][2] = icons["diff"][2] + icons["pdf"][1] = ""; icons["pdf"][2] = color_docs + icons["pgn"][1] = icons["chess"][1]; icons["pgn"][2] = icons["chess"][2] + icons["php"][1] = ""; icons["php"][2] = color_default + icons["png"][1] = icons["picturefile"][1]; icons["png"][2] = icons["picturefile"][2] + icons["ppt"][1] = ""; icons["ppt"][2] = color_default + icons["pptx"][1] = ""; icons["pptx"][2] = color_default + icons["psb"][1] = ""; icons["psb"][2] = color_default + icons["psd"][1] = ""; icons["psd"][2] = color_default + icons["py"][1] = icons["python"][1]; icons["py"][2] = icons["python"][2] + icons["pyc"][1] = icons["python"][1]; icons["pyc"][2] = icons["python"][2] + icons["pyd"][1] = icons["python"][1]; icons["pyd"][2] = icons["python"][2] + icons["pyo"][1] = icons["python"][1]; icons["pyo"][2] = icons["python"][2] + +# q + +# r + icons["rar"][1] = icons["archive"][1]; icons["rar"][2] = icons["archive"][2] + icons["rc"][1] = icons["configure"][1]; icons["rc"][2] = icons["configure"][2] + icons["rom"][1] = ""; icons["rom"][2] = color_default + icons["rpm"][1] = icons["archive"][1]; icons["rpm"][2] = icons["archive"][2] + icons["rss"][1] = "參"; icons["rss"][2] = color_default + icons["rtf"][1] = ""; icons["rtf"][2] = color_default + +# s + icons["sass"][1] = ""; icons["sass"][2] = color_css + icons["scss"][1] = ""; icons["scss"][2] = color_css + icons["so"][1] = icons["manual"][1]; icons["so"][2] = icons["manual"][2] + icons["scala"][1] = ""; icons["scala"][2] = color_scala + icons["sh"][1] = icons["script"][1]; icons["sh"][2] = icons["script"][2] + icons["slim"][1] = icons["script"][1]; icons["slim"][2] = icons["script"][2] + icons["sln"][1] = ""; icons["sln"][2] = color_default + icons["sql"][1] = icons["database"][1]; icons["sql"][2] = icons["database"][2] + icons["srt"][1] = ""; icons["srt"][2] = color_default + icons["isub"][1] = ""; icons["isub"][2] = color_default + icons["svg"][1] = icons["picturefile"][1]; icons["svg"][2] = icons["picturefile"][2] + +# t + icons["tar"][1] = icons["archive"][1]; icons["tar"][2] = icons["archive"][2] + icons["tex"][1] = ""; icons["tex"][2] = color_default + icons["tgz"][1] = icons["archive"][1]; icons["tgz"][2] = icons["archive"][2] + icons["ts"][1] = ""; icons["ts"][2] = color_js + icons["tsx"][1] = icons["react"][1]; icons["tsx"][2] = icons["react"][2] + icons["txt"][1] = icons["document"][1]; icons["txt"][2] = icons["document"][2] + icons["txz"][1] = icons["archive"][1]; icons["txz"][2] = icons["archive"][2] + +# u + +# v + icons["vid"][1] = icons["videofile"][1]; icons["vid"][2] = icons["videofile"][2] + icons["vim"][1] = ""; icons["vim"][2] = color_vim + icons["vimrc"][1] = ""; icons["vimrc"][2] = color_vim + icons["vtt"][1] = ""; icons["vtt"][2] = color_default +# w + icons["wav"][1] = icons["musicfile"][1]; icons["wav"][2] = icons["musicfile"][2] + icons["webm"][1] = icons["videofile"][1]; icons["webm"][2] = icons["videofile"][2] + icons["wma"][1] = icons["videofile"][1]; icons["wma"][2] = icons["videofile"][2] + icons["wmv"][1] = icons["videofile"][1]; icons["wmv"][2] = icons["videofile"][2] + +# x + icons["xbps"][1] = icons["archive"][1]; icons["xbps"][2] = color_archive + icons["xcf"][1] = icons["picturefile"][1]; icons["xcf"][2] = color_image + icons["xhtml"][1] = icons["html"][1]; icons["xhtml"][2] = icons["html"][2] + icons["xls"][1] = ""; icons["xls"][2] = color_default + icons["xlsx"][1] = ""; icons["xlsx"][2] = color_default + icons["xml"][1] = icons["html"][1]; icons["xml"][2] = icons["html"][2] + icons["xz"][1] = icons["archive"][1]; icons["xz"][2] = icons["archive"][2] + +# y + icons["yaml"][1] = icons["configure"][1]; icons["yaml"][2] = icons["configure"][2] + icons["yml"][1] = icons["configure"][1]; icons["yml"][2] = icons["configure"][2] +# z + icons["zip"][1] = icons["archive"][1]; icons["zip"][2] = icons["archive"][2] + icons["zsh"][1] = icons["script"][1]; icons["zsh"][2] = icons["script"][2] + icons["zst"][1] = icons["archive"][1]; icons["zst"][2] = icons["archive"][2] + + FS = "." + limit = ENVIRON["limit"] + switch (colordepth) { + case "4": + escape="\033[" + break; + case "8": + escape="\033[38;5;" + break; + case "24": + escape="\033[38;2;" + break; + } + bstr = ENVIRON["beforestr"] +} +{ + # dont print cwd . and leading ./ from tree -f + if ($0 ~/^\.$/) + next + ent = ($0 ~/^\.\//) ? substr($0, 3, length($0) - 2) : $0 + ext = $NF + + # Print icons, set color and bold directories by using ansi escape codes + if (ext in icons) + printcolor(icons[ext][1], icons[ext][2], color_filetxt, ent, "10") + else + switch (substr(ent, length(ent), 1)) { + case "/": + printcolor(icons["directory"][1], color_default, color_dirtxt, ent, "1") + break; + case "*": + printcolor(icons["exe"][1], color_default, color_filetxt, ent, "10") + break; + case "|": + printcolor(icons["pipe"][1], color_default, color_filetxt, ent, "10") + break; + case "=": + printcolor(icons["socket"][1], color_default, color_filetxt, ent, "10") + break; + case ">": + printcolor(icons["door"][1], color_default, color_filetxt, ent, "10") + break; + default: + printcolor(icons["file"][1], color_default, color_filetxt, ent, "10") + } +} +function printcolor(i, c, d, n, b) { + if (limit != "" && length(n) + 2 > limit) + n = substr(n, 1, limit - 2) + printf "\033[0m" + printf "%s%s%s;%sm%s %s%sm%s\n", bstr, escape, c, b, i, escape, d, n +}' +printf '\033[0m' +} + +print_begin() { + printf '%s\n' "$1" | sed 's/\\n/\n/g' +} + +print_end() { + printf '%s\n' "$1" | sed 's/\\n/\n/g' +} + +print_help() { + printf 'Icon Lookup\n +Usage: + iconlookup [options] + iconlookup [-bBe] [string] + iconlookup -l [number] + iconlookup (-h | --help) + + Prepend icons to list of files based on extension or appended indicator by ls/tree "-F" flag ("/" for directory, "*" for executable etc.) + +Options: + -h --help -? Show this screen. + -b --before Prepend str before icon. + -B --begin Prepend str before output. + -e --end Append str after output. + -l --limit Limit line length to [number] characters.' +} + +while :; do + case $1 in + -h|-\?|--help) + print_help + exit ;; + -B|--begin) + if [ -n "$2" ]; then + print_begin "$2" + fi + shift ;; + -e|--end) + if [ -n "$2" ]; then + end=1 + endstr="$2" + fi + shift ;; + -b|--before) + if [ -n "$2" ]; then + export beforestr="$2" + fi + shift ;; + -l|--limit) + if [ -n "$2" ]; then + export limit="$2" + shift + else + printf 'ERROR: "--limit" requires a non-empty option argument.\n' + exit + fi ;; + --) + shift + break ;; + -?*) + printf 'WARNING: Unknown option ignored: %s\n' "$1" ;; + *) break ;; + esac + shift +done + +if [ ! -t 0 ]; then + [ -n "$beforestr" ] && limit="$((limit - ${#beforestr}))" + icon_lookup +else + printf 'ERROR: no data provided...\nExpecting a directory listing in stdin\n' +fi + +if [ -n "$end" ]; then + print_end "$endstr" +fi diff --git a/.local/share/nnn/plugins/.nmv b/.local/share/nnn/plugins/.nmv new file mode 100755 index 0000000..37e887d --- /dev/null +++ b/.local/share/nnn/plugins/.nmv @@ -0,0 +1,180 @@ +#!/usr/bin/env bash + +# Description: An almost fully POSIX compliant batch file renamer +# +# Note: nnn auto-detects and invokes this plugin if available +# Whitespace is used as delimiter for read. +# The plugin doesn't support filenames with leading or trailing whitespace +# To use NNN_LIST your shell must support readlink(1) +# +# Capabilities: +# 1. Basic file rename +# 2. Detects order change +# 3. Can move files +# 4. Can remove files +# 5. Switch number pairs to swap filenames +# +# Shell: bash +# Author: KlzXS + +EDITOR="${EDITOR:-vi}" +TMPDIR="${TMPDIR:-/tmp}" +NNN_INCLUDE_HIDDEN="${NNN_INCLUDE_HIDDEN:-0}" +VERBOSE="${VERBOSE:-0}" +RECURSIVE="${RECURSIVE:-0}" + +case "$NNN_TRASH" in + 1) + RM_UTIL="trash-put" ;; + 2) + RM_UTIL="gio trash" ;; + *) + RM_UTIL="rm -ri" ;; +esac + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +exit_status=0 + +dst_file=$(mktemp "$TMPDIR/.nnnXXXXXX") + +if [ -s "$selection" ]; then + printf "Rename 'c'urrent / 's'election? " + read -r resp + + if ! [ "$resp" = "c" ] && ! [ "$resp" = "s" ]; then + exit 1 + fi +fi + +if [ "$resp" = "s" ]; then + arr=$(tr '\0' '\n' < "$selection") +else + findcmd="find . ! -name ." + + if [ "$RECURSIVE" -eq 0 ]; then + findcmd="$findcmd -prune" + fi + + if [ "$NNN_INCLUDE_HIDDEN" -eq 0 ]; then + findcmd="$findcmd ! -name \".*\"" + fi + + if [ -z "$NNN_LIST" ]; then + findcmd="$findcmd -print" + else + findcmd="$findcmd -printf "'"'"$NNN_LIST/%P\n"'"' + fi + + arr=$(eval "$findcmd" | sort) +fi + +lines=$(printf "%s\n" "$arr" | wc -l) +width=${#lines} + +printf "%s" "$arr" | awk '{printf("%'"${width}"'d %s\n", NR, $0)}' > "$dst_file" + +items=("~") +while IFS='' read -r line; do + if [ -n "$NNN_LIST" ]; then + line=$(readlink "$line" || printf "%s" "$line") + fi + + items+=("$line"); +done < <(printf "%s\n" "$arr") + +$EDITOR "$dst_file" + +while read -r num name; do + if [ -z "$name" ]; then + if [ -z "$num" ]; then + continue + fi + + printf "%s: unable to parse line, aborting\n" "$0" + exit 1 + fi + + # check if $num is an integer + if [ ! "$num" -eq "$num" ] 2> /dev/null; then + printf "%s: unable to parse line, aborting\n" "$0" + exit 1 + fi + + src=${items[$num]} + + if [ -z "$src" ]; then + printf "%s: unknown item number %s\n" "$0" "$num" > /dev/stderr + continue + elif [ "$name" != "$src" ]; then + if [ -z "$name" ]; then + continue + fi + + if [ ! -e "$src" ] && [ ! -L "$src" ]; then + printf "%s: %s does not exit\n" "$0" "$src" > /dev/stderr + + unset "items[$num]" + continue + fi + + # handle swaps + if [ -e "$name" ] || [ -L "$name" ]; then + tmp="$name~" + c=0 + + while [ -e "$tmp" ] || [ -L "$tmp" ]; do + c=$((c+1)) + tmp="$tmp~$c" + done + + if mv "$name" "$tmp"; then + if [ "$VERBOSE" -ne 0 ]; then + printf "'%s' -> '%s'\n" "$name" "$tmp" + fi + else + printf "%s: failed to rename %s to %s: %s\n" "$0" "$name" "$tmp" "$!" > /dev/stderr + exit_status=1 + fi + + for key in "${!items[@]}"; do + if [ "${items[$key]}" = "$name" ]; then + items[$key]="$tmp" + fi + done + fi + + dir=$(dirname "$name") + if [ ! -d "$dir" ] && ! mkdir -p "$dir"; then + printf "%s: failed to create directory tree %s\n" "$0" "$dir" > /dev/stderr + exit_status=1 + elif ! mv -i "$src" "$name"; then + printf "%s: failed to rename %s to %s: %s\n" "$0" "$name" "$tmp" "$!" > /dev/stderr + exit_status=1 + else + if [ -d "$name" ]; then + for key in "${!items[@]}"; do + items[$key]=$(printf "%s" "${items[$key]}" | sed "s|^$src\(\$\|\/\)|$name\1|") + done + + if [ "$VERBOSE" -ne 0 ]; then + printf "'%s' => '%s'\n" "$src" "$name" + fi + else + true + if [ "$VERBOSE" -ne 0 ]; then + printf "'%s' -> '%s'\n" "$src" "$name" + fi + fi + fi + fi + + unset "items[$num]" +done <"$dst_file" + +unset "items[0]" +for item in "${items[@]}"; do + $RM_UTIL "$item" +done + +rm "$dst_file" +exit $exit_status diff --git a/.local/share/nnn/plugins/.nnn-plugin-helper b/.local/share/nnn/plugins/.nnn-plugin-helper new file mode 100644 index 0000000..a0377ac --- /dev/null +++ b/.local/share/nnn/plugins/.nnn-plugin-helper @@ -0,0 +1,38 @@ +#!/usr/bin/env sh + +# Description: Helper script for plugins +# +# Shell: POSIX compliant +# Author: Anna Arad + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +export selection + +## Set CUR_CTX to 1 to open directory in current context +CUR_CTX=0 +export CUR_CTX + +## Ask nnn to switch to directory $1 in context $2. +## If $2 is not provided, the function asks explicitly. +nnn_cd () { + dir="$1" + + if [ -z "$NNN_PIPE" ]; then + echo "No pipe file found" 1>&2 + return + fi + + if [ -n "$2" ]; then + context=$2 + elif [ $CUR_CTX -ne 1 ]; then + printf "Choose context 1-4 (blank for current): " + read -r context + fi + + printf "%s" "${context:-0}c$dir" > "$NNN_PIPE" +} + +cmd_exists () { + type "$1" > /dev/null 2>&1 + echo $? +} diff --git a/.local/share/nnn/plugins/.ntfy b/.local/share/nnn/plugins/.ntfy new file mode 100755 index 0000000..2a61478 --- /dev/null +++ b/.local/share/nnn/plugins/.ntfy @@ -0,0 +1,22 @@ +#!/usr/bin/env sh + +# Description: Show a notification +# +# Details: nnn invokes this plugin to show notification when a cp/mv/rm operation is complete. +# +# Dependencies: notify-send (Ubuntu)/ntfy (https://github.com/dschep/ntfy)/osascript (macOS)/notify (Haiku) +# +# Shell: POSIX compliant +# Author: Anna Arad + +OS="$(uname)" + +if type notify-send >/dev/null 2>&1; then + notify-send nnn "Done!" +elif [ "$OS" = "Darwin" ]; then + osascript -e 'display notification "Done!" with title "nnn"' +elif type ntfy >/dev/null 2>&1; then + ntfy -t nnn send "Done!" +elif [ "$OS" = "Haiku" ]; then + notify --title "nnn" "Done!" +fi diff --git a/.local/share/nnn/plugins/README.md b/.local/share/nnn/plugins/README.md new file mode 100644 index 0000000..bb27d05 --- /dev/null +++ b/.local/share/nnn/plugins/README.md @@ -0,0 +1,378 @@ +

nnn plugins

+ +

+

read ebooks with plugin gutenread (Android)

+ +## Introduction + +Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or binaries) `nnn` can communicate with and trigger. This mechanism fits perfectly with the fundamental design to keep the core file manager lean and fast, by delegating repetitive (but not necessarily file manager-specific) tasks to the plugins which can be run with custom hotkeys. + +`nnn` is _**language-agnostic**_ when it comes to plugins. You can write a plugin in any (scripting) language you are comfortable in! + +## List of plugins + +| Plugin (a-z) | Description [Clears selection1] | Lang | Dependencies | +| --- | --- | --- | --- | +| [autojump](autojump) | Navigate to dir/path | sh | [jump](https://github.com/gsamokovarov/jump)/autojump/
zoxide/z/[z.lua](https://github.com/skywind3000/z.lua) | +| [boom](boom) | Play random music from dir | sh | [moc](http://moc.daper.net/) | +| [bulknew](bulknew) | Create multiple files/dirs at once | bash | sed, xargs, mktemp | +| [cdpath](cdpath) | `cd` to the directory from `CDPATH` | sh | fzf | +| [chksum](chksum) | Create and verify checksums [✓] | sh | md5sum,
sha256sum | +| [cmusq](cmusq) | Queue/play files/dirs in cmus player [✓] | sh | cmus, pgrep | +| [diffs](diffs) | Diff for selection (limited to 2 for directories) [✓] | sh | vimdiff, mktemp | +| [dragdrop](dragdrop) | Drag/drop files from/into nnn | sh | [dragon](https://github.com/mwh/dragon) | +| [dups](dups) | List non-empty duplicate files in current dir | bash | find, md5sum,
sort uniq xargs | +| [finder](finder) | Run custom find command (**stored in histfile**) and list | sh | - | +| [fixname](fixname) | Clean filename to be more shell-friendly [✓] | bash | sed | +| [fzcd](fzcd) | Fuzzy search multiple dirs (or `$PWD`) and visit file | sh | fzf, (find) | +| [fzhist](fzhist) | Fuzzy-select a cmd from history, edit in `$EDITOR` and run | sh | fzf, mktemp | +| [fzopen](fzopen) | Fuzzy find file(s) in subtree to edit/open/pick | sh | fzf, xdg-open/open | +| [fzplug](fzplug) | Fuzzy find, preview and run other plugins | sh | fzf | +| [getplugs](getplugs) | Update plugins to installed `nnn` version | sh | curl | +| [gitroot](gitroot) | Cd to the root of current git repo | sh | git | +| [gpge](gpge) | Encrypt/decrypt files using GPG [✓] | sh | gpg | +| [gutenread](gutenread) | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m
[epr](https://github.com/wustho/epr) (optional) | +| [gsconnect](gsconnect) | GNOME's implementation of kdeconnect [✓] | sh | gsconnect | +| [imgresize](imgresize) | Batch resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) | +| [imgur](imgur) | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) | bash | - | +| [imgview](imgview) | View (thumbnail)images, set wallpaper, [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images) and [more](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)| sh | _see in-file docs_ | +| [ipinfo](ipinfo) | Fetch external IP address and whois information | sh | curl, whois | +| [kdeconnect](kdeconnect) | Send selected files to an Android device [✓] | sh | kdeconnect-cli | +| [launch](launch) | GUI application launcher | sh | fzf | +| [mimelist](mimelist) | List files by mime in subtree | sh | - | +| [moclyrics](moclyrics) | Show lyrics of the track playing in moc | sh | [ddgr](https://github.com/jarun/ddgr), [moc](http://moc.daper.net/) | +| [mocq](mocq) | Queue/play selection/dir/file in moc [✓] | sh | [moc](http://moc.daper.net/) | +| [mp3conv](mp3conv) | Extract audio from multimedia as mp3 | sh | ffmpeg | +| [mtpmount](mtpmount) | Toggle mount of MTP device (eg. Android) | sh | gvfs-mtp | +| [nbak](nbak) | Backs up `nnn` config | sh | tar, awk, mktemp | +| [nmount](nmount) | Toggle mount status of a device as normal user | sh | pmount, udisks2 | +| [nuke](nuke) | Sample file opener (CLI-only by default) | sh | _see in-file docs_ | +| [oldbigfile](oldbigfile) | List large files by access time | sh | find, sort | +| [openall](openall) | Open selected files together or one by one [✓] | bash | - | +| [organize](organize) | Auto-organize files in directories by file type [✓] | sh | file | +| [pdfread](pdfread) | Read a PDF or text file aloud | sh | pdftotext, mpv,
pico2wave | +| [preview-tabbed](preview-tabbed) | Preview files with Tabbed/xembed | bash | _see in-file docs_ | +| [preview-tui](preview-tui) | Preview with Tmux/kitty/[QuickLook](https://github.com/QL-Win/QuickLook)/xterm/`$TERMINAL` | sh | _see in-file docs_ | +| [pskill](pskill) | Fuzzy list by name and kill process or zombie | sh | fzf, ps, sudo/doas | +| [renamer](renamer) | Batch rename selection or files in dir [✓] | sh | [qmv](https://www.nongnu.org/renameutils/)/[vidir](https://joeyh.name/code/moreutils/) | +| [ringtone](ringtone) | Create a variable bitrate mp3 ringtone from file | sh | date, ffmpeg | +| [rsynccp](rsynccp) | Gives copy-paste verbose progress percentage [✓] | sh | rsync | +| [splitjoin](splitjoin) | Split file or join selection [✓] | sh | split, cat | +| [suedit](suedit) | Edit file using superuser permissions | sh | sudoedit/sudo/doas | +| [togglex](togglex) | Toggle executable mode for selection [✓] | sh | chmod | +| [umounttree](umounttree) | Unmount a remote mountpoint from within | sh | fusermount | +| [upload](upload) | Upload to Firefox Send or ix.io (text) or file.io (bin) | sh | [ffsend](https://github.com/timvisee/ffsend), curl, jq, tr | +| [wallpaper](wall) | Set wallpaper or change colorscheme | sh | nitrogen/pywal | +| [x2sel](x2sel) | Copy file list from system clipboard to selection | sh | _see in-file docs_ | +| [xdgdefault](xdgdefault) | Set the default app for the hovered file type | sh | xdg-utils, fzf/dmenu | + +Notes: + +1. A plugin has to explicitly request `nnn` to clear the selection e.g. after operating on the selected files. +2. Files starting with a dot in the `plugins` directory are internal files and should not be used as plugins. + +### Table of contents + +- [Installation](#installation) +- [Configuration](#configuration) + - [Skip directory refresh after running a plugin](#skip-directory-refresh-after-running-a-plugin) +- [Running commands as plugin](#running-commands-as-plugin) + - [Skip user confirmation after command execution](#skip-user-confirmation-after-command-execution) + - [Run a GUI app as plugin](#run-a-gui-app-as-plugin) + - [Page non-interactive command output](#page-non-interactive-command-output) + - [Some useful key-command examples](#some-useful-key-command-examples) +- [Access level of plugins](#access-level-of-plugins) +- [Create your own plugins](#create-your-own-plugins) + - [Send data to `nnn`](#send-data-to-nnn) + - [Get notified on file hover](#get-notified-on-file-hover) +- [Examples](#examples) +- [Contributing plugins](#contributing-plugins) + +## Installation + +The following command installs or updates (after backup) all plugins: + +```sh +curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh +``` + +Plugins are installed to `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins`. + +## Configuration + +Set environment variable `NNN_PLUG` to assign keybinds and invoke plugins directly using the plugin shortcut (;) followed by the assigned key character. E.g., with the below config: + +```sh +export NNN_PLUG='f:finder;o:fzopen;p:mocq;d:diffs;t:nmount;v:imgview' +``` + +plugin `finder` can be invoked with the keybind ;f, `fzopen` can be run with ;o and so on... The key vs. plugin pairs are shown in the help and config screen. + +Alternatively, combine with Alt (i.e. Alt+key). + +To pick and run an unassigned plugin, press Enter (to _enter_ the plugin dir) at the plugin prompt. + +To run a plugin at startup, use the option `-P` followed by the plugin key. + +If the plugins list gets too long, try breaking them up into sections: + +``` +NNN_PLUG_PERSONAL='g:personal/convert2zoom;p:personal/echo' +NNN_PLUG_WORK='j:work/prettyjson;d:work/foobar' +NNN_PLUG_INLINE='e:!go run $nnn*' +NNN_PLUG_DEFAULT='1:ipinfo;p:preview-tui;o:fzz;b:nbak' +NNN_PLUG="$NNN_PLUG_PERSONAL;$NNN_PLUG_WORK;$NNN_PLUG_DEFAULT;$NNN_PLUG_INLINE" +export NNN_PLUG +``` + +Note: +- `'g:personal/convert2zoom'` will look in the personal sub-folder inside the plugin folder. +- `'b:boom;b:bulknew` will result in only the first definition of *b* (`b:boom`) being used. +- A keybinding definition of more than 1 character will prevent nnn from starting. + + +#### Skip directory refresh after running a plugin [`-`] + +`nnn` refreshes the directory after running a plugin to reflect any changes by the plugin. To disable this add a `-` before the plugin name: + +```sh +export NNN_PLUG='p:-plugin' +``` + +## Running commands as plugin [`!`] + +To assign keys to arbitrary non-background cli commands and invoke like plugins, add `!` (underscore) before the command. + +```sh +export NNN_PLUG='x:!chmod +x $nnn;g:!git log;s:!smplayer $nnn' +``` + +Now ;x can be used to make a file executable, ;g can be used to the git log of a git project directory, ;s can be used to preview a partially downloaded media file. + +#### Skip user confirmation after command execution [`*`] + +`nnn` waits for user confirmation (the prompt `Press Enter to continue`) after it executes a command as plugin (unlike plugins which can add a `read` to wait). To skip this, add a `*` after the command. + +```sh +export NNN_PLUG='s:!smplayer $nnn*;n:-!vim /home/vaio/Dropbox/Public/synced_note*' +``` + +Now there will be no prompt after ;s and ;n. + +Note: Do not use `*` with programs those run and exit e.g. cat. + +#### Run a GUI app as plugin [`&`] + +To run a GUI app as plugin, add a `&` after `!`. + +```sh +export NNN_PLUG='m:-!&mousepad $nnn' +``` + +Note: `$nnn` must be the last argument in this case. + +#### Page non-interactive command output [`|`] + +To show the output of run-and-exit commands which do not need user input, add `|` (pipe) after `!`. + +```sh +export NNN_PLUG='m:-!|mediainfo $nnn;t:-!|tree -ps;l:-!|ls -lah --group-directories-first' +``` + +This option is incompatible with `&` (terminal output is masked for GUI programs) and ignores `*` (output is already paged for user). + +Notes: + +1. Use single quotes for `$NNN_PLUG` so `$nnn` is not interpreted +2. `$nnn` must be the last argument (if used) to run a _command as plugin_ +3. (_Again_) add `!` before the command +4. To disable directory refresh after running a _command as plugin_, prefix with `-!` + +#### Some useful key-command examples + +| Key:Command | Description | +|---|---| +| `c:!convert $nnn png:- \| xclip -sel clipboard -t image/png*` | Copy image to clipboard | +| `e:-!sudo -E vim $nnn*` | Edit file as root in vim | +| `g:-!git diff` | Show git diff | +| `h:-!hx $nnn*` | Open hovered file in [hx](https://github.com/krpors/hx) hex editor | +| `k:-!fuser -kiv $nnn*` | Interactively kill process(es) using hovered file | +| `l:-!git log` | Show git log | +| `n:-!vi /home/user/Dropbox/dir/note*` | Take quick notes in a synced file/dir of notes | +| `p:-!less -iR $nnn*` | Page through hovered file in less | +| `s:-!&smplayer -minigui $nnn` | Play hovered media file, even unfinished download | +| `x:!chmod +x $nnn` | Make the hovered file executable | +| `y:-!sync*` | Flush cached writes | + +## Access level of plugins + +When `nnn` executes a plugin, it does the following: +- Changes to the directory where the plugin is to be run (`$PWD` pointing to the active directory) +- Passes three arguments to the script: + 1. `$1`: The hovered file's name. + 2. `$2`: The working directory (might differ from `$PWD` in case of symlinked paths; non-canonical). + 3. `$3`: The picker mode output file (`-` for stdout) if `nnn` is executed as a file picker. +- Sets the environment variable `NNN_PIPE` used to control `nnn` active directory. +- Sets the environment variable `NNN_INCLUDE_HIDDEN` to `1` if hidden files are active, `0` otherwise. +- Exports the [special variables](https://github.com/jarun/nnn/wiki/Concepts#special-variables). + +Plugins can also read the `.selection` file in the config directory. + +## Create your own plugins + +Plugins can be written in any scripting language. However, POSIX-compliant shell scripts runnable in `sh` are preferred. + +**Make the file executable**. Drop it in the plugin directory. Optionally add a hotkey in `$NNN_PLUG` for frequent usage. + +#### Send data to `nnn` +`nnn` provides a mechanism for plugins to send data to `nnn` to control its active directory or invoke the list mode. +The way to do so is by writing to the pipe pointed by the environment variable `NNN_PIPE`. +The plugin should write a single string in the format `(<->)` without a newline at the end. For example, `1c/etc`. + +The optional `-` at the **beginning of the stream** instructs `nnn` to clear the selection. +In cases where the data transfer to `nnn` has to happen while the selection file is being read (e.g. in a loop), the plugin should +create a tmp copy of the selection file, inform `nnn` to clear the selection and then do the subsequent processing with the tmp file. +A paged [`|`] or GUI [`&`] cmd run as plugin cannot clear selection. + +The `ctxcode` indicates the context to change the active directory of. + +| Context code | Meaning | +|:---:| --- | +| `+` | smart context (next inactive else current) | +| `0` | current context | +| `1`-`4` | context number | + +The `opcode` indicates the operation type. + +| Opcode | Operation | +|:---:| --- | +| `c` | change directory | +| `l` | list files in list mode | +| `p` | picker file overwritten | + +For convenience, we provided a helper script named `.nnn-plugin-helper` and a function named `nnn_cd` to ease this process. `nnn_cd` receives the path to change to as the first argument, and the context as an optional second argument. +If a context is not provided, it is asked for explicitly. To skip this and choose the current context, set the `CUR_CTX` variable in `.nnn-plugin-helper` (or in the specific plugin after sourcing `.nnn-plugin-helper`) to 1. +Usage examples can be found in the Examples section below. + +#### Get notified on file hover + +If `NNN_FIFO` is set, `nnn` will open it and write every hovered files. This can be used in plugins and external scripts, e.g. to implement file previews. + +Don't forget to fork in the background to avoid blocking `nnn`. + +For more details on configuration and usage of the preview plugins, visit [Live Previews](https://github.com/jarun/nnn/wiki/Live-previews). + +## Examples + +There are many plugins provided by `nnn` which can be used as examples. Here are a few simple selected examples. + +#### Show the git log of changes to the particular file along with the code for a quick and easy review. + +```sh +#!/usr/bin/env sh + +git log -p -- "$1" +``` + +#### Change to directory in clipboard using helper script + +```sh +#!/usr/bin/env sh + +. $(dirname $0)/.nnn-plugin-helper + +nnn_cd "$(xsel -ob)" +``` + +#### Change directory to the location of a link using helper script with specific context (current) + +```sh +#!/usr/bin/env sh + +. $(dirname $0)/.nnn-plugin-helper + +nnn_cd "$(dirname $(readlink -fn $1))" 0 +``` + +#### Change to arbitrary directory without helper script + +```sh +#!/usr/bin/env sh + +printf "cd to: " +read -r dir + +printf "%s" "0c$dir" > "$NNN_PIPE" +``` + +#### Send every hovered file to X selection + +```sh +#!/usr/bin/env sh + +if [ -z "$NNN_FIFO" ] ; then + exit 1 +fi + +while read FILE ; do + printf "%s" "$FILE" | xsel +done < "$NNN_FIFO" & +disown +``` + +#### Quick `find` the first match in subtree and open in `nuke` + +```sh +#!/usr/bin/env sh + +NUKE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/nuke" + +printf "file name: " +read -r pattern + +entry=$(find . -type f -iname "$pattern" -print -quit 2>/dev/null) + +if [ -n "$entry" ]; then + "$NUKE" "$entry" +fi +``` + +#### Quick find (using `fd`) + +```sh +#!/usr/bin/env sh + +. "$(dirname "$0")"/.nnn-plugin-helper + +printf "pattern: " +read -r pattern + +if [ -n "$pattern" ]; then + printf "%s" "+l" > "$NNN_PIPE" + eval "fd -HI $pattern -0" > "$NNN_PIPE" +fi +``` + +#### Quick grep (using `rg`) + +```sh +#!/usr/bin/env sh + +. "$(dirname "$0")"/.nnn-plugin-helper + +printf "pattern: " +read -r pattern + +if [ -n "$pattern" ]; then + printf "%s" "+l" > "$NNN_PIPE" + eval "rg -l0 --hidden -S $pattern" > "$NNN_PIPE" +fi +``` + +## Contributing plugins + +1. Add informative sections like _Description_, _Notes_, _Dependencies_, _Shell_, _Author_ etc. in the plugin. +2. Add an entry in the table above. Note that the list is alphabetically ordered by plugin name. +3. Keep non-portable commands (like `notify-send`) commented so users from any other OS/DE aren't surprised. +4. The plugin file should be executable. +5. If your plugin stores data, use `${XDG_CACHE_HOME:-$HOME/.cache}/nnn`. Document it _in-file_. diff --git a/.local/share/nnn/plugins/autojump b/.local/share/nnn/plugins/autojump new file mode 100755 index 0000000..6a24a52 --- /dev/null +++ b/.local/share/nnn/plugins/autojump @@ -0,0 +1,74 @@ +#!/usr/bin/env sh + +# Description: Navigate to directory using jump/autojump/zoxide/z +# +# Dependencies: +# - jump - https://github.com/gsamokovarov/jump +# - OR autojump - https://github.com/wting/autojump +# - OR zoxide - https://github.com/ajeetdsouza/zoxide +# - OR z - https://github.com/rupa/z (z requires fzf) +# - OR z (fish) - https://github.com/jethrokuan/z (z requires fzf) +# - OR z.lua - https://github.com/skywind3000/z.lua (z.lua can enhanced with fzf) +# +# Note: The dependencies STORE NAVIGATION PATTERNS +# +# to make z.lua work, you need to set $NNN_ZLUA to the path of script z.lua +# +# Shell: POSIX compliant +# Authors: Marty Buchaus, Dave Snider, Tim Adler, Nick Waywood + +if [ ! -p "$NNN_PIPE" ]; then + printf 'ERROR: NNN_PIPE is not set!' + read -r _ + exit 2 +fi + +if type jump >/dev/null 2>&1; then + printf "jump to : " + IFS= read -r line + # shellcheck disable=SC2086 + odir="$(jump cd ${line})" + printf "%s" "0c$odir" > "$NNN_PIPE" +elif type autojump >/dev/null 2>&1; then + printf "jump to : " + read -r dir + odir="$(autojump "$dir")" + printf "%s" "0c$odir" > "$NNN_PIPE" +elif type zoxide >/dev/null 2>&1; then + if type fzf >/dev/null 2>&1; then + odir="$(zoxide query -i --)" + printf "%s" "0c$odir" > "$NNN_PIPE" + else + printf "jump to : " + read -r dir + odir="$(zoxide query -- "$dir")" + printf "%s" "0c$odir" > "$NNN_PIPE" + fi +elif type lua >/dev/null 2>&1 && [ -n "$NNN_ZLUA" ]; then + printf "jump to : " + read -r line + if type fzf >/dev/null 2>&1; then + odir="$(lua "$NNN_ZLUA" -l "$line" | fzf --nth 2.. --reverse --inline-info --tac +s -e --height 35%)" + printf "%s" "0c$(echo "$odir" | awk '{print $2}')" > "$NNN_PIPE" + else + odir="$(lua "$NNN_ZLUA" -e "$line")" + printf "%s" "0c$odir" > "$NNN_PIPE" + fi +else + # rupa/z uses $_Z_DATA, jethrokuan/z (=port of z for fish) uses $Z_DATA + datafile="${_Z_DATA:-${Z_DATA:-$HOME/.z}}" + if type fzf >/dev/null 2>&1 && [ -f "$datafile" ]; then + # Read the data from z's file instead of calling + # z so the data doesn't need to be processed twice + sel=$(awk -F "|" '{print $1}' "$datafile" | fzf | awk '{$1=$1};1') + + # NOTE: Uncomment this line and comment out the line above if + # you want to see the weightings of the dir's in the fzf pane + # sel=$(awk -F "|" '{printf "%s %s\n", $2, $1}' "$datafile" | fzf | sed 's/^[0-9,.]* *//' | awk '{$1=$1};1') + + printf "%s" "0c$sel" > "$NNN_PIPE" + else + printf "No supported autojump script [jump/autojump/zoxide/z (needs fzf)] found" + read -r _ + fi +fi diff --git a/.local/share/nnn/plugins/boom b/.local/share/nnn/plugins/boom new file mode 100755 index 0000000..aab466f --- /dev/null +++ b/.local/share/nnn/plugins/boom @@ -0,0 +1,50 @@ +#!/usr/bin/env sh + +# Description: Play random music (MP3, FLAC, M4A, WEBM, WMA) from current dir. +# +# Dependencies: mocp (or custom) +# +# Note: You may want to set GUIPLAYER. +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +GUIPLAYER="${GUIPLAYER:-""}" +NUMTRACKS="${NUMTRACKS:-100}" + +if [ -n "$GUIPLAYER" ]; then + find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf -n "$NUMTRACKS" | xargs -d "\n" "$GUIPLAYER" > /dev/null 2>&1 & + + # detach the player + sleep 1 +elif type mocp >/dev/null 2>&1; then + cmd=$(pgrep -x mocp 2>/dev/null) + ret=$cmd + + if [ -z "$ret" ]; then + # start MOC server + mocp -S + mocp -o shuffle + else + # mocp running, check if it's playing + state=$(mocp -i | grep "State:" | cut -d' ' -f2) + if [ "$state" = 'PLAY' ]; then + # add up to 100 random audio files + find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a + exit + fi + fi + + # clear MOC playlist + mocp -c + mocp -o shuffle + + # add up to 100 random audio files + find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a + + # start playing + mocp -p +else + printf "moc missing" + read -r _ +fi diff --git a/.local/share/nnn/plugins/bulknew b/.local/share/nnn/plugins/bulknew new file mode 100755 index 0000000..64331e4 --- /dev/null +++ b/.local/share/nnn/plugins/bulknew @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +# Description: Allows for creation of multiple files/dirs simultaneously +# Creates a tmp file to write each entry in a separate line +# +# Note: Only relative paths are supported. Absolute paths are ignored +# Leading and trailing whitespace in path names is also ignored +# +# Shell: POSIX compliant +# Author: KlzXS + +EDITOR="${EDITOR:-vi}" +TMPDIR="${TMPDIR:-/tmp}" + +printf "'f'ile / 'd'ir? " +read -r resp + +if [ "$resp" = "f" ]; then + #shellcheck disable=SC2016 + cmd='mkdir -p "$(dirname "{}")" && touch "{}"' +elif [ "$resp" = "d" ]; then + cmd='mkdir -p {}' +else + exit 1 +fi + +tmpfile=$(mktemp "$TMPDIR/.nnnXXXXXX") +$EDITOR "$tmpfile" + +sed "/^\//d" "$tmpfile" | xargs -n1 -I{} sh -c "$cmd" + +rm "$tmpfile" diff --git a/.local/share/nnn/plugins/cdpath b/.local/share/nnn/plugins/cdpath new file mode 100755 index 0000000..663cb26 --- /dev/null +++ b/.local/share/nnn/plugins/cdpath @@ -0,0 +1,56 @@ +#!/usr/bin/env sh + +# Description: 'cd' to the directory from CDPATH +# +# Details: If the CDPATH environmet variable is not set, the default value of +# ${XDG_CONFIG_HOME:-$HOME/.config}/nnn/bookmarks will be used. +# You can create this directory and fill it with symbolic links to your +# favorite directories. It's a good idea to add it to CDPATH so that it +# could also be used from the command line outside of nnn. +# The fzf search is done on the directory basename (the first column). +# +# This plugin is an extended version of the bookmarks plugin. +# If you set your CDPATH to ${XDG_CACHE_HOME:-$HOME/.cache}/nnn/bookmarks +# or to the value of BOOKMARKS_DIR, you can use it as a bookmarks replacement. +# +# Shell: POSIX compliant +# Author: Yuri Kloubakov + +# shellcheck disable=SC1090,SC1091 +. "$(dirname "$0")"/.nnn-plugin-helper + +# Get a list of (symbolic links to) directories for every element of CDPATH +get_dirs() { + IFS=':' + for path in $CDPATH; do + for entry in "$path"/*; do + if [ -d "$entry" ]; then + name=$(basename "$entry" | grep -o '^.\{1,24\}') + if [ -h "$entry" ]; then + slink=$(ls -dl -- "$entry") + entry=${slink#*" $entry -> "} + fi + printf "%-24s :%s\n" "${name}" "$entry" + fi + done + done +} + +abort() { + echo "$1" + read -r _ + exit 1 +} + +if [ -z "$CDPATH" ]; then + CDPATH="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/bookmarks" + [ -d "$CDPATH" ] || abort "CDPATH is not set and there is no \"$CDPATH\" directory" +fi + +dir_list=$(get_dirs) +[ -n "$dir_list" ] || abort "There are no directories to choose from. Check your \"$CDPATH\"." + +dir=$(echo "$dir_list" | fzf --nth=1 --delimiter=':' | awk -F: 'END { print $2 }') +if [ -n "$dir" ]; then + nnn_cd "$dir" 0 +fi diff --git a/.local/share/nnn/plugins/chksum b/.local/share/nnn/plugins/chksum new file mode 100755 index 0000000..5fa91cb --- /dev/null +++ b/.local/share/nnn/plugins/chksum @@ -0,0 +1,75 @@ +#!/usr/bin/env sh + +# Description: Create and verify checksums +# +# Note: On macOS, install the relevant checksum packages from Homebrew with: +# brew install coreutils +# +# Details: +# - selection: it will generate one file with the checksums and filenames +# (and with paths if they are in another directory) +# output checksum filename format: checksum_timestamp.checksum_type +# - file: if the file is a checksum, the plugin does the verification +# if the file is not a checksum, checksum will be generated for it +# the output checksum filename will be filename.checksum_type +# - directory: recursively calculates checksum for all the files in the dir +# the output checksum filename will be directory.checksum_type +# +# Shell: POSIX compliant +# Authors: ath3, Arun Prakash Jana + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +resp=f +chsum=md5 + +checksum_type() +{ + echo "possible checksums: md5, sha1, sha224, sha256, sha384, sha512" + printf "create md5 (m), sha256 (s), sha512 (S) (or type one of the above checksums) [default=m]: " + read -r chsum_resp + for chks in md5 sha1 sha224 sha256 sha384 sha512 + do + if [ "$chsum_resp" = "$chks" ]; then + chsum=$chsum_resp + return + fi + done + if [ "$chsum_resp" = "s" ]; then + chsum=sha256 + elif [ "$chsum_resp" = "S" ]; then + chsum=sha512 + fi +} + +if [ -s "$selection" ]; then + printf "work with selection (s) or current file (f) [default=f]: " + read -r resp +fi + +if [ "$resp" = "s" ]; then + checksum_type + sed 's|'"$PWD/"'||g' < "$selection" | xargs -0 -I{} ${chsum}sum {} > "checksum_$(date '+%Y%m%d%H%M').$chsum" + + # Clear selection + if [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" + fi +elif [ -n "$1" ]; then + if [ -f "$1" ]; then + for chks in md5 sha1 sha224 sha256 sha384 sha512 + do + if echo "$1" | grep -q \.${chks}$; then + ${chks}sum -c < "$1" + read -r _ + return + fi + done + checksum_type + file=$(basename "$1").$chsum + ${chsum}sum "$1" > "$file" + elif [ -d "$1" ]; then + checksum_type + file=$(basename "$1").$chsum + find "$1" -type f -exec ${chsum}sum "{}" + > "$file" + fi +fi diff --git a/.local/share/nnn/plugins/cmusq b/.local/share/nnn/plugins/cmusq new file mode 100755 index 0000000..fbaa485 --- /dev/null +++ b/.local/share/nnn/plugins/cmusq @@ -0,0 +1,80 @@ +#!/usr/bin/env sh + +# Description: Add selection or hovered file/directory to cmus queue +# +# Dependencies: cmus, pgrep, xdotool (optional) +# +# Notes: +# 1. If adding selection, files/dirs are added in the same order they were selected in nnn +# 2. A new window will be opened if cmus is not running already, playback will start immediately +# 3. If cmus is already running, files will be appended to the queue with no forced playback +# +# TODO: +# 1. Add cava and cmus-lyrics as optional dependencies +# 2. Start cava and/or cmus-lyrics in tmux or kitty panes next to cmus +# +# Shell: POSIX compliant +# Author: Kabouik + +# (Optional) Set preferred terminal emulator for cmus if not set in your env, +# or leave commented out to use OS default +#TERMINAL="kitty" + +if ! type cmus >/dev/null; then + printf "cmus missing" + read -r _ + exit 1 +fi + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +start_cmus() { + type xdotool >/dev/null && nnnwindow="$(xdotool getactivewindow)" + case "$TERMINAL" in + kitty | gnome-terminal | st) + nohup "$TERMINAL" -- cmus & ;; + havoc) + nohup "$TERMINAL" cmus & ;; + "") + nohup x-terminal-emulator -e cmus & ;; + *) + nohup "$TERMINAL" -e cmus & ;; + esac + # Give the new terminal some time to open + until cmus-remote -C; do sleep 0.1; done + [ -n "$nnnwindow" ] && xdotool windowactivate "$nnnwindow" +} >/dev/null 2>&1 + +fill_queue() { + if [ "$REPLY" = "s" ]; then + xargs < "$selection" -0 cmus-remote -q + elif [ -n "$1" ]; then + cmus-remote -q "$1" + fi +} + +# If active selection,then ask what to do +if [ -s "$selection" ]; then + printf "Queue [s]election or [c]urrently hovered? [default=c]: " + read -r REPLY +fi + +# If cmus is not running, start and play queue +if ! pgrep cmus >/dev/null; then + printf "cmus is not running, starting it in a new %s window.\n" "$TERMINAL" + start_cmus + fill_queue "$1" + cmus-remote -p + printf "Files added to cmus queue.\n" +else # Append to existing queue if cmus is already running + fill_queue "$1" + printf "Files appended to current cmus queue.\n" +fi + +# Change view +cmus-remote -C "view 4" + +# Clear selection +if [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" +fi diff --git a/.local/share/nnn/plugins/diffs b/.local/share/nnn/plugins/diffs new file mode 100755 index 0000000..0464781 --- /dev/null +++ b/.local/share/nnn/plugins/diffs @@ -0,0 +1,62 @@ +#!/usr/bin/env sh + +# Description: Show diff of 2 directories or multiple files in vimdiff +# +# Notes: +# 1. vim may show the warning: 'Vim: Warning: Input is not from a terminal' +# press 'Enter' to ignore and proceed. +# 2. if only one file is in selection, the hovered file is considered as the +# second file to diff with +# +# Shell: POSIX compliant +# Authors: Arun Prakash Jana, ath3 + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +if type nvim >/dev/null 2>&1; then + diffcmd="nvim -d" +else + diffcmd="vimdiff +0" +fi + +dirdiff() { + dir1=$(mktemp "${TMPDIR:-/tmp}"/nnn-"$(basename "$1")".XXXXXXXX) + dir2=$(mktemp "${TMPDIR:-/tmp}"/nnn-"$(basename "$2")".XXXXXXXX) + ls -A1 "$1" > "$dir1" + ls -A1 "$2" > "$dir2" + $diffcmd "$dir1" "$dir2" + rm "$dir1" "$dir2" +} + +if [ -s "$selection" ]; then + arr=$(tr '\0' '\n' < "$selection") + if [ "$(echo "$arr" | wc -l)" -gt 1 ]; then + f1="$(echo "$arr" | sed -n '1p')" + f2="$(echo "$arr" | sed -n '2p')" + if [ -d "$f1" ] && [ -d "$f2" ]; then + dirdiff "$f1" "$f2" + else + # If xargs supports the -o option, use it to get rid of: + # Vim: Warning: Input is not from a terminal + # xargs -0 -o vimdiff < $selection + + eval xargs -0 "$diffcmd" < "$selection" + fi + elif [ -n "$1" ]; then + f1="$(echo "$arr" | sed -n '1p')" + if [ -d "$f1" ] && [ -d "$1" ]; then + dirdiff "$f1" "$1" + elif [ -f "$f1" ] && [ -f "$1" ]; then + $diffcmd "$f1" "$1" + else + echo "cannot compare file with directory" + fi + else + echo "needs at least 2 files or directories selected for comparison" + fi +fi + +# Clear selection +if [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" +fi diff --git a/.local/share/nnn/plugins/dragdrop b/.local/share/nnn/plugins/dragdrop new file mode 100755 index 0000000..812f970 --- /dev/null +++ b/.local/share/nnn/plugins/dragdrop @@ -0,0 +1,77 @@ +#!/usr/bin/env sh + +# Description: Open a Drag and drop window, to drop files onto other programs. +# Also provides drag and drop window for files. +# +# Dependencies: dragon - https://github.com/mwh/dragon +# +# Notes: +# 1. Files that are dropped will be added to nnn's selection +# Some web-based files will be downloaded to current dir +# with curl and it may overwrite some existing files +# 2. The user has to mm to clear nnn's selection first +# +# Shell: POSIX compliant +# Author: 0xACE + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +resp=f +all= +if type dragon-drag-and-drop >/dev/null 2>&1; then + dnd="dragon-drag-and-drop" +elif type dragon-drop >/dev/null 2>&1; then + dnd="dragon-drop" +else + dnd="dragon" +fi + +add_file () +{ + printf '%s\0' "$@" >> "$selection" +} + +use_all () +{ + printf "mark --all (a) [default=none]: " + read -r resp + if [ "$resp" = "a" ]; then + all="--all" + else + all="" + fi +} + +if [ -s "$selection" ]; then + printf "Drop file (r). Drag selection (s), Drag current directory (d) or drag current file (f) [default=f]: " + read -r resp +else + printf "Drop file (r). Drag current directory (d) or drag current file (f) [default=f]: " + read -r resp + if [ "$resp" = "s" ]; then + resp=f + fi +fi + +if [ "$resp" = "s" ]; then + use_all + sed -z 's|'"$PWD/"'||g' < "$selection" | xargs -0 "$dnd" "$all" & +elif [ "$resp" = "d" ]; then + use_all + "$dnd" "$all" "$PWD/"* & +elif [ "$resp" = "r" ]; then + true > "$selection" + "$dnd" --print-path --target | while read -r f + do + if printf "%s" "$f" | grep '^\(https\?\|ftps\?\|s\?ftp\):\/\/' ; then + curl -LJO "$f" + add_file "$PWD/$(basename "$f")" + elif [ -e "$f" ]; then + add_file "$f" + fi + done & +else + if [ -n "$1" ] && [ -e "$1" ]; then + "$dnd" "$1" & + fi +fi + diff --git a/.local/share/nnn/plugins/dups b/.local/share/nnn/plugins/dups new file mode 100755 index 0000000..27c1807 --- /dev/null +++ b/.local/share/nnn/plugins/dups @@ -0,0 +1,70 @@ +#!/usr/bin/env sh + +# Description: List non-empty duplicates in the current dir (based on size followed by MD5) +# +# Source: https://www.commandlinefu.com/commands/view/3555/find-duplicate-files-based-on-size-first-then-md5-hash +# +# Dependencies: find md5sum sort uniq xargs gsed +# +# Notes: +# 1. If the file size exceeds $size_digits digits the file will be misplaced +# 12 digits fit files up to 931GiB +# 2. Bash compatible required for mktemp +# +# Shell: Bash +# Authors: syssyphus, KlzXS + +EDITOR="${EDITOR:-vi}" +TMPDIR="${TMPDIR:-/tmp}" + +size_digits=12 +tmpfile=$(mktemp "$TMPDIR/.nnnXXXXXX") + +printf "\ +## This is an overview of all duplicate files found. +## Comment out the files you wish to remove. You will be given an option to cancel. +## Lines with double comments (##) are ignored. +## You will have the option to remove the files with force or interactively.\n +" > "$tmpfile" + +# shellcheck disable=SC2016 +find . -size +0 -type f -printf "%${size_digits}s %p\n" | sort -rn | uniq -w"${size_digits}" -D | sed -e ' +s/^ \{0,12\}\([0-9]\{0,12\}\) \(.*\)$/printf "%s %s\\n" "$(md5sum "\2")" "d\1"/ +' | tr '\n' '\0' | xargs -0 -n1 sh -c | sort | { uniq -w32 --all-repeated=separate; echo; } | sed -ne ' +h +s/^\(.\{32\}\).* d\([0-9]*\)$/## md5sum: \1 size: \2 bytes/p +g + +:loop +N +/.*\n$/!b loop +p' | sed -e 's/^.\{32\} \(.*\) d[0-9]*$/\1/' >> "$tmpfile" + +"$EDITOR" "$tmpfile" + +printf "Remove commented files? (yes/no) [default=n]: " +read -r commented + +if [ "$commented" = "y" ]; then + sedcmd="/^##.*/d; /^[^#].*/d; /^$/d; s/^# *\(.*\)$/\1/" +else + printf "Press any key to exit" + read -r _ + exit +fi + +printf "Remove with force or interactive? (f/i) [default=i]: " +read -r force + +if [ "$force" = "f" ]; then + #shellcheck disable=SC2016 + sed -e "$sedcmd" "$tmpfile" | tr '\n' '\0' | xargs -0 -r sh -c 'rm -f "$0" "$@" /dev/null; then + fexpr=${fexprs[$((fexpr - 1))]} + read -r -e -p "Search expression: " -i "$fexpr" fexpr + else + return 1 + fi +} + +readexpr() { + case "$fexpr" in + h) clear + printf "Examples:\n" + mapfile -t fexprs < <(printexamples) + printexprs 0 + read -r -p "Search expression or index: " fexpr + mapexpr + [ -n "$fexpr" ] && readexpr ;; + \$*) cmd="${fexpr:1}" ;; + *) mapexpr && readexpr + cmd="find $fexpr -print0" ;; + esac +} + +clear +[ -f "$NNN_FINDHIST" ] || printexamples > "$NNN_FINDHIST" + +mapfile -t fexprs < <(sort "$NNN_FINDHIST" | uniq -c | sort -nr | head -n5 |\ + awk '{for (i=2; i "$NNN_PIPE" + while :; do + readexpr + eval "$cmd" > "$NNN_PIPE" && break + read -r -e -p "Search expression: " -i "$fexpr" fexpr + done + if [ -n "$fexpr" ]; then + tail -n"$NNN_FINDHISTLEN" "$NNN_FINDHIST" > "$TMPDIR/finderbms" + printf "%s\n" "$fexpr" >> "$TMPDIR/finderbms" + mv "$TMPDIR/finderbms" "$NNN_FINDHIST" + fi +fi diff --git a/.local/share/nnn/plugins/fixname b/.local/share/nnn/plugins/fixname new file mode 100755 index 0000000..4047152 --- /dev/null +++ b/.local/share/nnn/plugins/fixname @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +# Description: Clean filename or dirname (either hovered or selections) +# to be more shell-friendly. This script cleans +# non A-Za-z0-9._- characters. +# and replaces it with underscore (_). +# +# It supports cleaning single/double quote, newline, +# leading, trailing spaces. +# +# eg. +# to be continued (つづく).mp4 -> to_be_continued______.mp4 +# [work] stuff.txt -> _work__stuff.txt +# home's server -> home_s_server +# qwe\trty -> __qwe_rty +# +# And if there are two almost similar filenames +# like: 'asd]f' and 'asd f' both will be renamed to 'asd_f', +# to avoid overwriting, the last file will be prepended by _. +# So they will be: 'asd_f' and '_asd_f' +# +# Dependencies: sed +# +# Shell: Bash +# Author: Benawi Adha + +prompt=true +sel=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +cleanup() { + # printf "%s" "$1" | sed -e 's/[^A-Za-z0-9._-]/_/g' + printf "%s" "$1" | sed 's/[^A-Za-z0-9._-]/_/g' | sed ':a;N;$!ba;s/\n/_/g' +} + +if [ -s "$sel" ]; then + targets=() + while IFS= read -r -d '' i || [ -n "$i" ]; do + targets+=( "$(basename "$i")" ) + done < "$sel" +else + targets=("$1") +fi + +for i in "${targets[@]}"; do + printf "%s -> %s\n" "$i" "$(cleanup "$i")"; +done + +if $prompt; then + echo + printf "Proceed [Yn]? " + read -r input + case "$input" in + y|Y|'') + ;; + *) + echo "Canceled" + exit + ;; + esac +fi + +for i in "${targets[@]}"; do + if [ "$i" != "$(cleanup "$i")" ]; then + tmp='' + if [ -e "$(cleanup "$i")" ]; then + tmp='_' + fi + mv "$i" "$tmp$(cleanup "$i")"; + fi +done + +# Clear selection +if [ -s "$sel" ] && [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" +fi diff --git a/.local/share/nnn/plugins/fzcd b/.local/share/nnn/plugins/fzcd new file mode 100755 index 0000000..125092c --- /dev/null +++ b/.local/share/nnn/plugins/fzcd @@ -0,0 +1,89 @@ +#!/usr/bin/env sh + +# Description: Fuzzy search multiple locations read-in from a path-list file +# (or $PWD) and open the selected file's dir in a smart context. +# Dependencies: fzf, find (only for multi-location search) +# +# Details: Paths in list file should be newline-separated absolute paths. +# Paths can be file paths; the script will scan the parent dirs. +# +# The path-list file precedence is: +# - "$1" (the hovered file) if it exists, is plain-text and the +# first line points to an existing file +# - "$LIST" if set below +# - "$2" (the current directory) [mimics plugin fzcd behaviour] +# +# The path-list file can be generated easily: +# - pick the (file)paths in picker mode to path-list file +# - OR, edit selection in nnn and save as path-list file +# +# Shell: POSIX compliant +# Author: Anna Arad, Arun Prakash Jana, KlzXS + +IFS="$(printf '\n\r')" + +# shellcheck disable=SC1090,SC1091 +. "$(dirname "$0")"/.nnn-plugin-helper + +CTX=+ +LIST="${LIST:-""}" + +if ! type fzf >/dev/null 2>&1; then + printf "fzf missing" + read -r _ + exit 1 +fi + +if [ -n "$1" ] && [ "$(file -b --mime-type "$1")" = 'text/plain' ] && [ -e "$(head -1 "$1")" ]; then + LIST="$1" +elif ! [ -s "$LIST" ]; then + sel=$(fzf) + # Show only the file and parent dir + # sel=$(fzf --delimiter / --with-nth=-2,-1 --tiebreak=begin --info=hidden) + + LIST='' +fi + +if [ -n "$LIST" ]; then + if type find >/dev/null 2>&1; then + tmpfile=$(mktemp /tmp/abc-script.XXXXXX) + + while IFS= read -r path; do + if [ -d "$path" ]; then + printf "%s\n" "$path" >> "$tmpfile" + elif [ -f "$path" ]; then + printf "%s\n" "$(dirname "$path")" >> "$tmpfile" + fi + done < "$LIST" + + sel=$(xargs -d '\n' < "$tmpfile" -I{} find {} -type f -printf "%H//%P\n" | sed '/.*\/\/\(\..*\|.*\/\..*\)/d; s:/\+:/:g' | fzf --delimiter / --tiebreak=begin --info=hidden) + # Alternative for 'fd' + # sel=$(xargs -d '\n' < "$tmpfile" fd . | fzf --delimiter / --tiebreak=begin --info=hidden) + + rm "$tmpfile" + else + printf "find missing" + read -r _ + exit 1 + fi +fi + +if [ -n "$sel" ]; then + if [ "$sel" = "." ] || { ! [ -d "$sel" ] && ! [ -f "$sel" ]; }; then + exit 0 + fi + + # Check if the selected path returned by fzf command is absolute + case $sel in + /*) nnn_cd "$sel" "$CTX" ;; + *) + # Remove "./" prefix if it exists + sel="${sel#./}" + + if [ "$PWD" = "/" ]; then + nnn_cd "/$sel" "$CTX" + else + nnn_cd "$PWD/$sel" "$CTX" + fi;; + esac +fi diff --git a/.local/share/nnn/plugins/fzhist b/.local/share/nnn/plugins/fzhist new file mode 100755 index 0000000..111bc22 --- /dev/null +++ b/.local/share/nnn/plugins/fzhist @@ -0,0 +1,40 @@ +#!/usr/bin/env sh + +# Description: Fuzzy find a command from history, +# edit in $EDITOR and run as a command +# +# Note: Supports only bash and fish history +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +if type fzf >/dev/null 2>&1; then + fuzzy=fzf +else + exit 1 +fi + +shellname="$(basename "$SHELL")" + +if [ "$shellname" = "bash" ]; then + hist_file="$HOME/.bash_history" + entry="$("$fuzzy" < "$hist_file")" +elif [ "$shellname" = "fish" ]; then + hist_file="$HOME/.local/share/fish/fish_history" + entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | "$fuzzy")" +fi + +if [ -n "$entry" ]; then + tmpfile=$(mktemp) + echo "$entry" >> "$tmpfile" + $EDITOR "$tmpfile" + + if [ -s "$tmpfile" ]; then + $SHELL -c "$(cat "$tmpfile")" + fi + + rm "$tmpfile" + + printf "Press any key to exit" + read -r _ +fi diff --git a/.local/share/nnn/plugins/fzopen b/.local/share/nnn/plugins/fzopen new file mode 100755 index 0000000..17b0585 --- /dev/null +++ b/.local/share/nnn/plugins/fzopen @@ -0,0 +1,83 @@ +#!/usr/bin/env sh + +# Description: Regular mode: +# Fuzzy find a file in directory subtree. +# Opens in $VISUAL or $EDITOR if text. +# Opens other type of files with xdg-open. +# Work only with a single file selected. +# +# Picker mode: +# If picker mode output file is passed, it +# will be overwritten with any picked files. +# Leaves untouched if no file is picked. +# Works with single/multiple files selected. +# +# Dependencies: fd/find, fzf/skim, xdg-open/open (on macOS) +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +NUKE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/nuke" +USE_NUKE=0 + +# shellcheck disable=SC1090,SC1091 +. "$(dirname "$0")"/.nnn-plugin-helper + +if type fzf >/dev/null 2>&1; then + cmd="$FZF_DEFAULT_COMMAND" + if type fd >/dev/null 2>&1; then + [ -z "$cmd" ] && cmd="fd -t f 2>/dev/null" + else + [ -z "$cmd" ] && cmd="find . -type f 2>/dev/null" + fi + entry="$(eval "$cmd" | fzf -m)" + # To show only the file name + # entry=$(find . -type f 2>/dev/null | fzf --delimiter / --with-nth=-1 --tiebreak=begin --info=hidden) +elif type sk >/dev/null 2>&1; then + entry=$(find . -type f 2>/dev/null | sk) +else + exit 1 +fi + +# Check for picker mode +if [ "$3" ]; then + if [ "$entry" ]; then + case "$entry" in + /*) fullpath="$entry" ;; + *) fullpath="$PWD/$entry" ;; + esac + if [ "-" = "$3" ]; then + printf "%s\n" "$fullpath" + else + printf "%s\n" "$fullpath" > "$3" + fi + + # Tell `nnn` to clear its internal selection + printf "%s" "0p" > "$NNN_PIPE" + fi + + exit 0 +fi + +if [ "$USE_NUKE" -ne 0 ]; then + "$NUKE" "$entry" + exit 0 +fi + +# Open the file (works for a single file only) +cmd_file="" +cmd_open="" +if uname | grep -q "Darwin"; then + cmd_file="file -bIL" + cmd_open="open" +else + cmd_file="file -biL" + cmd_open="xdg-open" +fi + +case "$($cmd_file "$entry")" in + *text*) + "${VISUAL:-$EDITOR}" "$entry" ;; + *) + $cmd_open "$entry" >/dev/null 2>&1 ;; +esac diff --git a/.local/share/nnn/plugins/fzplug b/.local/share/nnn/plugins/fzplug new file mode 100755 index 0000000..11dcf7f --- /dev/null +++ b/.local/share/nnn/plugins/fzplug @@ -0,0 +1,59 @@ +#!/usr/bin/env sh + +# Description: Fuzzy find and execute nnn plugins (and optionally, +# custom scripts located elsewhere). +# Description and details of plugins can be previewed +# from the fzf interface. Use `?` to toggle preview +# pane on and off, ^Up/^Dn to scroll. +# +# Dependencies: find, fzf, cat (or bat, if installed) +# +# Note: For better compatibility with as many nnn plugins as possible, +# fzplug will first execute the chosen script on the file hovered +# in nnn, and upon failure, try to run it with no target (i.e on +# an active selection, if present). +# +# Shell: POSIX compliant +# Author: Kabouik + +# Optional scripts sources + +# Leave blank or fill with the absolute path of a folder containing executable +# scripts other than nnn plugins (e.g., "$HOME/.local/share/nautilus/scripts", +# since there are numerous Nautilus script git repositories). +# Add extra variables if needed, make sure you call them in the find command. + +#CUSTOMDIR1="$HOME/.local/share/nautilus/scripts" +CUSTOMDIR1="" +CUSTOMDIR2="" + +nnnpluginsdir="$HOME/.config/nnn/plugins" + +# Preview with bat if installed +if type bat >/dev/null; then + BAT="bat --terminal-width='$(tput cols)' --decorations=always --color=always --style='${BAT_STYLE:-header,numbers}'" +fi + +plugin=$(find "$nnnpluginsdir" "$CUSTOMDIR1" "$CUSTOMDIR2" \ +-maxdepth 3 -perm -111 -type f 2>/dev/null | fzf --ansi --preview \ + "${BAT:-cat} {}" --preview-window="right:66%:wrap" --delimiter / \ + --with-nth -1 --bind="?:toggle-preview") + +# Try running the script on the hovered file, and abort +# abort if no plugin was selected (ESC or ^C pressed). +err=0 +if ! [ "$plugin" = "" ]; then + "$plugin" "$1" || err=1 +fi + +# If attempt with hovered file fails, try without any target +# (nnn selections should still be passed to the script in that case) +if [ "$err" -eq "1" ]; then + clear && "$plugin" || err=2 +fi + +# Abort and show error if both fail +if [ "$err" -eq "2" ]; then + sep="\n---\n" + printf "$sep""Failed to execute '%s'. See error above or try without fzfplug. Press return to continue. " "$plugin" && read -r _ && clear +fi diff --git a/.local/share/nnn/plugins/getplugs b/.local/share/nnn/plugins/getplugs new file mode 100755 index 0000000..361a605 --- /dev/null +++ b/.local/share/nnn/plugins/getplugs @@ -0,0 +1,70 @@ +#!/usr/bin/env sh + +# Description: Update nnn plugins to installed nnn version +# +# Shell: POSIX compliant +# Authors: Arun Prakash Jana, KlzXS + +CONFIG_DIR=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/ +PLUGIN_DIR=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins + +merge () { + if type nvim >/dev/null 2>&1; then + nvim -d "$1" "$2" + else + vimdiff +0 "$1" "$2" + fi +} + +prompt () { + printf "%s\n" "Plugin $1 already exists and is different." + printf "Keep (k), merge (m), overwrite (o) [default: k]? " + read -r operation + + if [ "$operation" = "m" ]; then + op="merge" + elif [ "$operation" = "o" ]; then + op="cp -vRf" + else + op="true" + fi +} + +if [ "$1" = "master" ] ; then + VER="master" + ARCHIVE_URL=https://github.com/jarun/nnn/archive/master.tar.gz +elif type nnn >/dev/null 2>&1; then + VER=$(nnn -V) + ARCHIVE_URL=https://github.com/jarun/nnn/releases/download/v"$VER"/nnn-v"$VER".tar.gz +else + echo "nnn is not installed" + exit 1 +fi + +# backup any earlier plugins +if [ -d "$PLUGIN_DIR" ]; then + tar -C "$CONFIG_DIR" -czf "$CONFIG_DIR""plugins-$(date '+%Y%m%d%H%M').tar.gz" plugins/ +fi + +mkdir -p "$PLUGIN_DIR" +cd "$CONFIG_DIR" || exit 1 +curl -Ls "$ARCHIVE_URL" -o nnn-"$VER".tar.gz +tar -zxf nnn-"$VER".tar.gz + +cd nnn-"$VER"/plugins || exit 1 + +# shellcheck disable=SC2044 +# We do not use obnoxious names for plugins +for f in $(find . -maxdepth 1 \( ! -iname "." ! -iname "*.md" \)); do + if [ -f ../../plugins/"$f" ]; then + if [ "$(diff --brief "$f" ../../plugins/"$f")" ]; then + prompt "$f" + $op "$f" ../../plugins/ + fi + else + cp -vRf "$f" ../../plugins/ + fi +done +cd ../.. || exit 1 + +rm -rf nnn-"$VER"/ nnn-"$VER".tar.gz diff --git a/.local/share/nnn/plugins/gitroot b/.local/share/nnn/plugins/gitroot new file mode 100755 index 0000000..4428d1e --- /dev/null +++ b/.local/share/nnn/plugins/gitroot @@ -0,0 +1,15 @@ +#!/usr/bin/env sh + +# Description: cd to the top level of the current git repository in the current context +# Dependencies: git +# Shell: sh +# Author: https://github.com/PatrickF1 + +root="$(git rev-parse --show-toplevel 2>/dev/null)" +if [ -n "$root" ]; then + printf "%s" "0c$root" > "$NNN_PIPE" +else + printf "Not in a git repository" + read -r _ + exit 1 +fi diff --git a/.local/share/nnn/plugins/gpgd b/.local/share/nnn/plugins/gpgd new file mode 100755 index 0000000..44d5c0f --- /dev/null +++ b/.local/share/nnn/plugins/gpgd @@ -0,0 +1,28 @@ +#!/usr/bin/env sh + +# Description: Decrypts selected files using gpg. The contents of the +# decrypted file are stored in a file with extension .dec +# +# Note: If an appropriate private key cannot be found gpg silently +# prints a message in the background and no files are written. +# +# Shell: POSIX compliant +# Author: KlzXS + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +printf "(s)election/(c)urrent? [default=c] " +read -r resp + +if [ "$resp" = "s" ]; then + files=$(tr '\0' '\n' < "$selection") +else + files=$1 +fi + +printf "%s" "$files" | xargs -n1 -I{} gpg --decrypt --output "{}.dec" {} + +# Clear selection +if [ "$resp" = "s" ] && [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" +fi diff --git a/.local/share/nnn/plugins/gpge b/.local/share/nnn/plugins/gpge new file mode 100755 index 0000000..69016a9 --- /dev/null +++ b/.local/share/nnn/plugins/gpge @@ -0,0 +1,44 @@ +#!/usr/bin/env sh + +# Description: Encrypts selected files using gpg. Can encrypt +# asymmetrically (key) or symmetrically (passphrase). +# If asymmetric encryption is chosen a key can be +# chosen from the list of capable public keys using fzf. +# +# Note: Symmetric encryption only works for a single (current) file as per gpg limitations +# +# Shell: POSIX compliant +# Author: KlzXS + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +printf "(s)ymmetric, (a)symmetric? [default=a] " +read -r symmetry + +if [ "$symmetry" = "s" ]; then + gpg --symmetric "$1" +else + printf "(s)election/(c)urrent? [default=c] " + read -r resp + + if [ "$resp" = "s" ]; then + files=$(tr '\0' '\n' < "$selection") + else + files=$1 + fi + + keyids=$(gpg --list-public-keys --with-colons | grep -E "pub:(.*:){10}.*[eE].*:" | awk -F ":" '{print $5}') + + #awk needs literal $10 + #shellcheck disable=SC2016 + keyuids=$(printf "%s" "$keyids" | xargs -n1 -I{} sh -c 'gpg --list-key --with-colons "{}" | grep "uid" | awk -F ":" '\''{printf "%s %s\n", "{}", $10}'\''') + + recipient=$(printf "%s" "$keyuids" | fzf | awk '{print $1}') + + printf "%s" "$files" | xargs -n1 gpg --encrypt --recipient "$recipient" + + # Clear selection + if [ "$resp" = "s" ] && [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" + fi +fi diff --git a/.local/share/nnn/plugins/gsconnect b/.local/share/nnn/plugins/gsconnect new file mode 100755 index 0000000..f45f3d3 --- /dev/null +++ b/.local/share/nnn/plugins/gsconnect @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +#set -x +# Description: Send the selected (or hovered) files to your Android device using gsconnect daemon.js. +# GSConnect must be configured on the Android device and the PC. +# +# Shell: POSIX compliant +# Author: Darukutsu +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +gsconnect=$HOME/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/daemon.js +ids=$($gsconnect -l) + +for id in $ids; do + if [ -s "$selection" ]; then + xargs -0 < "$selection" -I{} "$gsconnect" -d "$id" --share-file="{}" + # Clear selection + printf "-" > "$NNN_PIPE" + else + "$gsconnect" -d "$id" --share-file="$2/$1" + fi +done diff --git a/.local/share/nnn/plugins/gutenread b/.local/share/nnn/plugins/gutenread new file mode 100755 index 0000000..036ff35 --- /dev/null +++ b/.local/share/nnn/plugins/gutenread @@ -0,0 +1,49 @@ +#!/usr/bin/env sh + +# Description: Browse Project Gutenberg catalogue by popularity, then download +# and read a book of your choice. +# +# Details: Set the variable EBOOK_ID to download in html format and read in w3m. +# Clear EBOOK_ID to browse available ebooks by popularity and set it to +# the ID once you find an interesting one. +# To download and read in epub format set READER to an epub reader like +# epr: https://github.com/wustho/epr +# +# More on EBOOK_ID: +# Wuthering Heights by Emily Brontë is at https://www.gutenberg.org/ebooks/768 +# So EBOOK_ID would be 768 +# +# Downloaded ebooks are at ${XDG_CACHE_HOME:-$HOME/.cache}/nnn/gutenbooks/ +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +EBOOK_ID="${EBOOK_ID:-""}" +DIR="${XDG_CACHE_HOME:-$HOME/.cache}/nnn/gutenbooks/$EBOOK_ID" +BROWSE_LINK="https://www.gutenberg.org/ebooks/search/?sort_order=downloads" +BROWSER="${BROWSER:-w3m}" +READER="${READER:-""}" + +if [ -n "$EBOOK_ID" ]; then + if [ ! -e "$DIR" ]; then + mkdir -p "$DIR" + cd "$DIR" || exit 1 + + if [ -z "$READER" ]; then + curl -L -O "https://www.gutenberg.org/files/$EBOOK_ID/$EBOOK_ID-h.zip" + unzip "$EBOOK_ID"-h.zip + else + curl -L -o "$EBOOK_ID".epub "https://www.gutenberg.org/ebooks/$EBOOK_ID.epub.noimages" + fi + fi + + if [ -d "$DIR" ]; then + if [ -z "$READER" ]; then + "$BROWSER" "$DIR/$EBOOK_ID-h/$EBOOK_ID-h.htm" + else + "$READER" "$DIR/$EBOOK_ID.epub" + fi + fi +else + "$BROWSER" "$BROWSE_LINK" +fi diff --git a/.local/share/nnn/plugins/imgresize b/.local/share/nnn/plugins/imgresize new file mode 100755 index 0000000..351fe71 --- /dev/null +++ b/.local/share/nnn/plugins/imgresize @@ -0,0 +1,31 @@ +#!/usr/bin/env sh + +# Description: Resize images in a directory to screen resolution with imgp +# +# Dependencipes: imgp - https://github.com/jarun/imgp +# +# Notes: +# 1. Set res to avoid the desktop resolution prompt each time +# 2. MINSIZE is set to 1MB by default, adjust it if you want +# 3. imgp options used: +# a - adaptive mode +# c - convert PNG to JPG +# k - skip images matching specified hres/vres +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +# set resolution (e.g. 1920x1080) +res="${RESOLUTION}" + +# set minimum image size (in bytes) to resize (default: 1MB) +MINSIZE="${MINSIZE:-1048576}" + +if [ -z "$res" ]; then + printf "desktop resolution (hxv): " + read -r res +fi + +if [ -n "$res" ] && [ -n "$MINSIZE" ]; then + imgp -ackx "$res" -s "$MINSIZE" +fi diff --git a/.local/share/nnn/plugins/imgur b/.local/share/nnn/plugins/imgur new file mode 100755 index 0000000..16d21bc --- /dev/null +++ b/.local/share/nnn/plugins/imgur @@ -0,0 +1,597 @@ +#!/usr/bin/env bash + +########################################################################## +# The MIT License +# +# Copyright (c) jomo +# +# Permission is hereby granted, free of charge, +# to any person obtaining a copy of this software and +# associated documentation files (the "Software"), to +# deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, +# merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom +# the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice +# shall be included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +########################################################################## + +# https://github.com/jomo/imgur-screenshot +# https://help.imgur.com/hc/en-us/articles/209592766-Tools-for-Imgur +# +# Slightly modified for `nnn` integration +# +# Shell: Bash +# Description: Upload an image file to imgur + +if [ "${1}" = "--debug" ]; then + echo "########################################" + echo "Enabling debug mode" + echo "Please remove credentials before pasting" + echo "########################################" + echo "" + uname -a + for arg in ${0} "${@}"; do + echo -n "'${arg}' " + done + echo -e "\n" + shift + set -x +fi + +current_version="v1.7.4" + +function is_mac() { + uname | grep -q "Darwin" +} + +### IMGUR-SCREENSHOT DEFAULT CONFIG #### + +# You can override the config in ~/.config/imgur-screenshot/settings.conf + +imgur_anon_id="ea6c0ef2987808e" +imgur_icon_path="${HOME}/Pictures/imgur.png" + +imgur_acct_key="" +imgur_secret="" +login="false" +album_title="" +album_id="" +credentials_file="${HOME}/.config/imgur-screenshot/credentials.conf" + +file_name_format="imgur-%Y_%m_%d-%H:%M:%S.png" # when using scrot, must end with .png! +file_dir="${HOME}/Pictures" + +upload_connect_timeout="5" +upload_timeout="120" +upload_retries="1" + +# shellcheck disable=SC2034 +if is_mac; then + screenshot_select_command="screencapture -i %img" + screenshot_window_command="screencapture -iWa %img" + screenshot_full_command="screencapture %img" + open_command="open %url" +else + screenshot_select_command="scrot -s %img" + screenshot_window_command="scrot %img" + screenshot_full_command="scrot %img" + open_command="xdg-open %url" +fi +open="true" + +mode="select" +edit_command="gimp %img" +edit="false" +exit_on_album_creation_fail="true" + +log_file="${HOME}/.imgur-screenshot.log" + +auto_delete="" +copy_url="true" +keep_file="true" +check_update="true" + +# NOTICE: if you make changes here, also edit the docs at +# https://github.com/jomo/imgur-screenshot/wiki/Config + +# You can override the config in ~/.config/imgur-screenshot/settings.conf + +############## END CONFIG ############## + +settings_path="${HOME}/.config/imgur-screenshot/settings.conf" +if [ -f "${settings_path}" ]; then + # shellcheck disable=SC1090 + source "${settings_path}" +fi + +# dependency check +if [ "${1}" = "--check" ]; then + (type grep &>/dev/null && echo "OK: found grep") || echo "ERROR: grep not found" + if is_mac; then + if type growlnotify &>/dev/null; then + echo "OK: found growlnotify" + elif type terminal-notifier &>/dev/null; then + echo "OK: found terminal-notifier" + else + echo "ERROR: growlnotify nor terminal-notifier found" + fi + (type screencapture &>/dev/null && echo "OK: found screencapture") || echo "ERROR: screencapture not found" + (type pbcopy &>/dev/null && echo "OK: found pbcopy") || echo "ERROR: pbcopy not found" + else + (type notify-send &>/dev/null && echo "OK: found notify-send") || echo "ERROR: notify-send (from libnotify-bin) not found" + (type scrot &>/dev/null && echo "OK: found scrot") || echo "ERROR: scrot not found" + (type xclip &>/dev/null && echo "OK: found xclip") || echo "ERROR: xclip not found" + fi + (type curl &>/dev/null && echo "OK: found curl") || echo "ERROR: curl not found" + exit 0 +fi + + +# notify <'ok'|'error'> <text> +function notify() { + if is_mac; then + if type growlnotify &>/dev/null; then + growlnotify --icon "${imgur_icon_path}" --iconpath "${imgur_icon_path}" --title "${2}" --message "${3}" + else + terminal-notifier -appIcon "${imgur_icon_path}" -contentImage "${imgur_icon_path}" -title "imgur: ${2}" -message "${3}" + fi + else + if [ "${1}" = "error" ]; then + notify-send -a ImgurScreenshot -u critical -c "im.error" -i "${imgur_icon_path}" -t 500 "imgur: ${2}" "${3}" + else + notify-send -a ImgurScreenshot -u low -c "transfer.complete" -i "${imgur_icon_path}" -t 500 "imgur: ${2}" "${3}" + fi + fi +} + +function take_screenshot() { + echo "Please select area" + is_mac || sleep 0.1 # https://bbs.archlinux.org/viewtopic.php?pid=1246173#p1246173 + + cmd="screenshot_${mode}_command" + cmd=${!cmd//\%img/${1}} + + if ! shot_err="$(${cmd} &>/dev/null)"; then #takes a screenshot with selection + echo "Failed to take screenshot '${1}': '${shot_err}'. For more information visit https://github.com/jomo/imgur-screenshot/wiki/Troubleshooting" | tee -a "${log_file}" + notify error "Something went wrong :(" "Information has been logged" + exit 1 + fi +} + +function check_for_update() { + # exit non-zero on HTTP error, output only the body (no stats) but output errors, follow redirects, output everything to stdout + remote_version="$(curl --compressed -fsSL --stderr - "https://api.github.com/repos/jomo/imgur-screenshot/releases" | grep -Em 1 --color 'tag_name":\s*".*"' | cut -d '"' -f 4)" + if [ -n "$remote_version" ]; then + if [ ! "${current_version}" = "${remote_version}" ] && [ -n "${current_version}" ] && [ -n "${remote_version}" ]; then + echo "Update found!" + echo "Version ${remote_version} is available (You have ${current_version})" + notify ok "Update found" "Version ${remote_version} is available (You have ${current_version}). https://github.com/jomo/imgur-screenshot" + echo "Check https://github.com/jomo/imgur-screenshot/releases/${remote_version} for more info." + elif [ -z "${current_version}" ] || [ -z "${remote_version}" ]; then + echo "Invalid empty version string" + echo "Current (local) version: '${current_version}'" + echo "Latest (remote) version: '${remote_version}'" + else + echo "Version ${current_version} is up to date." + fi + else + echo "Failed to check for latest version: ${remote_version}" + fi +} + +function check_oauth2_client_secrets() { + if [ -z "${imgur_acct_key}" ] || [ -z "${imgur_secret}" ]; then + echo "In order to upload to your account, register a new application at:" + echo "https://api.imgur.com/oauth2/addclient" + echo "Select 'OAuth 2 authorization without a callback URL'" + echo "Then, set the imgur_acct_key (Client ID) and imgur_secret in your config." + exit 1 + fi +} + +function load_access_token() { + token_expire_time=0 + # check for saved access_token and its expiration date + if [ -f "${credentials_file}" ]; then + # shellcheck disable=SC1090 + source "${credentials_file}" + fi + current_time="$(date +%s)" + preemptive_refresh_time="$((10*60))" + expired="$((current_time > (token_expire_time - preemptive_refresh_time)))" + if [ -n "${refresh_token}" ]; then + # token already set + if [ "${expired}" -eq "0" ]; then + # token expired + refresh_access_token "${credentials_file}" + fi + else + acquire_access_token "${credentials_file}" + fi +} + +function acquire_access_token() { + check_oauth2_client_secrets + # prompt for a PIN + authorize_url="https://api.imgur.com/oauth2/authorize?client_id=${imgur_acct_key}&response_type=pin" + echo "Go to" + echo "${authorize_url}" + echo "and grant access to this application." + read -rp "Enter the PIN: " imgur_pin + + if [ -z "${imgur_pin}" ]; then + echo "PIN not entered, exiting" + exit 1 + fi + + # exchange the PIN for access token and refresh token + response="$(curl --compressed -fsSL --stderr - \ + -F "client_id=${imgur_acct_key}" \ + -F "client_secret=${imgur_secret}" \ + -F "grant_type=pin" \ + -F "pin=${imgur_pin}" \ + https://api.imgur.com/oauth2/token)" + save_access_token "${response}" "${1}" +} + +function refresh_access_token() { + check_oauth2_client_secrets + token_url="https://api.imgur.com/oauth2/token" + # exchange the refresh token for access_token and refresh_token + if ! response="$(curl --compressed -fsSL --stderr - \ + -F "client_id=${imgur_acct_key}" \ + -F "client_secret=${imgur_secret}" \ + -F "grant_type=refresh_token" \ + -F "refresh_token=${refresh_token}" \ + "${token_url}" + )"; then + # curl failed + handle_upload_error "${response}" "${token_url}" + exit 1 + fi + save_access_token "${response}" "${1}" +} + +function save_access_token() { + if ! grep -q "access_token" <<<"${1}"; then + # server did not send access_token + echo "Error: Something is wrong with your credentials:" + echo "${1}" + exit 1 + fi + + access_token="$(grep -Eo 'access_token":".*"' <<<"${1}" | cut -d '"' -f 3)" + refresh_token="$(grep -Eo 'refresh_token":".*"' <<<"${1}" | cut -d '"' -f 3)" + expires_in="$(grep -Eo 'expires_in":[0-9]*' <<<"${1}" | cut -d ':' -f 2)" + token_expire_time="$(( $(date +%s) + expires_in ))" + + # create dir if not exist + mkdir -p "$(dirname "${2}")" 2>/dev/null + touch "${2}" && chmod 600 "${2}" + cat <<EOF > "${2}" +access_token="${access_token}" +refresh_token="${refresh_token}" +token_expire_time="${token_expire_time}" +EOF +} + +function fetch_account_info() { + response="$(curl --compressed --connect-timeout "${upload_connect_timeout}" -m "${upload_timeout}" --retry "${upload_retries}" -fsSL --stderr - -H "Authorization: Bearer ${access_token}" https://api.imgur.com/3/account/me)" + if grep -Eq '"success":\s*true' <<<"${response}"; then + username="$(grep -Eo '"url":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + echo "Logged in as ${username}." + echo "https://${username}.imgur.com" + else + echo "Failed to fetch info: ${response}" + fi +} + +function delete_image() { + response="$(curl --compressed -X DELETE -fsSL --stderr - -H "Authorization: Client-ID ${1}" "https://api.imgur.com/3/image/${2}")" + if grep -Eq '"success":\s*true' <<<"${response}"; then + echo "Image successfully deleted (delete hash: ${2})." >> "${3}" + else + echo "The Image could not be deleted: ${response}." >> "${3}" + fi +} + +function upload_authenticated_image() { + echo "Uploading '${1}'..." + title="$(echo "${1}" | rev | cut -d "/" -f 1 | cut -d "." -f 2- | rev)" + if [ -n "${album_id}" ]; then + response="$(curl --compressed --connect-timeout "${upload_connect_timeout}" -m "${upload_timeout}" --retry "${upload_retries}" -fsSL --stderr - -F "title=${title}" -F "image=@\"${1}\"" -F "album=${album_id}" -H "Authorization: Bearer ${access_token}" https://api.imgur.com/3/image)" + else + response="$(curl --compressed --connect-timeout "${upload_connect_timeout}" -m "${upload_timeout}" --retry "${upload_retries}" -fsSL --stderr - -F "title=${title}" -F "image=@\"${1}\"" -H "Authorization: Bearer ${access_token}" https://api.imgur.com/3/image)" + fi + + # JSON parser premium edition (not really) + if grep -Eq '"success":\s*true' <<<"${response}"; then + img_id="$(grep -Eo '"id":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + img_ext="$(grep -Eo '"link":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4 | rev | cut -d "." -f 1 | rev)" # "link" itself has ugly '\/' escaping and no https! + del_id="$(grep -Eo '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + + if [ -n "${auto_delete}" ]; then + export -f delete_image + echo "Deleting image in ${auto_delete} seconds." + nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" & + fi + + handle_upload_success "https://i.imgur.com/${img_id}.${img_ext}" "https://imgur.com/delete/${del_id}" "${1}" + else # upload failed + err_msg="$(grep -Eo '"error":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + test -z "${err_msg}" && err_msg="${response}" + handle_upload_error "${err_msg}" "${1}" + fi +} + +function upload_anonymous_image() { + echo "Uploading '${1}'..." + title="$(echo "${1}" | rev | cut -d "/" -f 1 | cut -d "." -f 2- | rev)" + if [ -n "${album_id}" ]; then + response="$(curl --compressed --connect-timeout "${upload_connect_timeout}" -m "${upload_timeout}" --retry "${upload_retries}" -fsSL --stderr - -H "Authorization: Client-ID ${imgur_anon_id}" -F "title=${title}" -F "image=@\"${1}\"" -F "album=${album_id}" https://api.imgur.com/3/image)" + else + response="$(curl --compressed --connect-timeout "${upload_connect_timeout}" -m "${upload_timeout}" --retry "${upload_retries}" -fsSL --stderr - -H "Authorization: Client-ID ${imgur_anon_id}" -F "title=${title}" -F "image=@\"${1}\"" https://api.imgur.com/3/image)" + fi + # JSON parser premium edition (not really) + if grep -Eq '"success":\s*true' <<<"${response}"; then + img_id="$(grep -Eo '"id":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + img_ext="$(grep -Eo '"link":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4 | rev | cut -d "." -f 1 | rev)" # "link" itself has ugly '\/' escaping and no https! + del_id="$(grep -Eo '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + + if [ -n "${auto_delete}" ]; then + export -f delete_image + echo "Deleting image in ${auto_delete} seconds." + nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" & + fi + + handle_upload_success "https://i.imgur.com/${img_id}.${img_ext}" "https://imgur.com/delete/${del_id}" "${1}" + else # upload failed + err_msg="$(grep -Eo '"error":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + test -z "${err_msg}" && err_msg="${response}" + handle_upload_error "${err_msg}" "${1}" + fi +} + +function handle_upload_success() { + echo "" + echo "image link: ${1}" + echo "delete link: ${2}" + + if [ "${copy_url}" = "true" ] && [ -z "${album_title}" ]; then + if is_mac; then + echo -n "${1}" | pbcopy + else + echo -n "${1}" | xclip -selection clipboard + fi + echo "URL copied to clipboard" + fi + + # print to log file: image link, image location, delete link + echo -e "${1}\t${3}\t${2}" >> "${log_file}" + + notify ok "Upload done!" "${1}" + +# if [ ! -z "${open_command}" ] && [ "${open}" = "true" ]; then +# open_cmd=${open_command//\%url/${1}} +# open_cmd=${open_cmd//\%img/${2}} +# echo "Opening '${open_cmd}'" +# eval "${open_cmd}" +# fi +} + +function handle_upload_error() { + error="Upload failed: \"${1}\"" + echo "${error}" + echo -e "Error\t${2}\t${error}" >> "${log_file}" + notify error "Upload failed :(" "${1}" +} + +function handle_album_creation_success() { + echo "" + echo "Album link: ${1}" + echo "Delete hash: ${2}" + echo "" + + notify ok "Album created!" "${1}" + + if [ "${copy_url}" = "true" ]; then + if is_mac; then + echo -n "${1}" | pbcopy + else + echo -n "${1}" | xclip -selection clipboard + fi + echo "URL copied to clipboard" + fi + + # print to log file: album link, album title, delete hash + echo -e "${1}\t\"${3}\"\t${2}" >> "${log_file}" +} + +function handle_album_creation_error() { + error="Album creation failed: \"${1}\"" + echo -e "Error\t${2}\t${error}" >> "${log_file}" + notify error "Album creation failed :(" "${1}" + if [ ${exit_on_album_creation_fail} ]; then + exit 1 + fi +} + +while [ ${#} != 0 ]; do + case "${1}" in + -h | --help) + echo "usage: ${0} [--debug] [-c | --check | -v | -h | -u]" + echo " ${0} [--debug] [option]... [file]..." + echo "" + echo " --debug Enable debugging, must be first option" + echo " -h, --help Show this help, exit" + echo " -v, --version Show current version, exit" + echo " --check Check if all dependencies are installed, exit" + echo " -c, --connect Show connected imgur account, exit" + echo " -o, --open <true|false> Override 'open' config" + echo " -e, --edit <true|false> Override 'edit' config" + echo " -i, --edit-command <command> Override 'edit_command' config (include '%img'), sets --edit 'true'" + echo " -l, --login <true|false> Override 'login' config" + echo " -a, --album <album_title> Create new album and upload there" + echo " -A, --album-id <album_id> Override 'album_id' config" + echo " -k, --keep-file <true|false> Override 'keep_file' config" + echo " -d, --auto-delete <s> Automatically delete image after <s> seconds" + echo " -u, --update Check for updates, exit" + echo " file Upload file instead of taking a screenshot" + exit 0;; + -v | --version) + echo "${current_version}" + exit 0;; + -s | --select) + mode="select" + shift;; + -w | --window) + mode="window" + shift;; + -f | --full) + mode="full" + shift;; + -o | --open) + # shellcheck disable=SC2034 + open="${2}" + shift 2;; + -e | --edit) + edit="${2}" + shift 2;; + -i | --edit-command) + edit_command="${2}" + edit="true" + shift 2;; + -l | --login) + login="${2}" + shift 2;; + -c | --connect) + load_access_token + fetch_account_info + exit 0;; + -a | --album) + album_title="${2}" + shift 2;; + -A | --album-id) + album_id="${2}" + shift 2;; + -k | --keep-file) + keep_file="${2}" + shift 2;; + -d | --auto-delete) + auto_delete="${2}" + shift 2;; + -u | --update) + check_for_update + exit 0;; + *) + upload_files=("${@}") + break;; + esac +done + +if [ "${login}" = "true" ]; then + # load before changing directory + load_access_token +fi + + +if [ -n "${album_title}" ]; then + if [ "${login}" = "true" ]; then + response="$(curl -fsSL --stderr - \ + -F "title=${album_title}" \ + -H "Authorization: Bearer ${access_token}" \ + https://api.imgur.com/3/album)" + else + response="$(curl -fsSL --stderr - \ + -F "title=${album_title}" \ + -H "Authorization: Client-ID ${imgur_anon_id}" \ + https://api.imgur.com/3/album)" + fi + if grep -Eq '"success":\s*true' <<<"${response}"; then # Album creation successful + echo "Album '${album_title}' successfully created" + album_id="$(grep -Eo '"id":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + del_id="$(grep -Eo '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + handle_album_creation_success "https://imgur.com/a/${album_id}" "${del_id}" "${album_title}" + + if [ "${login}" = "false" ]; then + album_id="${del_id}" + fi + else # Album creation failed + err_msg="$(grep -Eo '"error":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" + test -z "${err_msg}" && err_msg="${response}" + handle_album_creation_error "${err_msg}" "${album_title}" + fi +fi + +if [ -z "${upload_files[*]}" ]; then + upload_files[0]="" +fi + +for upload_file in "${upload_files[@]}"; do + + if [ -z "${upload_file}" ]; then + cd "${file_dir}" || exit 1 + + # new filename with date + img_file="$(date +"${file_name_format}")" + take_screenshot "${img_file}" + else + # upload file instead of screenshot + img_file="${upload_file}" + fi + + # get full path + #cd "$(dirname "$(realpath "${img_file}")")" + #img_file="$(realpath "${img_file}")" + + # check if file exists + if ! [ -f "${img_file}" ]; then + echo "file '${img_file}' doesn't exist !" + read -r _ + exit 1 + fi + + # open image in editor if configured + if [ "${edit}" = "true" ]; then + edit_cmd=${edit_command//\%img/${img_file}} + echo "Opening editor '${edit_cmd}'" + if ! (eval "${edit_cmd}"); then + echo "Error for image '${img_file}': command '${edit_cmd}' failed, not uploading. For more information visit https://github.com/jomo/imgur-screenshot/wiki/Troubleshooting" | tee -a "${log_file}" + notify error "Something went wrong :(" "Information has been logged" + exit 1 + fi + fi + + if [ "${login}" = "true" ]; then + upload_authenticated_image "${img_file}" + else + upload_anonymous_image "${img_file}" + fi + + # delete file if configured + if [ "${keep_file}" = "false" ] && [ -z "${1}" ]; then + echo "Deleting temp file ${file_dir}/${img_file}" + rm -rf "${img_file}" + fi + + echo "" +done + + +if [ "${check_update}" = "true" ]; then + check_for_update +fi + +read -r _ diff --git a/.local/share/nnn/plugins/imgview b/.local/share/nnn/plugins/imgview new file mode 100755 index 0000000..d8cc247 --- /dev/null +++ b/.local/share/nnn/plugins/imgview @@ -0,0 +1,113 @@ +#!/usr/bin/env sh + +# Description: Open hovered or current directory in image viewer. +# Generates media thumbnails with optional dependencies. +# +# Dependencies: +# - imv (https://github.com/eXeC64/imv) or, +# - sxiv (https://github.com/muennich/sxiv) or, +# - nsxiv (https://codeberg.org/nsxiv/nsxiv) or, +# - ucollage (https://github.com/ckardaris/ucollage) or, +# - lsix (https://github.com/hackerb9/lsix), or +# - viu (https://github.com/atanunq/viu), or +# - catimg (https://github.com/posva/catimg), or +# - optional: ffmpeg for audio thumbnails (album art) +# - optional: ffmpegthumbnailer for video thumbnails +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana, Luuk van Baal +# +# Consider setting NNN_PREVIEWDIR to $XDG_CACHE_HOME/nnn/previews +# if you want to keep media thumbnails on disk between reboots. +NNN_PREVIEWDIR="${NNN_PREVIEWDIR:-${TMPDIR:-/tmp}/nnn/previews}" + +exit_prompt() { + [ -n "$1" ] && printf "%s\n" "$1" + printf "%s" "Press any key to exit..." + cfg=$(stty -g); stty raw -echo; head -c 1; stty "$cfg" + clear + exit +} + +make_thumbs() { + mkdir -p "$NNN_PREVIEWDIR$dir" || return + if [ "$1" = "viu" ] || [ "$1" = "catimg" ]; then + [ -d "$target" ] && exit_prompt "$1 can only display a single image" + mime="$(file -bL --mime-type -- "$target")" + case "$mime" in + audio/*) ffmpeg -i "$target" "$NNN_PREVIEWDIR$target.jpg" -y >/dev/null 2>&1 + ret="$NNN_PREVIEWDIR/$target.jpg" ;; + video/*) ffmpegthumbnailer -i "$target" -o "$NNN_PREVIEWDIR$target.jpg" 2> /dev/null + ret="$NNN_PREVIEWDIR/$target.jpg" ;; + *) ret="$target" ;; + esac + fi + for file in "$dir"/*; do + if [ ! -f "$NNN_PREVIEWDIR$file.jpg" ]; then + case "$(file -bL --mime-type -- "$file")" in + audio/*) [ "$1" != "sxiv" ] && + ffmpeg -i "$file" "$NNN_PREVIEWDIR$file.jpg" -y >/dev/null 2>&1 ;; + video/*) [ "$1" != "ucollage" ] && + ffmpegthumbnailer -i "$file" -o "$NNN_PREVIEWDIR$file.jpg" 2> /dev/null ;; + esac + fi + done + for file in "$NNN_PREVIEWDIR$dir"/*; do + filename="$(basename "$file" .jpg)" + [ ! -e "$dir/$filename" ] && rm "$file" 2>/dev/null + done +} + +listimages() { + find -L "$dir" "$NNN_PREVIEWDIR$dir" -maxdepth 1 -type f -print0 2>/dev/null | sort -z +} + +view_files() { + [ -f "$target" ] && count="-n $(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)" + case "$1" in + nsxiv) listimages | xargs -0 nsxiv -a "${count:--t}" -- ;; + sxiv) listimages | xargs -0 sxiv -a "${count:--t}" -- ;; + imv*) listimages | xargs -0 "$1" "${count:-}" -- ;; + esac +} + +target="$(readlink -f "$1")" +[ -d "$target" ] && dir="$target" || dir="${target%/*}" +if uname | grep -q "Darwin"; then + [ -f "$1" ] && open "$1" >/dev/null 2>&1 & +elif type lsix >/dev/null 2>&1; then + if [ -d "$target" ]; then + cd "$target" || exit_prompt + fi + make_thumbs lsix + clear + lsix + cd "$NNN_PREVIEWDIR$dir" && lsix + exit_prompt +elif type ucollage >/dev/null 2>&1; then + type ffmpeg >/dev/null 2>&1 && make_thumbs ucollage + UCOLLAGE_EXPAND_DIRS=1 ucollage "$dir" "$NNN_PREVIEWDIR$dir" || exit_prompt +elif type sxiv >/dev/null 2>&1; then + type ffmpegthumbnailer >/dev/null 2>&1 && make_thumbs sxiv + view_files sxiv >/dev/null 2>&1 & +elif type nsxiv >/dev/null 2>&1; then + type ffmpegthumbnailer >/dev/null 2>&1 && make_thumbs sxiv + view_files nsxiv >/dev/null 2>&1 & +elif type imv >/dev/null 2>&1; then + make_thumbs imv + view_files imv >/dev/null 2>&1 & +elif type imvr >/dev/null 2>&1; then + make_thumbs imv + view_files imvr >/dev/null 2>&1 & +elif type viu >/dev/null 2>&1; then + clear + make_thumbs viu + viu -n "$ret" + exit_prompt +elif type catimg >/dev/null 2>&1; then + make_thumbs catimg + catimg "$ret" + exit_prompt +else + exit_prompt "Please install sxiv/nsxiv/imv/viu/catimg/lsix." +fi diff --git a/.local/share/nnn/plugins/ipinfo b/.local/share/nnn/plugins/ipinfo new file mode 100755 index 0000000..4ff6f41 --- /dev/null +++ b/.local/share/nnn/plugins/ipinfo @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +# Description: Shows the external IP address and whois information. Useful over VPNs. +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +IP=$(curl -s ifconfig.me) + +whois "$IP" +echo your external IP address is "$IP" + +read -r _ diff --git a/.local/share/nnn/plugins/kdeconnect b/.local/share/nnn/plugins/kdeconnect new file mode 100755 index 0000000..5f63d8b --- /dev/null +++ b/.local/share/nnn/plugins/kdeconnect @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +# Description: Send the selected files to your Android device using kdeconnect-cli. +# kdeconnect must be configured on the Android device and the PC. +# +# Shell: POSIX compliant +# Author: juacq97 + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +id=$(kdeconnect-cli -a --id-only | awk '{print $1}') +if [ -s "$selection" ]; then + kdeconnect-cli -d "$id" --share "$(cat "$selection")" + + # If you want a system notification, uncomment the next 3 lines. + #notify-send -a "Kdeconnect" "Sending $(cat "$selection")" +#else + #notify-send -a "Kdeconnect" "No file selected" + + # Clear selection + if [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" + fi +fi diff --git a/.local/share/nnn/plugins/launch b/.local/share/nnn/plugins/launch new file mode 100755 index 0000000..d666cc5 --- /dev/null +++ b/.local/share/nnn/plugins/launch @@ -0,0 +1,42 @@ +#!/usr/bin/env sh + +# Description: Independent POSIX-compliant GUI application launcher. +# Fuzzy find executables in $PATH and launch an application. +# stdin, stdout, stderr are suppressed so CLI tools exit silently. +# +# To configure launch as an independent app launcher add a keybind +# to open launch in a terminal e.g., +# +# xfce4-terminal -e "${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/launch +# +# Dependencies: fzf +# +# Usage: launch [delay] +# delay is in seconds, if omitted launch waits for 1 sec +# +# Integration with nnn: launch is installed with other plugins, nnn picks it up. +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +# shellcheck disable=SC2086 + +IFS=':' + +get_selection() { + if type fzf >/dev/null 2>&1; then + { IFS=':'; ls -H $PATH; } | sort | fzf + else + exit 1 + fi +} + +if selection=$( get_selection ); then + setsid "$selection" 2>/dev/null 1>/dev/null & + + if [ -n "$1" ]; then + sleep "$1" + else + sleep 1 + fi +fi diff --git a/.local/share/nnn/plugins/mimelist b/.local/share/nnn/plugins/mimelist new file mode 100755 index 0000000..ccfe05a --- /dev/null +++ b/.local/share/nnn/plugins/mimelist @@ -0,0 +1,15 @@ +#!/usr/bin/env sh + +# Description: Find and list files by mime type in smart context +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +# shellcheck disable=SC1090,SC1091 +. "$(dirname "$0")"/.nnn-plugin-helper + +printf "mime (e.g., video/audio/image): " +read -r mime + +printf "%s" "+l" > "$NNN_PIPE" +find . | file -if- | grep "$mime" | awk -F: '{printf "%s\0", $1}' > "$NNN_PIPE" diff --git a/.local/share/nnn/plugins/moclyrics b/.local/share/nnn/plugins/moclyrics new file mode 100755 index 0000000..2f69807 --- /dev/null +++ b/.local/share/nnn/plugins/moclyrics @@ -0,0 +1,40 @@ +#!/usr/bin/env sh + +# Description: Fetches the lyrics of the track currently playing in MOC +# +# Dependencies: ddgr (https://github.com/jarun/ddgr) +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +# Check if MOC server is running +cmd=$(pgrep -x mocp 2>/dev/null) +ret=$cmd +if [ -z "$ret" ]; then + exit +fi + +# Grab the output +out="$(mocp -i)" + +# Check if anything is playing +state=$(echo "$out" | grep "State:" | cut -d' ' -f2) +if ! [ "$state" = 'PLAY' ]; then + exit +fi + +# Try by Artist and Song Title first +ARTIST="$(echo "$out" | grep 'Artist:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')" +TITLE="$(echo "$out" | grep 'SongTitle:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')" + +if [ -n "$ARTIST" ] && [ -n "$TITLE" ]; then + ddgr -w azlyrics.com --ducky "$ARTIST" "$TITLE" +else + # Try by file name + FILENAME="$(basename "$(echo "$out" | grep 'File:' | cut -d':' -f2)")" + FILENAME="$(echo "${FILENAME%%.*}" | tr -d -)" + + if [ -n "$FILENAME" ]; then + ddgr -w azlyrics.com --ducky "$FILENAME" + fi +fi diff --git a/.local/share/nnn/plugins/mocq b/.local/share/nnn/plugins/mocq new file mode 100755 index 0000000..038ecc9 --- /dev/null +++ b/.local/share/nnn/plugins/mocq @@ -0,0 +1,89 @@ +#!/usr/bin/env sh + +# Description: Appends and optionally plays music in MOC +# +# Notes: +# - if selection is available, plays it, else plays the current file or directory +# - appends tracks and exits is MOC is running, else clears playlist and adds tracks +# - to let mocp shuffle tracks, set SHUFFLE=1 +# +# Shell: POSIX compliant +# Authors: Arun Prakash Jana, ath3 + +IFS="$(printf '\n\r')" +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +cmd=$(pgrep -x mocp 2>/dev/null) +ret=$cmd + +SHUFFLE="${SHUFFLE:-0}" + +mocp_add () +{ + if [ "$SHUFFLE" = 1 ]; then + if [ "$resp" = "y" ]; then + arr=$(tr '\0' '\n' < "$selection") + elif [ -n "$1" ]; then + arr="$1" + fi + + for entry in $arr + do + if [ -d "$entry" ]; then + arr2=$arr2$(find "$entry" -type f \( ! -iname "*.m3u" ! -iname "*.pls" \)) + elif echo "$entry" | grep -qv '\.m3u$\|\.pls$' ; then + arr2=$(printf "%s\n%s" "$entry" "$arr2") + fi + done + + mocp -o shuffle + echo "$arr2" | xargs -d "\n" mocp -a + else + if [ "$resp" = "y" ]; then + xargs < "$selection" -0 mocp -a + else + mocp -a "$1" + fi + fi +} + +if [ ! -s "$selection" ] && [ -z "$1" ]; then + exit +fi + +if [ "$2" = "opener" ]; then + : +elif [ -s "$selection" ]; then + printf "Work with selection? Enter 'y' to confirm: " + read -r resp +fi + +if [ -z "$ret" ]; then + # mocp not running + mocp -S +else + # mocp running, check if it's playing + state=$(mocp -i | grep "State:" | cut -d' ' -f2) + + if [ "$state" = 'PLAY' ]; then + # add to playlist and exit + mocp_add "$1" + + # uncomment the line below to show mocp interface after appending + # mocp + + exit + fi +fi + +# clear selection and play +mocp -c +mocp_add "$1" "$resp" +mocp -p + +# uncomment the line below to show mocp interface after appending +# mocp + +# Clear selection +if [ "$resp" = "y" ] && [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" +fi diff --git a/.local/share/nnn/plugins/mp3conv b/.local/share/nnn/plugins/mp3conv new file mode 100755 index 0000000..029f544 --- /dev/null +++ b/.local/share/nnn/plugins/mp3conv @@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +# Description: Extract audio from multimedia files and convert to mp3 +# +# Dependencies: ffmpeg compiled with libmp3lame audio codec support +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +outdir=_mp3files + +handle_multimedia() { + mime="${1}" + file="${2}" + + case "${mime}" in + audio/* | video/*) + ffmpeg -i "${file}" -vn -codec:a libmp3lame -q:a 2 "${outdir}/${file%.*}.mp3" + ;; + *) + ;; + esac +} + +printf "Process 'a'll in directory or 'c'urrent? " +read -r resp + +if [ "$resp" = "a" ]; then + if ! [ -e "${outdir}" ]; then + mkdir "${outdir}" + fi + + for f in *; do + if [ -f "${f}" ]; then + mimestr="$( file --dereference --brief --mime-type -- "${f}" )" + handle_multimedia "${mimestr}" "${f}" + fi + done +elif [ "$resp" = "c" ] && [ -f "$1" ]; then + ffmpeg -i "${1}" -vn -codec:a libmp3lame -q:a 2 "${1%.*}.mp3" +fi diff --git a/.local/share/nnn/plugins/mtpmount b/.local/share/nnn/plugins/mtpmount new file mode 100755 index 0000000..d6feea0 --- /dev/null +++ b/.local/share/nnn/plugins/mtpmount @@ -0,0 +1,76 @@ +#!/usr/bin/env sh + +# Description: Toggle mount of MTP device (eg. Android device) +# 'l' to list mountable devices +# 'n' integer associated to device to mount +# 'q'/'Return' exit +# +# Dependencies: gvfs-mtp +# +# Notes: The MTP device should be mounted at /run/user/$UID/gvfs. +# Put /run/user/$UID/gvfs to bookmark entries (NNN_BMS) for faster access. +# Make sure the device is unlocked when mounting. +# +# When doing copy-paste into MTP device, you will get an error like this: +# cp: preserving times for './gambar1.png': Operation not supported +# That just means the file is copied but timestamp won't be preserved. +# It's like doing `cp -p localfile.txt file-to-SMB.txt`. +# +# Shell: POSIX compliant +# Author: Benawi Adha + +prompt="Device number ('l' to list): " + +IFS=' +' + +lsmtp () { + devs=$(gio mount -li | grep -e 'activation_root' | sed 's/\s*activation_root=//g') + c=1 + printf "Devices list:\n" + for i in $devs; do + printf "%s %s\\n" "$c" "$i" + c=$(( c + 1 )) + done + echo +} + +lsmtp +printf "%s" "$prompt" +read -r input + +while [ -n "$input" ] +do + if [ "$input" = "l" ]; then + lsmtp + elif [ "$input" = "q" ] || [ "$input" -eq 0 ]; then + exit + elif [ "$input" -le "$(printf '%s\n' "${devs}" | grep -c '^')" ]; then + # dev=$(printf "%s\n" "$devs" | cut -d$'\n' -f${input}) + c=1 + for i in $devs; do + dev=$i + if [ "$input" -eq $c ]; then + break + fi + c=$(( c + 1 )) + done + + if (gio mount -l | grep '^Mount([1-9]).*'"$dev" ) 1>/dev/null; then + if gio mount -u "${dev}"; then + printf "%s unmounted\n" "$dev" + fi + else + if gio mount "${dev}"; then + printf "%s mounted to /run/user/\$UID/gvfs\n" "$dev" + fi + fi + echo + else + printf "Invalid input\n" + fi + + printf "%s" "$prompt" + read -r input +done + diff --git a/.local/share/nnn/plugins/nbak b/.local/share/nnn/plugins/nbak new file mode 100755 index 0000000..f9cb644 --- /dev/null +++ b/.local/share/nnn/plugins/nbak @@ -0,0 +1,75 @@ +#!/usr/bin/env sh + +# Description: Backup nnn configuration +# - config dir content +# - environment config +# - shell functions and aliases +# +# Shell: POSIX compliant +# Author: Léo Villeveygoux + +nnn_aliases="n nnn" + +outdir="nnn-$(whoami)@$(hostname)" + +outfile="${outdir}.tar.bz2" + +shellname="$(basename "$SHELL")" + +conffile="config.txt" + +configdir="${XDG_CONFIG_HOME:-$HOME/.config}/nnn" + +workdir="$PWD" + +tempdir="$(mktemp -d)" + +mkdir "$tempdir/$outdir" + +if [ ! -d "$tempdir" ]; then + echo "Can't create work directory." >&2 + exit 1 +fi + +cd "$tempdir/$outdir" || exit 1 + +# Backing up config dir content +cp -r "$configdir" . || exit 1 + +# Environment config +env | sed "s/'/'\\\\''/" |\ + awk '/^NNN_/{print "export '\''"$0"'\''"}' > "$conffile" + +# Shell functions/aliases +case "$shellname" in + bash) + for name in $nnn_aliases ; do + if [ "$(bash -ic "type -t $name")" = "function" ] ; then + bash -ic "type $name" | tail -n+2 >> "$conffile" + elif bash -ic "alias $name" >/dev/null 2>&1 ; then + bash -ic "alias $name" >> "$conffile" + fi + done + ;; + zsh) + for name in $nnn_aliases ; do + if zsh -ic "functions $name" ; then + zsh -ic "functions $name" >> "$conffile" + elif zsh -ic "alias $name" ; then + echo alias "$(zsh -ic "alias $name")" >> "$conffile" + fi + done + ;; + + *) + echo "Unknown shell, skipping alias/function checking." >&2 + ;; +esac + +cd .. || exit 1 + +printf "Saving as '%s' ... " "$workdir/$outfile" + +tar caf "$workdir/$outfile" "$outdir" && echo "Done" || echo "Failed" + +cd "$workdir" && rm -rf "$tempdir" diff --git a/.local/share/nnn/plugins/nmount b/.local/share/nnn/plugins/nmount new file mode 100755 index 0000000..e92fd5d --- /dev/null +++ b/.local/share/nnn/plugins/nmount @@ -0,0 +1,55 @@ +#!/usr/bin/env sh + +# Description: Toggle mount status of a device using pmount +# If the device is not mounted, it will be mounted. +# If the device is mounted, it will be unmounted and powered down. +# +# Dependencies: lsblk, pmount +# +# Usage: Runs `lsblk` on 'l', exits on 'Return`. +# +# Notes: +# - The script uses Linux-specific lsblk to list block devices. Alternatives: +# macOS: "diskutil list" +# BSD: "geom disk list" +# - The script uses udisksctl (from udisks2) to power down devices. This is also Linux-specific. +# Users on non-Linux platforms can comment it and use an alterntive to power-down disks. +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +prompt="device name [e.g. sdXn] ('l'ist, 'q'uit): " + +lsblk + +printf "\nEnsure you aren't still in the mounted device.\n" +printf "%s" "$prompt" +read -r dev + +while [ -n "$dev" ] +do + if [ "$dev" = "l" ]; then + lsblk + elif [ "$dev" = "q" ]; then + exit + else + if grep -qs "$dev " /proc/mounts; then + sync + if pumount "$dev" + then + echo "$dev" unmounted. + if udisksctl power-off -b /dev/"$dev" + then + echo "$dev" ejected. + fi + fi + else + pmount "$dev" + echo "$dev" mounted to "$(lsblk -n /dev/"$dev" | rev | cut -d' ' -f1 | rev)". + fi + fi + + echo + printf "%s" "$prompt" + read -r dev +done diff --git a/.local/share/nnn/plugins/nuke b/.local/share/nnn/plugins/nuke new file mode 100755 index 0000000..b3eafc8 --- /dev/null +++ b/.local/share/nnn/plugins/nuke @@ -0,0 +1,555 @@ +#!/usr/bin/env sh + +# Description: Sample script to play files in apps by file type or mime +# +# Shell: POSIX compliant +# Usage: nuke filepath +# +# Integration with nnn: +# 1. Export the required config: +# export NNN_OPENER=/absolute/path/to/nuke +# # Otherwise, if nuke is in $PATH +# # export NNN_OPENER=nuke +# 2. Run nnn with the program option to indicate a CLI opener +# nnn -c +# # The -c program option overrides option -e +# 3. nuke can use nnn plugins (e.g. mocq is used for audio), $PATH is updated. +# +# Details: +# Inspired by ranger's scope.sh, modified for usage with nnn. +# +# Guards against accidentally opening mime types like executables, shared libs etc. +# +# Tries to play 'file' (1st argument) in the following order: +# 1. by extension +# 2. by mime (image, video, audio, pdf) +# 3. by mime (other file types) +# 4. by mime (prompt and run executables) +# +# Modification tips: +# 1. Invokes CLI utilities by default. Set GUI to 1 to enable GUI apps. +# 2. PAGER is "less -R". +# 3. Start GUI apps in bg to unblock. Redirect stdout and strerr if required. +# 4. Some CLI utilities are piped to the $PAGER, to wait and quit uniformly. +# 5. If the output cannot be paged use "read -r _" to wait for user input. +# 6. On a DE, try 'xdg-open' or 'open' in handle_fallback() as last resort. +# +# Feel free to change the utilities to your favourites and add more mimes. +# +# Defaults: +# By extension (only the enabled ones): +# most archives: list with atool, bsdtar +# rar: list with unrar +# 7-zip: list with 7z +# pdf: zathura (GUI), pdftotext, mutool, exiftool +# audio: mocq (nnn plugin using MOC), mpv, media_client (Haiku), mediainfo, exiftool +# avi|mkv|mp4: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool +# log: vi +# torrent: rtorrent, transmission-show +# odt|ods|odp|sxw: odt2txt +# md: glow (https://github.com/charmbracelet/glow), lowdown (https://kristaps.bsd.lv/lowdown) +# htm|html|xhtml: w3m, lynx, elinks +# json: jq, python (json.tool module) +# Multimedia by mime: +# image/*: imv/sxiv/nsxiv (GUI), viu (https://github.com/atanunq/viu), img2txt, exiftool +# video/*: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool +# audio/*: mocq (nnn plugin using MOC), mpv, media_client (Haiku), mediainfo, exiftool +# application/pdf: zathura (GUI), pdftotext, mutool, exiftool +# Other mimes: +# text/troff: man -l +# text/* | */xml: vi +# image/vnd.djvu): djvutxt, exiftool +# +# TODO: +# 1. Adapt, test and enable all mimes +# 2. Clean-up the unnecessary exit codes + +# set to 1 to enable GUI apps and/or BIN execution +GUI="${GUI:-0}" +BIN="${BIN:-0}" + +set -euf -o noclobber -o noglob -o nounset +IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n + +PATH=$PATH:"${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins" +IMAGE_CACHE_PATH="$(dirname "$1")"/.thumbs + +FPATH="$1" +FNAME=$(basename "$1") +EDITOR="${VISUAL:-${EDITOR:-vi}}" +PAGER="${PAGER:-less -R}" +ext="${FNAME##*.}" +if [ -n "$ext" ]; then + ext="$(printf "%s" "${ext}" | tr '[:upper:]' '[:lower:]')" +fi + +is_mac() { + uname | grep -q "Darwin" +} + +handle_pdf() { + if [ "$GUI" -ne 0 ]; then + if is_mac; then + nohup open "${FPATH}" >/dev/null 2>&1 & + elif type zathura >/dev/null 2>&1; then + nohup zathura "${FPATH}" >/dev/null 2>&1 & + else + return + fi + elif type pdftotext >/dev/null 2>&1; then + ## Preview as text conversion + pdftotext -l 10 -nopgbrk -q -- "${FPATH}" - | eval "$PAGER" + elif type mutool >/dev/null 2>&1; then + mutool draw -F txt -i -- "${FPATH}" 1-10 | eval "$PAGER" + elif type exiftool >/dev/null 2>&1; then + exiftool "${FPATH}" | eval "$PAGER" + else + return + fi + exit 0 +} + +handle_audio() { + if type mocp >/dev/null 2>&1 && type mocq >/dev/null 2>&1; then + mocq "${FPATH}" "opener" >/dev/null 2>&1 + elif type mpv >/dev/null 2>&1; then + mpv "${FPATH}" >/dev/null 2>&1 & + elif type media_client >/dev/null 2>&1; then + media_client play "${FPATH}" >/dev/null 2>&1 & + elif type mediainfo >/dev/null 2>&1; then + mediainfo "${FPATH}" | eval "$PAGER" + elif type exiftool >/dev/null 2>&1; then + exiftool "${FPATH}"| eval "$PAGER" + else + return + fi + exit 0 +} + +handle_video() { + if [ "$GUI" -ne 0 ]; then + if is_mac; then + nohup open "${FPATH}" >/dev/null 2>&1 & + elif type smplayer >/dev/null 2>&1; then + nohup smplayer "${FPATH}" >/dev/null 2>&1 & + elif type mpv >/dev/null 2>&1; then + nohup mpv "${FPATH}" >/dev/null 2>&1 & + else + return + fi + elif type ffmpegthumbnailer >/dev/null 2>&1; then + # Thumbnail + [ -d "${IMAGE_CACHE_PATH}" ] || mkdir "${IMAGE_CACHE_PATH}" + ffmpegthumbnailer -i "${FPATH}" -o "${IMAGE_CACHE_PATH}/${FNAME}.jpg" -s 0 + viu -n "${IMAGE_CACHE_PATH}/${FNAME}.jpg" | eval "$PAGER" + elif type mediainfo >/dev/null 2>&1; then + mediainfo "${FPATH}" | eval "$PAGER" + elif type exiftool >/dev/null 2>&1; then + exiftool "${FPATH}"| eval "$PAGER" + else + return + fi + exit 0 +} + +# handle this extension and exit +handle_extension() { + case "${ext}" in + ## Archive + a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\ + rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip) + if type atool >/dev/null 2>&1; then + atool --list -- "${FPATH}" | eval "$PAGER" + exit 0 + elif type bsdtar >/dev/null 2>&1; then + bsdtar --list --file "${FPATH}" | eval "$PAGER" + exit 0 + fi + exit 1;; + rar) + if type unrar >/dev/null 2>&1; then + ## Avoid password prompt by providing empty password + unrar lt -p- -- "${FPATH}" | eval "$PAGER" + fi + exit 1;; + 7z) + if type 7z >/dev/null 2>&1; then + ## Avoid password prompt by providing empty password + 7z l -p -- "${FPATH}" | eval "$PAGER" + exit 0 + fi + exit 1;; + + ## PDF + pdf) + handle_pdf + exit 1;; + + ## Audio + aac|flac|m4a|mid|midi|mpa|mp2|mp3|ogg|wav|wma) + handle_audio + exit 1;; + + ## Video + avi|mkv|mp4) + handle_video + exit 1;; + + ## Log files + log) + "$EDITOR" "${FPATH}" + exit 0;; + + ## BitTorrent + torrent) + if type rtorrent >/dev/null 2>&1; then + rtorrent "${FPATH}" + exit 0 + elif type transmission-show >/dev/null 2>&1; then + transmission-show -- "${FPATH}" + exit 0 + fi + exit 1;; + + ## OpenDocument + odt|ods|odp|sxw) + if type odt2txt >/dev/null 2>&1; then + ## Preview as text conversion + odt2txt "${FPATH}" | eval "$PAGER" + exit 0 + fi + exit 1;; + + ## Markdown + md) + if type glow >/dev/null 2>&1; then + glow -sdark "${FPATH}" | eval "$PAGER" + exit 0 + elif type lowdown >/dev/null 2>&1; then + lowdown -Tterm "${FPATH}" | eval "$PAGER" + exit 0 + fi + ;; + + ## HTML + htm|html|xhtml) + ## Preview as text conversion + if type w3m >/dev/null 2>&1; then + w3m -dump "${FPATH}" | eval "$PAGER" + exit 0 + elif type lynx >/dev/null 2>&1; then + lynx -dump -- "${FPATH}" | eval "$PAGER" + exit 0 + elif type elinks >/dev/null 2>&1; then + elinks -dump "${FPATH}" | eval "$PAGER" + exit 0 + fi + ;; + + ## JSON + json) + if type jq >/dev/null 2>&1; then + jq --color-output . "${FPATH}" | eval "$PAGER" + exit 0 + elif type python >/dev/null 2>&1; then + python -m json.tool -- "${FPATH}" | eval "$PAGER" + exit 0 + fi + ;; + esac +} + +# sets the variable abs_target, this should be faster than calling printf +abspath() { + case "$1" in + /*) abs_target="$1";; + *) abs_target="$PWD/$1";; + esac +} + +# storing the result to a tmp file is faster than calling listimages twice +listimages() { + find -L "///${1%/*}" -maxdepth 1 -type f -print0 | + grep -izZE '\.(jpe?g|png|gif|webp|tiff|bmp|ico|svg)$' | + sort -z | tee "$tmp" +} + +load_dir() { + abspath "$2" + tmp="${TMPDIR:-/tmp}/nuke_$$" + trap 'rm -f $tmp' EXIT + count="$(listimages "$abs_target" | grep -a -m 1 -ZznF "$abs_target" | cut -d: -f1)" + + if [ -n "$count" ]; then + if [ "$GUI" -ne 0 ]; then + xargs -0 nohup "$1" -n "$count" -- < "$tmp" + else + xargs -0 "$1" -n "$count" -- < "$tmp" + fi + else + shift + "$1" -- "$@" # fallback + fi +} + +handle_multimedia() { + ## Size of the preview if there are multiple options or it has to be + ## rendered from vector graphics. If the conversion program allows + ## specifying only one dimension while keeping the aspect ratio, the width + ## will be used. + # local DEFAULT_SIZE="1920x1080" + + mimetype="${1}" + case "${mimetype}" in + ## SVG + # image/svg+xml|image/svg) + # convert -- "${FPATH}" "${IMAGE_CACHE_PATH}" && exit 6 + # exit 1;; + + ## DjVu + # image/vnd.djvu) + # ddjvu -format=tiff -quality=90 -page=1 -size="${DEFAULT_SIZE}" \ + # - "${IMAGE_CACHE_PATH}" < "${FPATH}" \ + # && exit 6 || exit 1;; + + ## Image + image/*) + if [ "$GUI" -ne 0 ]; then + if is_mac; then + nohup open "${FPATH}" >/dev/null 2>&1 & + exit 0 + elif type imv >/dev/null 2>&1; then + load_dir imv "${FPATH}" >/dev/null 2>&1 & + exit 0 + elif type imvr >/dev/null 2>&1; then + load_dir imvr "${FPATH}" >/dev/null 2>&1 & + exit 0 + elif type sxiv >/dev/null 2>&1; then + load_dir sxiv "${FPATH}" >/dev/null 2>&1 & + exit 0 + elif type nsxiv >/dev/null 2>&1; then + load_dir nsxiv "${FPATH}" >/dev/null 2>&1 & + exit 0 + fi + elif type viu >/dev/null 2>&1; then + viu -n "${FPATH}" | eval "$PAGER" + exit 0 + elif type img2txt >/dev/null 2>&1; then + img2txt --gamma=0.6 -- "${FPATH}" | eval "$PAGER" + exit 0 + elif type exiftool >/dev/null 2>&1; then + exiftool "${FPATH}" | eval "$PAGER" + exit 0 + fi + # local orientation + # orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FPATH}" )" + ## If orientation data is present and the image actually + ## needs rotating ("1" means no rotation)... + # if [[ -n "$orientation" && "$orientation" != 1 ]]; then + ## ...auto-rotate the image according to the EXIF data. + # convert -- "${FPATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6 + # fi + + ## `w3mimgdisplay` will be called for all images (unless overridden + ## as above), but might fail for unsupported types. + exit 7;; + + ## PDF + application/pdf) + handle_pdf + exit 1;; + + ## Audio + audio/*) + handle_audio + exit 1;; + + ## Video + video/*) + handle_video + exit 1;; + + # pdftoppm -f 1 -l 1 \ + # -scale-to-x "${DEFAULT_SIZE%x*}" \ + # -scale-to-y -1 \ + # -singlefile \ + # -jpeg -tiffcompression jpeg \ + # -- "${FPATH}" "${IMAGE_CACHE_PATH%.*}" \ + # && exit 6 || exit 1;; + + + ## ePub, MOBI, FB2 (using Calibre) + # application/epub+zip|application/x-mobipocket-ebook|\ + # application/x-fictionbook+xml) + # # ePub (using https://github.com/marianosimone/epub-thumbnailer) + # epub-thumbnailer "${FPATH}" "${IMAGE_CACHE_PATH}" \ + # "${DEFAULT_SIZE%x*}" && exit 6 + # ebook-meta --get-cover="${IMAGE_CACHE_PATH}" -- "${FPATH}" \ + # >/dev/null && exit 6 + # exit 1;; + + ## Font + # application/font*|application/*opentype) + # preview_png="/tmp/$(basename "${IMAGE_CACHE_PATH%.*}").png" + # if fontimage -o "${preview_png}" \ + # --pixelsize "120" \ + # --fontname \ + # --pixelsize "80" \ + # --text " ABCDEFGHIJKLMNOPQRSTUVWXYZ " \ + # --text " abcdefghijklmnopqrstuvwxyz " \ + # --text " 0123456789.:,;(*!?') ff fl fi ffi ffl " \ + # --text " The quick brown fox jumps over the lazy dog. " \ + # "${FPATH}"; + # then + # convert -- "${preview_png}" "${IMAGE_CACHE_PATH}" \ + # && rm "${preview_png}" \ + # && exit 6 + # else + # exit 1 + # fi + # ;; + + ## Preview archives using the first image inside. + ## (Very useful for comic book collections for example.) + # application/zip|application/x-rar|application/x-7z-compressed|\ + # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) + # local fn=""; local fe="" + # local zip=""; local rar=""; local tar=""; local bsd="" + # case "${mimetype}" in + # application/zip) zip=1 ;; + # application/x-rar) rar=1 ;; + # application/x-7z-compressed) ;; + # *) tar=1 ;; + # esac + # { [ "$tar" ] && fn=$(tar --list --file "${FPATH}"); } || \ + # { fn=$(bsdtar --list --file "${FPATH}") && bsd=1 && tar=""; } || \ + # { [ "$rar" ] && fn=$(unrar lb -p- -- "${FPATH}"); } || \ + # { [ "$zip" ] && fn=$(zipinfo -1 -- "${FPATH}"); } || return + # + # fn=$(echo "$fn" | python -c "import sys; import mimetypes as m; \ + # [ print(l, end='') for l in sys.stdin if \ + # (m.guess_type(l[:-1])[0] or '').startswith('image/') ]" |\ + # sort -V | head -n 1) + # [ "$fn" = "" ] && return + # [ "$bsd" ] && fn=$(printf '%b' "$fn") + # + # [ "$tar" ] && tar --extract --to-stdout \ + # --file "${FPATH}" -- "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 + # fe=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') + # [ "$bsd" ] && bsdtar --extract --to-stdout \ + # --file "${FPATH}" -- "$fe" > "${IMAGE_CACHE_PATH}" && exit 6 + # [ "$bsd" ] || [ "$tar" ] && rm -- "${IMAGE_CACHE_PATH}" + # [ "$rar" ] && unrar p -p- -inul -- "${FPATH}" "$fn" > \ + # "${IMAGE_CACHE_PATH}" && exit 6 + # [ "$zip" ] && unzip -pP "" -- "${FPATH}" "$fe" > \ + # "${IMAGE_CACHE_PATH}" && exit 6 + # [ "$rar" ] || [ "$zip" ] && rm -- "${IMAGE_CACHE_PATH}" + # ;; + esac +} + +handle_mime() { + mimetype="${1}" + case "${mimetype}" in + ## Manpages + text/troff) + man -l "${FPATH}" + exit 0;; + + ## Text + text/* | */xml) + "$EDITOR" "${FPATH}" + exit 0;; + ## Syntax highlight + # if [[ "$( stat --printf='%s' -- "${FPATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then + # exit 2 + # fi + # if [[ "$( tput colors )" -ge 256 ]]; then + # local pygmentize_format='terminal256' + # local highlight_format='xterm256' + # else + # local pygmentize_format='terminal' + # local highlight_format='ansi' + # fi + # env HIGHLIGHT_OPTIONS="${HIGHLIGHT_OPTIONS}" highlight \ + # --out-format="${highlight_format}" \ + # --force -- "${FPATH}" && exit 5 + # pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}"\ + # -- "${FPATH}" && exit 5 + # exit 2;; + + ## DjVu + image/vnd.djvu) + if type djvutxt >/dev/null 2>&1; then + ## Preview as text conversion (requires djvulibre) + djvutxt "${FPATH}" | eval "$PAGER" + exit 0 + elif type exiftool >/dev/null 2>&1; then + exiftool "${FPATH}" | eval "$PAGER" + exit 0 + fi + exit 1;; + esac +} + +handle_fallback() { + if [ "$GUI" -ne 0 ]; then + if type xdg-open >/dev/null 2>&1; then + nohup xdg-open "${FPATH}" >/dev/null 2>&1 & + exit 0 + elif type open >/dev/null 2>&1; then + nohup open "${FPATH}" >/dev/null 2>&1 & + exit 0 + fi + fi + + echo '----- File details -----' && file --dereference --brief -- "${FPATH}" + exit 1 +} + +handle_blocked() { + case "${MIMETYPE}" in + application/x-sharedlib) + exit 0;; + + application/x-shared-library-la) + exit 0;; + + application/x-executable) + exit 0;; + + application/x-shellscript) + exit 0;; + + application/octet-stream) + exit 0;; + esac +} + +handle_bin() { + case "${MIMETYPE}" in + application/x-executable|application/x-shellscript) + clear + echo '-------- Executable File --------' && file --dereference --brief -- "${FPATH}" + printf "Run executable (y/N/'a'rgs)? " + read -r answer + case "$answer" in + [Yy]* ) exec "${FPATH}";; + [Aa]* ) + printf "args: " + read -r args + exec "${FPATH}" "$args";; + [Nn]* ) exit;; + esac + esac +} + +MIMETYPE="$( file -bL --mime-type -- "${FPATH}" )" +handle_extension +handle_multimedia "${MIMETYPE}" +handle_mime "${MIMETYPE}" +[ "$BIN" -ne 0 ] && [ -x "${FPATH}" ] && handle_bin +handle_blocked "${MIMETYPE}" +handle_fallback + +exit 1 diff --git a/.local/share/nnn/plugins/oldbigfile b/.local/share/nnn/plugins/oldbigfile new file mode 100755 index 0000000..0a21527 --- /dev/null +++ b/.local/share/nnn/plugins/oldbigfile @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +# Description: List files bigger than input size by ascending access date. +# +# Dependencies: find sort +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +printf "Min file size (MB): " +read -r size + +find . -size +"$size"M -type f -printf '%A+ %s %p\n' | sort + +echo "Press any key to exit" +read -r _ diff --git a/.local/share/nnn/plugins/openall b/.local/share/nnn/plugins/openall new file mode 100755 index 0000000..5a7941f --- /dev/null +++ b/.local/share/nnn/plugins/openall @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Description: Open selected files in nuke one by one or in oneshot +# +# Notes: 1. Opens the hovered file if the selection is empty +# 2. nuke is the default, set OPENER below for custom +# 3. Opener is invoked once for each file in a loop +# 4. Keep pressing "Enter" to open files one by one +# +# Shell: bash +# Author: Arun Prakash Jana + +sel=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +OPENER="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/nuke" + +if [ -s "$sel" ]; then + targets=() + while IFS= read -r -d '' entry || [ -n "$entry" ]; do + targets+=( "$entry" ) + done < "$sel" + + elements=${#targets[@]} + + if (( elements == 1 )); then + # If there's only one file selected, open without prompts + "$OPENER" "${targets[0]}" + else + printf "open [A]ll? " + read -r all + + for ((index=0; index <= ${#targets[@]}; index++)); do + "$OPENER" "${targets[index]}" + if [ "$all" != "A" ] && (( index+1 < elements )); then + printf "press Enter to open '%s'\n" "${targets[index+1]}" + read -r -s -n 1 key + if [[ $key != "" ]]; then + break + fi + fi + done + fi + + # Clear selection + if [ -s "$sel" ] && [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" + fi +elif [ -n "$1" ]; then + "$OPENER" "$1" +fi diff --git a/.local/share/nnn/plugins/organize b/.local/share/nnn/plugins/organize new file mode 100755 index 0000000..fb70aaf --- /dev/null +++ b/.local/share/nnn/plugins/organize @@ -0,0 +1,62 @@ +#!/usr/bin/env sh + +# Description: Organize files in directories by category +# +# Note: This plugin clears the selection as it changes the contents of the current dir +# +# Shell: POSIX compliant +# Author: th3lusive + +sel=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +organize() { + case "$(file -biL "$1")" in + *video*) + [ ! -d "Videos" ] && mkdir "Videos" + mv "$1" "Videos/$1" + printf "Moved %s to Videos\n" "$1" ;; + + *audio*) [ ! -d "Audio" ] && mkdir "Audio" + mv "$1" "Audio/$1" + printf "Moved %s to Audio\n" "$1" ;; + + *image*) + [ ! -d "Images" ] && mkdir "Images" + mv "$1" "Images/$1" + printf "Moved %s to Images\n" "$1" ;; + + *pdf*|*document*|*epub*|*djvu*|*cb*) + [ ! -d "Documents" ] && mkdir "Documents" + mv "$1" "Documents/$1" + printf "Moved %s to Documents\n" "$1" ;; + + *text*) + [ ! -d "Plaintext" ] && mkdir "Plaintext" + mv "$1" "Plaintext/$1" + printf "Moved %s to Plaintext\n" "$1" ;; + + *tar*|*xz*|*compress*|*7z*|*rar*|*zip*) + [ ! -d "Archives" ] && mkdir "Archives" + mv "$1" "Archives/$1" + printf "Moved %s to Archives\n" "$1" ;; + + *binary*) + [ ! -d "Binaries" ] && mkdir "Binaries" + mv "$1" "Binaries/$1" + printf "Moved %s to Binaries\n" "$1" ;; + esac +} + +main() { + for file in * + do + [ -f "$file" ] && organize "$file" + done + + # Clear selection + if [ -s "$sel" ] && [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" + fi +} + +main "$@" diff --git a/.local/share/nnn/plugins/pdfread b/.local/share/nnn/plugins/pdfread new file mode 100755 index 0000000..1e889be --- /dev/null +++ b/.local/share/nnn/plugins/pdfread @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +# Description: Read a text or PDF file in British English +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +if [ -n "$1" ]; then + tmpf="$(basename "$1")" + tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}" + + if [ "$(head -c 4 "$1")" = "%PDF" ]; then + # Convert using pdftotext + pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' > "$tmpf".txt + + pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$tmpf".txt)" + + rm "$tmpf".txt + else + pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$1")" + fi + + # to jump around and note the time + mpv "$tmpf".wav + + # flat read but better quality + # play -qV0 "$tmpf".wav treble 2 gain -l 2 + + rm "$tmpf".wav +fi diff --git a/.local/share/nnn/plugins/preview-tabbed b/.local/share/nnn/plugins/preview-tabbed new file mode 100755 index 0000000..d1354bc --- /dev/null +++ b/.local/share/nnn/plugins/preview-tabbed @@ -0,0 +1,211 @@ +#!/usr/bin/env bash + +# Description: tabbed/xembed based file previewer +# +# Dependencies: +# - tabbed (https://tools.suckless.org/tabbed): xembed host +# - xterm (or urxvt or st) : xembed client for text-based preview +# - mpv (https://mpv.io): xembed client for video/audio +# - sxiv (https://github.com/muennich/sxiv) or, +# - nsxiv (https://codeberg.org/nsxiv/nsxiv) : xembed client for images +# - zathura (https://pwmt.org/projects/zathura): xembed client for PDF +# - nnn's nuke plugin for text preview and fallback +# nuke is a fallback for 'mpv', 'sxiv'/'nsxiv', and 'zathura', but has its +# own dependencies, see the script for more information +# - vim (or any editor/pager really) +# - file +# - mktemp +# - xdotool (optional, to keep main window focused) +# +# Usage: +# - Install the dependencies. Then set a NNN_FIFO +# and set a key for the plugin, then start `nnn`: +# $ NNN_FIFO=/tmp/nnn.fifo nnn +# - Launch the plugin with the designated key from nnn +# +# Notes: +# 1. This plugin needs a "NNN_FIFO" to work. See man. +# 2. If the same NNN_FIFO is used in multiple nnn instances, there will be one +# common preview window. With different FIFO paths, they will be independent. +# +# How it works: +# We use `tabbed` [1] as a xembed [2] host, to have a single window +# owning each previewer window. So each previewer must be a xembed client. +# For text previewers, this is not an issue, as there are a lot of +# xembed-able terminal emulator (we default to `xterm`, but examples are +# provided for `urxvt` and `st`). For graphic preview this can be trickier, +# but a few popular viewers are xembed-able, we use: +# - `mpv`: multimedia player, for video/audio preview +# - `sxiv`/`nsxiv`: image viewer +# - `zathura`: PDF viewer +# - but we always fallback to `nuke` plugin +# +# [1]: https://tools.suckless.org/tabbed/ +# [2]: https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.html +# +# Shell: Bash (job control is weakly specified in POSIX) +# Author: Léo Villeveygoux + + +XDOTOOL_TIMEOUT=2 +PAGER=${PAGER:-"vim -R"} +NUKE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/nuke" + + +if type xterm >/dev/null 2>&1 ; then + TERMINAL="xterm -into" +elif type urxvt >/dev/null 2>&1 ; then + TERMINAL="urxvt -embed" +elif type st >/dev/null 2>&1 ; then + TERMINAL="st -w" +else + echo "No xembed term found" >&2 +fi + + +term_nuke () { + # $1 -> $XID, $2 -> $FILE + $TERMINAL "$1" -e "$NUKE" "$2" & +} + +start_tabbed () { + FIFO="$(mktemp -u)" + mkfifo "$FIFO" + + tabbed > "$FIFO" & + + jobs # Get rid of the "Completed" entries + + TABBEDPID="$(jobs -p %%)" + + if [ -z "$TABBEDPID" ] ; then + echo "Can't start tabbed" + exit 1 + fi + + read -r XID < "$FIFO" + + rm "$FIFO" +} + +get_viewer_pid () { + VIEWERPID="$(jobs -p %%)" +} + +kill_viewer () { + if [ -n "$VIEWERPID" ] && jobs -p | grep "$VIEWERPID" ; then + kill "$VIEWERPID" + fi +} + +sigint_kill () { + kill_viewer + kill "$TABBEDPID" + exit 0 +} + +previewer_loop () { + unset -v NNN_FIFO + # mute from now + exec >/dev/null 2>&1 + + MAINWINDOW="$(xdotool getactivewindow)" + + start_tabbed + trap sigint_kill SIGINT + + xdotool windowactivate "$MAINWINDOW" + + # Bruteforce focus stealing prevention method, + # works well in floating window managers like XFCE + # but make interaction with the preview window harder + # (uncomment to use): + #xdotool behave "$XID" focus windowactivate "$MAINWINDOW" & + + while read -r FILE ; do + + jobs # Get rid of the "Completed" entries + + if ! jobs | grep tabbed ; then + break + fi + + if [ ! -e "$FILE" ] ; then + continue + fi + + kill_viewer + + MIME="$(file -bL --mime-type "$FILE")" + + case "$MIME" in + video/*) + if type mpv >/dev/null 2>&1 ; then + mpv --force-window=immediate --loop-file --wid="$XID" "$FILE" & + else + term_nuke "$XID" "$FILE" + fi + ;; + audio/*) + if type mpv >/dev/null 2>&1 ; then + mpv --force-window=immediate --loop-file --wid="$XID" "$FILE" & + else + term_nuke "$XID" "$FILE" + fi + ;; + image/*) + if type sxiv >/dev/null 2>&1 ; then + sxiv -ae "$XID" "$FILE" & + elif type nsxiv >/dev/null 2>&1 ; then + nsxiv -ae "$XID" "$FILE" & + else + term_nuke "$XID" "$FILE" + fi + ;; + application/pdf) + if type zathura >/dev/null 2>&1 ; then + zathura -e "$XID" "$FILE" & + else + term_nuke "$XID" "$FILE" + fi + ;; + inode/directory) + $TERMINAL "$XID" -e nnn "$FILE" & + ;; + text/*) + if [ -x "$NUKE" ] ; then + term_nuke "$XID" "$FILE" + else + # shellcheck disable=SC2086 + $TERMINAL "$XID" -e $PAGER "$FILE" & + fi + ;; + *) + if [ -x "$NUKE" ] ; then + term_nuke "$XID" "$FILE" + else + $TERMINAL "$XID" -e sh -c "file '$FILE' | $PAGER -" & + fi + ;; + esac + get_viewer_pid + + # following lines are not needed with the bruteforce xdotool method + ACTIVE_XID="$(xdotool getactivewindow)" + if [ $((ACTIVE_XID == XID)) -ne 0 ] ; then + xdotool windowactivate "$MAINWINDOW" + else + timeout "$XDOTOOL_TIMEOUT" xdotool behave "$XID" focus windowactivate "$MAINWINDOW" & + fi + done + kill "$TABBEDPID" + kill_viewer +} + +if [ ! -r "$NNN_FIFO" ] ; then + echo "Can't read \$NNN_FIFO ('$NNN_FIFO')" + exit 1 +fi + +previewer_loop < "$NNN_FIFO" & +disown diff --git a/.local/share/nnn/plugins/preview-tui b/.local/share/nnn/plugins/preview-tui new file mode 100755 index 0000000..1426327 --- /dev/null +++ b/.local/share/nnn/plugins/preview-tui @@ -0,0 +1,481 @@ +#!/usr/bin/env sh + +# Description: Terminal based file previewer +# +# Note: This plugin needs a "NNN_FIFO" to work. See man. +# +# Dependencies: +# - Supports 5 independent methods to preview with: +# - tmux (>=3.0), or +# - kitty with allow_remote_control and listen_on set in kitty.conf, or +# - QuickLook on WSL (https://github.com/QL-Win/QuickLook), or +# - Windows Terminal (https://github.com/Microsoft/Terminal | https://aka.ms/terminal) with WSL, or +# - $TERMINAL set to a terminal (it's xterm by default). +# - less or $PAGER +# - tree or exa or ls +# - mediainfo or file +# - mktemp +# - unzip +# - tar +# - man +# - optional: bsdtar or atool for additional archive preview +# - optional: bat for code syntax highlighting +# - optional: ueberzug, kitty terminal, viu or catimg for images +# - optional: convert(ImageMagick) for playing gif preview (required for kitty image previews) +# - optional: ffmpegthumbnailer for video thumbnails (https://github.com/dirkvdb/ffmpegthumbnailer) +# - optional: ffmpeg for audio thumbnails +# - optional: libreoffce for opendocument/officedocument preview +# - optional: pdftoppm(poppler) for pdf thumbnails +# - optional: gnome-epub-thumbnailer for epub thumbnails (https://gitlab.gnome.org/GNOME/gnome-epub-thumbnailer) +# - optional: fontpreview for font preview (https://github.com/sdushantha/fontpreview) +# - optional: djvulibre for djvu +# - optional: glow or lowdown for markdown +# - optional: w3m or lynx or elinks for html +# - optional: set/export ICONLOOKUP as 1 to enable file icons in front of directory previews with .iconlookup +# Icons and colors are configureable in .iconlookup +# - optional: scope.sh file viewer from ranger. +# 1. drop scope.sh executable in $PATH +# 2. set/export $USE_SCOPE as 1 +# - optional: pistol file viewer (https://github.com/doronbehar/pistol). +# 1. install pistol +# 2. set/export $USE_PISTOL as 1 +# +# Usage: +# You need to set a NNN_FIFO path and a key for the plugin with NNN_PLUG, +# then start `nnn`: +# +# $ nnn -a +# +# or +# +# $ NNN_FIFO=/tmp/nnn.fifo nnn +# +# Then launch the `preview-tui` plugin in `nnn`. +# +# If you provide the same NNN_FIFO to all nnn instances, there will be a +# single common preview window. If you provide different FIFO path (e.g. +# with -a), they will be independent. +# +# The previews will be shown in a tmux split. If that isn't possible, it +# will try to use a kitty terminal split. And as a final fallback, a +# different terminal window will be used ($TERMINAL). +# +# Tmux and kitty users can configure $SPLIT to either "h" or "v" to set a +# 'h'orizontal split or a 'v'ertical split (as in, the line that splits the +# windows will be horizontal or vertical). +# +# Kitty users need something similar to the following in their kitty.conf: +# - `allow_remote_control yes` +# - `listen_on unix:$TMPDIR/kitty` +# - `enabled_layouts splits` (optional) +# With ImageMagick installed, this terminal can use the icat kitten to display images. +# Refer to kitty documentation for further details. +# +# Iterm2 users are recommended to use viu to view images without getting pixelated. +# +# Windows Terminal users can set "Profile termination behavior" under "Profile > Advanced" settings +# to automaticaly close pane on quit when exit code is 0. +# +# Shell: POSIX compliant +# Authors: Todd Yamakawa, Léo Villeveygoux, @Recidiviste, Mario Ortiz Manero, Luuk van Baal, @WanderLanz + +#SPLIT="$SPLIT" # you can set a permanent split here +#TERMINAL="$TERMINAL" # same goes for the terminal +SPLIT_SIZE="${SPLIT_SIZE:-50}" # split size in percentage for supported previewers +USE_SCOPE="${USE_SCOPE:-0}" +USE_PISTOL="${USE_PISTOL:-0}" +ICONLOOKUP="${ICONLOOKUP:-0}" +PAGER="${PAGER:-less -P?n -R}" +TMPDIR="${TMPDIR:-/tmp}" +BAT_STYLE="${BAT_STYLE:-numbers}" +BAT_THEME="${BAT_THEME:-ansi}" +# Consider setting NNN_PREVIEWDIR to $XDG_CACHE_HOME/nnn/previews if you want to keep previews on disk between reboots +NNN_PREVIEWDIR="${NNN_PREVIEWDIR:-$TMPDIR/nnn/previews}" +NNN_PREVIEWWIDTH="${NNN_PREVIEWWIDTH:-1920}" +NNN_PREVIEWHEIGHT="${NNN_PREVIEWHEIGHT:-1080}" +NNN_PARENT="${NNN_FIFO#*.}" +[ "$NNN_PARENT" -eq "$NNN_PARENT" ] 2>/dev/null || NNN_PARENT="" +FIFOPID="$TMPDIR/nnn-preview-tui-fifopid.$NNN_PARENT" +PREVIEWPID="$TMPDIR/nnn-preview-tui-pagerpid.$NNN_PARENT" +CURSEL="$TMPDIR/nnn-preview-tui-selection.$NNN_PARENT" +FIFO_UEBERZUG="$TMPDIR/nnn-preview-tui-ueberzug-fifo.$NNN_PARENT" +POSOFFSET="$TMPDIR/nnn-preview-tui-posoffset" + +exists() { type "$1" >/dev/null 2>&1 ;} +pkill() { command pkill "$@" >/dev/null 2>&1 ;} +pidkill() { [ -f "$1" ] && kill "$(cat "$1")" >/dev/null 2>&1 ;} +prompt() { printf "%b" "$@"; cfg=$(stty -g); stty raw -echo; head -c 1; stty "$cfg" ;} + +start_preview() { + [ "$PAGER" = "most" ] && PAGER="less -R" + + if [ -e "${TMUX%%,*}" ] && tmux -V | grep -q '[ -][3456789]\.'; then + TERMINAL=tmux + elif [ -n "$KITTY_LISTEN_ON" ]; then + TERMINAL=kitty + elif [ -z "$TERMINAL" ] && [ "$TERM_PROGRAM" = "iTerm.app" ]; then + TERMINAL=iterm + elif [ -n "$WT_SESSION" ]; then + TERMINAL=winterm + else + TERMINAL="${TERMINAL:-xterm}" + fi + + if [ -z "$SPLIT" ] && [ $(($(tput lines) * 2)) -gt "$(tput cols)" ]; then + SPLIT='h' + elif [ "$SPLIT" != 'h' ]; then + SPLIT='v' + fi + + case "$TERMINAL" in + tmux) # tmux splits are inverted + if [ "$SPLIT" = "v" ]; then DSPLIT="h"; else DSPLIT="v"; fi + tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -e "CURSEL=$CURSEL" \ + -e "TMPDIR=$TMPDIR" -e "FIFOPID=$FIFOPID" -e "POSOFFSET=$POSOFFSET" \ + -e "BAT_STYLE=$BAT_STYLE" -e "BAT_THEME=$BAT_THEME" -e "PREVIEWPID=$PREVIEWPID" \ + -e "PAGER=$PAGER" -e "ICONLOOKUP=$ICONLOOKUP" -e "NNN_PREVIEWWIDTH=$NNN_PREVIEWWIDTH" \ + -e "USE_SCOPE=$USE_SCOPE" -e "SPLIT=$SPLIT" -e "USE_PISTOL=$USE_PISTOL" \ + -e "NNN_PREVIEWDIR=$NNN_PREVIEWDIR" -e "NNN_PREVIEWHEIGHT=$NNN_PREVIEWHEIGHT" \ + -e "FIFO_UEBERZUG=$FIFO_UEBERZUG" -e "QLPATH=$2" -d"$DSPLIT" -p"$SPLIT_SIZE" "$0" "$1" ;; + kitty) # Setting the layout for the new window. It will be restored after the script ends. + kitty @ goto-layout splits + # Trying to use kitty's integrated window management as the split window. All + # environmental variables that will be used in the new window must be explicitly passed. + kitty @ launch --no-response --title "nnn preview" --keep-focus \ + --cwd "$PWD" --env "PATH=$PATH" --env "NNN_FIFO=$NNN_FIFO" \ + --env "PREVIEW_MODE=1" --env "PAGER=$PAGER" --env "TMPDIR=$TMPDIR" \ + --env "USE_SCOPE=$USE_SCOPE" --env "SPLIT=$SPLIT" --env "TERMINAL=$TERMINAL"\ + --env "PREVIEWPID=$PREVIEWPID" --env "FIFO_UEBERZUG=$FIFO_UEBERZUG" \ + --env "ICONLOOKUP=$ICONLOOKUP" --env "NNN_PREVIEWHEIGHT=$NNN_PREVIEWHEIGHT" \ + --env "NNN_PREVIEWWIDTH=$NNN_PREVIEWWIDTH" --env "NNN_PREVIEWDIR=$NNN_PREVIEWDIR" \ + --env "USE_PISTOL=$USE_PISTOL" --env "BAT_STYLE=$BAT_STYLE" \ + --env "BAT_THEME=$BAT_THEME" --env "FIFOPID=$FIFOPID" \ + --env "CURSEL=$CURSEL" --location "${SPLIT}split" "$0" "$1" ;; + iterm) + command="$SHELL -c 'cd $PWD; \ + PATH=\\\"$PATH\\\" NNN_FIFO=\\\"$NNN_FIFO\\\" PREVIEW_MODE=1 PAGER=\\\"$PAGER\\\" \ + USE_SCOPE=\\\"$USE_SCOPE\\\" SPLIT=\\\"$SPLIT\\\" TERMINAL=\\\"$TERMINAL\\\" \ + PREVIEWPID=\\\"$PREVIEWPID\\\" CURSEL=\\\"$CURSEL\\\" TMPDIR=\\\"$TMPDIR\\\" \ + ICONLOOKUP=\\\"$ICONLOOKUP\\\" NNN_PREVIEWHEIGHT=\\\"$NNN_PREVIEWHEIGHT\\\" \ + NNN_PREVIEWWIDTH=\\\"$NNN_PREVIEWWIDTH\\\" NNN_PREVIEWDIR=\\\"$NNN_PREVIEWDIR\\\" \ + USE_PISTOL=\\\"$USE_PISTOL\\\" BAT_STYLE=\\\"$BAT_STYLE\\\" \ + BAT_THEME=\\\"$BAT_THEME\\\" FIFOPID=\\\"$FIFOPID\\\" \\\"$0\\\" \\\"$1\\\"'" + if [ "$SPLIT" = "h" ]; then split="horizontally"; else split="vertically"; fi + osascript <<-EOF + tell application "iTerm" + tell current session of current window + split $split with default profile command "$command" + end tell + end tell +EOF + ;; + winterm) + if [ "$SPLIT" = "h" ]; then split="H"; else split="V"; fi + cmd.exe /c wt -w 0 sp -$split -s$((SPLIT_SIZE / 100)) bash -c "cd $PWD \; \ + PATH='$PATH' NNN_FIFO=$NNN_FIFO PREVIEW_MODE=1 CURSEL=$CURSEL TMPDIR=$TMPDIR \ + FIFOPID=$FIFOPID BAT_STYLE=$BAT_STYLE BAT_THEME=$BAT_THEME PREVIEWPID=$PREVIEWPID \ + PAGER='$PAGER' ICONLOOKUP=$ICONLOOKUP NNN_PREVIEWWIDTH=$NNN_PREVIEWWIDTH \ + USE_SCOPE=$USE_SCOPE SPLIT=$SPLIT USE_PISTOL=$USE_PISTOL \ + NNN_PREVIEWDIR=$NNN_PREVIEWDIR NNN_PREVIEWHEIGHT=$NNN_PREVIEWHEIGHT \ + FIFO_UEBERZUG=$FIFO_UEBERZUG QLPATH=$2 $0 $1" \; -w 0 mf previous + ;; + *) if [ -n "$2" ]; then + QUICKLOOK=1 QLPATH="$2" PREVIEW_MODE=1 "$0" "$1" & + else + PREVIEWPID="$PREVIEWPID" CURSEL="$CURSEL" PREVIEW_MODE=1 \ + FIFOPID="$FIFOPID" FIFO_UEBERZUG="$FIFO_UEBERZUG" $TERMINAL -e "$0" "$1" & + fi ;; + esac +} + +toggle_preview() { + if exists QuickLook.exe; then + QLPATH="QuickLook.exe" + elif exists Bridge.exe; then + QLPATH="Bridge.exe" + fi + if pidkill "$FIFOPID"; then + [ -p "$NNN_PPIPE" ] && printf "0" > "$NNN_PPIPE" + pidkill "$PREVIEWPID" + pkill -f "tail --follow $FIFO_UEBERZUG" + if [ -n "$QLPATH" ] && stat "$1"; then + f="$(wslpath -w "$1")" && "$QLPATH" "$f" & + fi + else + [ -p "$NNN_PPIPE" ] && printf "1" > "$NNN_PPIPE" + start_preview "$1" "$QLPATH" + fi +} + +fifo_pager() { + cmd="$1" + shift + + # We use a FIFO to access $PAGER PID in jobs control + tmpfifopath="$TMPDIR/nnn-preview-tui-fifo.$$" + mkfifo "$tmpfifopath" || return + + $PAGER < "$tmpfifopath" & + printf "%s" "$!" > "$PREVIEWPID" + + ( + exec > "$tmpfifopath" + if [ "$cmd" = "pager" ]; then + if exists bat; then + bat --terminal-width="$cols" --decorations=always --color=always \ + --paging=never --style="$BAT_STYLE" --theme="$BAT_THEME" "$@" & + else + $PAGER "$@" & + fi + else + "$cmd" "$@" & + fi + ) + + rm "$tmpfifopath" +} + +# Binary file: show file info inside the pager +print_bin_info() { + printf -- "-------- \033[1;31mBinary file\033[0m --------\n" + if exists mediainfo; then + mediainfo "$1" + else + file -b "$1" + fi +} + +handle_mime() { + case "$2" in + image/jpeg) image_preview "$cols" "$lines" "$1" ;; + image/gif) generate_preview "$cols" "$lines" "$1" "gif" ;; + image/vnd.djvu) generate_preview "$cols" "$lines" "$1" "djvu" ;; + image/*) generate_preview "$cols" "$lines" "$1" "image" ;; + video/*) generate_preview "$cols" "$lines" "$1" "video" ;; + audio/*) generate_preview "$cols" "$lines" "$1" "audio" ;; + application/font*|application/*opentype|font/*) generate_preview "$cols" "$lines" "$1" "font" ;; + */*office*|*/*document*) generate_preview "$cols" "$lines" "$1" "office" ;; + application/zip) fifo_pager unzip -l "$1" ;; + text/troff) + if exists man; then + fifo_pager man -Pcat -l "$1" + else + fifo_pager pager "$1" + fi ;; + *) handle_ext "$1" "$3" "$4" ;; + esac +} + +handle_ext() { + case "$2" in + epub) generate_preview "$cols" "$lines" "$1" "epub" ;; + pdf) generate_preview "$cols" "$lines" "$1" "pdf" ;; + gz|bz2) fifo_pager tar -tvf "$1" ;; + md) if exists glow; then + fifo_pager glow -s dark "$1" + elif exists lowdown; then + fifo_pager lowdown -Tterm "$1" + else + fifo_pager pager "$1" + fi ;; + htm|html|xhtml) + if exists w3m; then + fifo_pager w3m "$1" + elif exists lynx; then + fifo_pager lynx "$1" + elif exists elinks; then + fifo_pager elinks "$1" + else + fifo_pager pager "$1" + fi ;; + 7z|a|ace|alz|arc|arj|bz|cab|cpio|deb|jar|lha|lz|lzh|lzma|lzo\ + |rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z) + if exists atool; then + fifo_pager atool -l "$1" + elif exists bsdtar; then + fifo_pager bsdtar -tvf "$1" + fi ;; + *) if [ "$3" = "bin" ]; then + fifo_pager print_bin_info "$1" + else + fifo_pager pager "$1" + fi ;; + esac +} + +preview_file() { + clear + # Trying to use pistol if it's available. + if [ "$USE_PISTOL" -ne 0 ] && exists pistol; then + fifo_pager pistol "$1" + return + fi + + # Trying to use scope.sh if it's available. + if [ "$USE_SCOPE" -ne 0 ] && exists scope.sh; then + fifo_pager scope.sh "$1" "$cols" "$lines" "$(mktemp -d)" "True" + return + fi + + # Use QuickLook if it's available. + if [ -n "$QUICKLOOK" ]; then + stat "$1" && f="$(wslpath -w "$1")" && "$QLPATH" "$f" & + return + fi + + # Detecting the exact type of the file: the encoding, mime type, and extension in lowercase. + encoding="$(file -bL --mime-encoding -- "$1")" + mimetype="$(file -bL --mime-type -- "$1")" + ext="${1##*.}" + [ -n "$ext" ] && ext="$(printf "%s" "${ext}" | tr '[:upper:]' '[:lower:]')" + lines=$(tput lines) + cols=$(tput cols) + + # Otherwise, falling back to the defaults. + if [ -d "$1" ]; then + cd "$1" || return + if [ "$ICONLOOKUP" -ne 0 ] && [ -f "$(dirname "$0")"/.iconlookup ]; then + [ "$SPLIT" = v ] && BSTR="\n" + # shellcheck disable=SC2012 + ls -F --group-directories-first | head -n "$((lines - 3))" | "$(dirname "$0")"/.iconlookup -l "$cols" -B "$BSTR" -b " " + elif exists tree; then + fifo_pager tree --filelimit "$(find . -maxdepth 1 | wc -l)" -L 3 -C -F --dirsfirst --noreport + elif exists exa; then + exa -G --group-directories-first --colour=always + else + fifo_pager ls -F --group-directories-first --color=always + fi + elif [ "${encoding#*)}" = "binary" ]; then + handle_mime "$1" "$mimetype" "$ext" "bin" + else + handle_mime "$1" "$mimetype" "$ext" + fi +} + +generate_preview() { + if [ -n "$QLPATH" ] && stat "$3"; then + f="$(wslpath -w "$3")" && "$QLPATH" "$f" & + elif [ ! -f "$NNN_PREVIEWDIR/$3.jpg" ] || [ -n "$(find -L "$3" -newer "$NNN_PREVIEWDIR/$3.jpg")" ]; then + mkdir -p "$NNN_PREVIEWDIR/${3%/*}" + case $4 in + audio) ffmpeg -i "$3" -filter_complex "scale=iw*min(1\,min($NNN_PREVIEWWIDTH/iw\,ih)):-1" "$NNN_PREVIEWDIR/$3.jpg" -y ;; + epub) gnome-epub-thumbnailer "$3" "$NNN_PREVIEWDIR/$3.jpg" ;; + font) fontpreview -i "$3" -o "$NNN_PREVIEWDIR/$3.jpg" ;; + gif) if [ -p "$FIFO_UEBERZUG" ] && exists convert; then + frameprefix="$NNN_PREVIEWDIR/$3/${3##*/}" + if [ ! -d "$NNN_PREVIEWDIR/$3" ]; then + mkdir -p "$NNN_PREVIEWDIR/$3" + convert -coalesce -resize "$NNN_PREVIEWWIDTH"x"$NNN_PREVIEWHEIGHT"\> "$3" "$frameprefix.jpg" || + MAGICK_TMPDIR="/tmp" convert -coalesce -resize "$NNN_PREVIEWWIDTH"x"$NNN_PREVIEWHEIGHT"\> "$3" "$frameprefix.jpg" + fi + frames=$(($(find "$NNN_PREVIEWDIR/$3" | wc -l) - 2)) + [ $frames -lt 0 ] && return + while true; do + for i in $(seq 0 $frames); do + image_preview "$1" "$2" "$frameprefix-$i.jpg" + sleep 0.1 + done + done & + printf "%s" "$!" > "$PREVIEWPID" + return + else + image_preview "$1" "$2" "$3" + return + fi ;; + image) if exists convert; then + convert "$3" -flatten -resize "$NNN_PREVIEWWIDTH"x"$NNN_PREVIEWHEIGHT"\> "$NNN_PREVIEWDIR/$3.jpg" + else + image_preview "$1" "$2" "$3" && return + fi ;; + office) libreoffice --convert-to jpg "$3" --outdir "$NNN_PREVIEWDIR/${3%/*}" + filename="$(printf "%s" "${3##*/}" | cut -d. -f1)" + mv "$NNN_PREVIEWDIR/${3%/*}/$filename.jpg" "$NNN_PREVIEWDIR/$3.jpg" ;; + pdf) pdftoppm -jpeg -f 1 -singlefile "$3" "$NNN_PREVIEWDIR/$3" ;; + djvu) ddjvu -format=ppm -page=1 "$3" "$NNN_PREVIEWDIR/$3.jpg" ;; + video) ffmpegthumbnailer -m -s0 -i "$3" -o "$NNN_PREVIEWDIR/$3.jpg" || rm "$NNN_PREVIEWDIR/$3.jpg" ;; + esac + fi + if [ -f "$NNN_PREVIEWDIR/$3.jpg" ]; then + image_preview "$1" "$2" "$NNN_PREVIEWDIR/$3.jpg" + else + fifo_pager print_bin_info "$3" + fi +} >/dev/null 2>&1 + +image_preview() { + clear + exec >/dev/tty + if [ "$TERMINAL" = "kitty" ]; then + # Kitty terminal users can use the native image preview method + kitty +kitten icat --silent --scale-up --place "$1"x"$2"@0x0 --transfer-mode=stream --stdin=no "$3" & + elif exists ueberzug; then + ueberzug_layer "$1" "$2" "$3" && return + elif exists catimg; then + catimg "$3" & + elif exists viu; then + viu -t "$3" & + else + fifo_pager print_bin_info "$3" && return + fi + printf "%s" "$!" > "$PREVIEWPID" +} + +ueberzug_layer() { + [ -f "$POSOFFSET" ] && read -r x y < "$POSOFFSET" + printf '{"action": "add", "identifier": "nnn_ueberzug", "x": %d, "y": %d, "width": "%d", "height": "%d", "scaler": "fit_contain", "path": "%s"}\n'\ + "${x:-0}" "${y:-0}" "$1" "$2" "$3" > "$FIFO_UEBERZUG" +} + +ueberzug_remove() { + printf '{"action": "remove", "identifier": "nnn_ueberzug"}\n' > "$FIFO_UEBERZUG" +} + +winch_handler() { + clear + pidkill "$PREVIEWPID" + if [ -p "$FIFO_UEBERZUG" ]; then + pkill -f "tail --follow $FIFO_UEBERZUG" + tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser json & + fi + preview_file "$(cat "$CURSEL")" +} + +preview_fifo() { + while read -r selection; do + if [ -n "$selection" ]; then + pidkill "$PREVIEWPID" + [ -p "$FIFO_UEBERZUG" ] && ueberzug_remove + [ "$selection" = "close" ] && break + preview_file "$selection" + printf "%s" "$selection" > "$CURSEL" + fi + done < "$NNN_FIFO" + sleep 0.1 # make sure potential preview by winch_handler is killed + pkill -P "$$" +} + +if [ "$PREVIEW_MODE" ]; then + if [ "$TERMINAL" != "kitty" ] && exists ueberzug; then + mkfifo "$FIFO_UEBERZUG" + tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser json & + fi + + preview_file "$PWD/$1" + preview_fifo & + printf "%s" "$!" > "$FIFOPID" + printf "%s" "$PWD/$1" > "$CURSEL" + trap 'winch_handler; wait' WINCH + trap 'rm "$PREVIEWPID" "$CURSEL" "$FIFO_UEBERZUG" "$FIFOPID" "$POSOFFSET" 2>/dev/null' INT HUP EXIT + wait "$!" 2>/dev/null + exit 0 +else + if [ ! -r "$NNN_FIFO" ]; then + clear + prompt "No FIFO available! (\$NNN_FIFO='$NNN_FIFO')\nPlease read Usage in preview-tui." + elif [ "$KITTY_WINDOW_ID" ] && [ -z "$TMUX" ] && [ -z "$KITTY_LISTEN_ON" ]; then + clear + prompt "\$KITTY_LISTEN_ON not set!\nPlease read Usage in preview-tui." + else + toggle_preview "$1" & + fi +fi diff --git a/.local/share/nnn/plugins/pskill b/.local/share/nnn/plugins/pskill new file mode 100755 index 0000000..e01c739 --- /dev/null +++ b/.local/share/nnn/plugins/pskill @@ -0,0 +1,35 @@ +#!/usr/bin/env sh + +# Description: Fuzzy list and kill a (zombie) process by name +# +# Dependencies: fzf, ps +# +# Note: To kill a zombie process enter "zombie" +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +printf "Enter process name ['defunct' for zombies]: " +read -r psname + +# shellcheck disable=SC2009 +if [ -n "$psname" ]; then + if type sudo >/dev/null 2>&1; then + sucmd=sudo + elif type doas >/dev/null 2>&1; then + sucmd=doas + else + sucmd=: # noop + fi + + if type fzf >/dev/null 2>&1; then + fuzzy=fzf + else + exit 1 + fi + + cmd="$(ps -ax | grep -iw "$psname" | "$fuzzy" | sed -e 's/^[ \t]*//' | cut -d' ' -f1)" + if [ -n "$cmd" ]; then + $sucmd kill -9 "$cmd" + fi +fi diff --git a/.local/share/nnn/plugins/renamer b/.local/share/nnn/plugins/renamer new file mode 100755 index 0000000..51c586e --- /dev/null +++ b/.local/share/nnn/plugins/renamer @@ -0,0 +1,45 @@ +#!/usr/bin/env sh + +# Description: Batch rename selection or current directory with qmv or vidir +# +# Notes: +# - Try to mimic current batch rename functionality but with correct +# handling of edge cases by qmv or vidir. +# - Qmv opens with hidden files if no selection is used. Selected +# directories are shown. +# - Vidir don't show directories nor hidden files. +# +# Shell: POSIX compliant +# Author: José Neder + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +if type qmv >/dev/null 2>&1; then + batchrenamesel="qmv -fdo -da" + batchrename="qmv -fdo -a" +elif type vidir >/dev/null 2>&1; then + batchrenamesel="vidir" + batchrename="vidir" +else + printf "there is not batchrename program installed." + exit +fi + +if [ -s "$selection" ]; then + printf "rename selection? " + read -r resp +fi + +if [ "$resp" = "y" ]; then + # -o flag is necessary for interactive editors + xargs -o -0 $batchrenamesel < "$selection" + + # Clear selection + if [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" + fi +elif [ ! "$(LC_ALL=C ls -a)" = ". +.." ]; then + # On older systems that don't have ls -A + $batchrename +fi diff --git a/.local/share/nnn/plugins/ringtone b/.local/share/nnn/plugins/ringtone new file mode 100755 index 0000000..c18f255 --- /dev/null +++ b/.local/share/nnn/plugins/ringtone @@ -0,0 +1,36 @@ +#!/usr/bin/env sh + +# Description: Create an mp3 ringtone out of an audio file in any format +# Needs user to provide start and end where to cut the file +# Input file audio.ext results in audio_ringtone.mp3 +# +# Tip: To convert a complete media file, set start as 0 and +# the runtime of the file as end. +# +# Dependencies: date, ffmpeg +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +if [ -n "$1" ]; then + printf "start (hh:mm:ss): " + read -r start + st=$(date -d "$start" +%s) || exit 1 + + printf "end (hh:mm:ss): " + read -r end + et=$(date -d "$end" +%s) || exit 1 + + if [ "$st" -ge "$et" ]; then + printf "error: start >= end " + read -r _ + exit 1 + fi + + interval=$(( et - st )) + + outfile=$(basename "$1") + outfile="${outfile%.*}"_ringtone.mp3 + + ffmpeg -i "$1" -ss "$start" -t "$interval" -vn -sn -acodec libmp3lame -q:a 2 "$outfile" +fi diff --git a/.local/share/nnn/plugins/rsynccp b/.local/share/nnn/plugins/rsynccp new file mode 100755 index 0000000..902f9e7 --- /dev/null +++ b/.local/share/nnn/plugins/rsynccp @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +# Description: Simple script to give copy-paste a progress percentage +# by utilizing rsync. +# +# LIMITATION: this won't work when pasting to MTP device. +# +# Dependencies: rsync +# +# Shell: POSIX compliant +# Author: Benawi Adha + +sel=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +# Choose one of these two schemes by commenting + +# more verbose +xargs -0 -I % rsync -ah --progress % "$PWD" < "$sel" + +# less verbose +# xargs -0 -I % rsync -ah --info=progress2 % "$PWD" < "$sel" + +# Clear selection +if [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" +fi diff --git a/.local/share/nnn/plugins/splitjoin b/.local/share/nnn/plugins/splitjoin new file mode 100755 index 0000000..5ba081b --- /dev/null +++ b/.local/share/nnn/plugins/splitjoin @@ -0,0 +1,52 @@ +#!/usr/bin/env sh + +# Description: Splits the file passed as argument or joins selection +# +# Note: Adds numeric suffix to split files +# Adds '.out suffix to the first file to be joined and saves as output file for join +# +# Shell: POSIX compliant +# Authors: Arun Prakash Jana, ath3 + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +resp=s + +if [ -s "$selection" ]; then + printf "press 's' (split current file) or 'j' (join selection): " + read -r resp +fi + +if [ "$resp" = "j" ]; then + if [ -s "$selection" ]; then + arr=$(tr '\0' '\n' < "$selection") + if [ "$(echo "$arr" | wc -l)" -lt 2 ]; then + echo "joining needs at least 2 files" + exit + fi + for entry in $arr + do + if [ -d "$entry" ]; then + echo "cant join directories" + exit + fi + done + + file="$(basename "$(echo "$arr" | sed -n '1p' | sed -e 's/[0-9][0-9]$//')")" + sort -z < "$selection" | xargs -0 -I{} cat {} > "${file}.out" + + # Clear selection + if [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" + fi + fi +elif [ "$resp" = "s" ]; then + if [ -n "$1" ] && [ -f "$1" ]; then + # a single file is passed + printf "split size in MB: " + read -r size + + if [ -n "$size" ]; then + split -d -b "$size"M "$1" "$1" + fi + fi +fi diff --git a/.local/share/nnn/plugins/suedit b/.local/share/nnn/plugins/suedit new file mode 100755 index 0000000..21dddf4 --- /dev/null +++ b/.local/share/nnn/plugins/suedit @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +# Description: Edit file as superuser +# +# Shell: POSIX compliant +# Author: Anna Arad + +EDITOR="${EDITOR:-vim}" + +if type sudo >/dev/null 2>&1; then + sudo -E "$EDITOR" "$1" +elif type sudoedit >/dev/null 2>&1; then + sudoedit -E "$1" +elif type doas >/dev/null 2>&1; then + doas "$EDITOR" "$1" +fi diff --git a/.local/share/nnn/plugins/togglex b/.local/share/nnn/plugins/togglex new file mode 100755 index 0000000..e42d65a --- /dev/null +++ b/.local/share/nnn/plugins/togglex @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +# Description: Toggles executable mode for selection +# +# Dependencies: chmod +# +# Note: Works _only_ with selection (nnn can toggle the mode for the hovered file) +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +if [ -s "$selection" ]; then + xargs -0 -I {} sh -c 'if [ -x "{}" ] ; then chmod -x "{}" ; else chmod +x "{}" ; fi' < "$selection" + + # Clear selection + if [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" + fi +fi diff --git a/.local/share/nnn/plugins/umounttree b/.local/share/nnn/plugins/umounttree new file mode 100755 index 0000000..011d74d --- /dev/null +++ b/.local/share/nnn/plugins/umounttree @@ -0,0 +1,52 @@ +#!/usr/bin/env sh + +# Description: Autodetects a nnn remote mountpoint (mounted with `c`) +# from any of its subfolders and allows unmounting it +# from the subdir without navigating to the mountppoint +# or entering the remote name. Also works when hovering +# the mountpoint directly like vanilla `u`. +# +# Dependencies: fusermount +# +# Shell: POSIX compliant +# Authors: Kabouik & 0xACE +# +# TODO: +# - Avoid lazy unmount by forcing nnn context to leave the subfolder before fusermount. +# Tried `printf "%s" "0c$m" > "$NNN_PIPE"` but it breaks the nnn interface, see #854. + +err=0 +m=$HOME/.config/nnn/mounts +if [ "$PWD" = "$m" ]; then + # Allow running the script on hovered directory if user is in ~/.config/nnn/mounts + d="$1" +else + d=$(dirname "$(readlink -f "$1")" | grep -oP "^$m\K.*" | cut -d"/" -f2) +fi + +# Test if user is within $m or a subdir, abort if not +if [ "$d" = "" ]; then + clear && printf "You are not in a remote folder mounted with nnn. Press return to continue. " && read -r _ +else + # Test if $m/$d is a mountpoint and try unmounting if it is + mountpoint -q -- "$m/$d" + if [ "$?" -eq "1" ]; then + clear && printf "Parent '%s' is not a mountpoint. Press return to continue. " "$d" && read -r _ + else + cd "$m" && fusermount -uq "$m/$d" || err=1 + if [ "$err" -eq "0" ]; then + rmdir "$m/$d" && clear && printf "Parent '%s' unmounted." "$d" + else + clear && printf "Failed to unmount. Try lazy unmount? [Yy/Nn] " && read -r + fi + fi +fi + +# If unmount fails, offer lazy unmount +if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then + err=0 + cd "$m" && fusermount -uqz "$m/$d" || err=1 + if [ "$err" -eq "0" ]; then + rmdir "$m/$d" && clear && printf "Parent '%s' unmounted with lazy unmount. " "$d" + fi +fi diff --git a/.local/share/nnn/plugins/upload b/.local/share/nnn/plugins/upload new file mode 100755 index 0000000..4948587 --- /dev/null +++ b/.local/share/nnn/plugins/upload @@ -0,0 +1,45 @@ +#!/usr/bin/env sh + +# Description: Selections are uploaded using Firefox Send +# For single files: +# Upload to Firefox Send if ffsend is found, else +# Paste contents of a text a file http://ix.io +# Upload a binary file to file.io +# +# Dependencies: ffsend (https://github.com/timvisee/ffsend), curl, jq, tr +# +# Note: Binary file set to expire after a week +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +if [ -s "$selection" ]; then + if type ffsend >/dev/null 2>&1; then + # File name will be randomized foo.tar + xargs -0 < "$selection" ffsend u + else + printf "ffsend is required to upload selection." + fi + + # Clear selection + printf "-" > "$NNN_PIPE" +else + if [ -n "$1" ] && [ -s "$1" ]; then + if type ffsend >/dev/null 2>&1; then + ffsend -fiq u "$1" + elif [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "text" ]; then + curl -F "f:1=@$1" ix.io + else + # Upload the file, show the download link and wait till user presses any key + curl -s -F "file=@$1" https://file.io/?expires=1w | jq '.link' | tr -d '"' + + # To write download link to "$1".loc and exit + # curl -s -F "file=@$1" https://file.io/?expires=1w -o `basename "$1"`.loc + fi + else + printf "empty file!" + fi +fi + +read -r _ diff --git a/.local/share/nnn/plugins/wallpaper b/.local/share/nnn/plugins/wallpaper new file mode 100755 index 0000000..2017fbd --- /dev/null +++ b/.local/share/nnn/plugins/wallpaper @@ -0,0 +1,37 @@ +#!/usr/bin/env sh + +# Description: Set the selected image as wallpaper. +# Uses nitrogen or pywal on X11, swww on wayland. +# +# Usage: Hover on an image and run the script to set it as wallpaper. +# +# Shell: POSIX compliant +# Author: juacq97 + +if [ -n "$1" ]; then + if [ "$(file --mime-type "$1" | awk '{print $NF}' | awk -F '/' '{print $1}')" = "image" ]; then + if [ "$XDG_SESSION_TYPE" = "x11" ]; then + if type nitrogen >/dev/null 2>&1; then + nitrogen --set-zoom-fill --save "$1" + elif type wal >/dev/null 2>&1; then + wal -i "$1" + else + printf "nitrogen or pywal missing" + read -r _ + fi + else + if type swww >/dev/null 2>&1; then + swww img "$1" + else + printf "swww missing" + read -r _ + fi + fi + + # If you want a system notification, uncomment the next 3 lines. + # notify-send -a "nnn" "Wallpaper changed!" + # else + # notify-send -a "nnn" "No image selected" + + fi +fi diff --git a/.local/share/nnn/plugins/x2sel b/.local/share/nnn/plugins/x2sel new file mode 100755 index 0000000..70104d7 --- /dev/null +++ b/.local/share/nnn/plugins/x2sel @@ -0,0 +1,62 @@ +#!/usr/bin/env sh + +# Description: Copy system clipboard newline-separated file list to selection +# +# Dependencies: +# - tr +# - xclip/xsel (Linux) +# - pbpaste (macOS) +# - termux-clipboard-get (Termux) +# - powershell (WSL) +# - cygwim's /dev/clipboard (Cygwin) +# - wl-paste (Wayland) +# - clipboard (Haiku) +# +# Note: +# - Limitation: breaks if a filename has newline in it +# +# Shell: POSIX compliant +# Author: Léo Villeveygoux, after Arun Prakash Jana's .cbcp + +IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +getclip () { + if type xsel >/dev/null 2>&1; then + # Linux + xsel -bo + elif type xclip >/dev/null 2>&1; then + # Linux + xclip -sel clip -o + elif type pbpaste >/dev/null 2>&1; then + # macOS + pbpaste + elif type termux-clipboard-get >/dev/null 2>&1; then + # Termux + termux-clipboard-get + elif type powershell.exe >/dev/null 2>&1; then + # WSL + powershell.exe Get-Clipboard + elif [ -r /dev/clipboard ] ; then + # Cygwin + cat /dev/clipboard + elif type wl-paste >/dev/null 2>&1; then + # Wayland + wl-paste + elif type clipboard >/dev/null 2>&1; then + # Haiku + clipboard --print + fi +} + +CLIPBOARD=$(getclip) + +# Check if clipboard actually contains a file list +for file in $CLIPBOARD ; do + if [ ! -e "$file" ] ; then + exit 1; + fi +done + +printf "%s" "$CLIPBOARD" | tr '\n' '\0' > "$selection" diff --git a/.local/share/nnn/plugins/xdgdefault b/.local/share/nnn/plugins/xdgdefault new file mode 100755 index 0000000..cf64a2f --- /dev/null +++ b/.local/share/nnn/plugins/xdgdefault @@ -0,0 +1,53 @@ +#!/usr/bin/env sh + +# Description: Sets the xdg-open's default application for the current entry's file +# type. ${XDG_DATA_DIRS} and ${XDG_DATA_HOME} are set to the recommended +# defaults if unset, as specified in XDG Base Directory Specification +# - http://specifications.freedesktop.org/basedir-spec/. +# +# Dependencies: xdg-utils, fzf or dmenu (GUI) +# +# Shell: POSIX compliant +# Author: lwnctd + +# set to 1 to enable GUI apps +GUI="${GUI:-0}" + +if [ "$GUI" -ne 0 ] && command -v dmenu > /dev/null 2>& 1; then + menu="dmenu -i -l 7" +elif command -v fzf > /dev/null 2>& 1; then + menu="fzf -e --tiebreak=begin" +fi + +if [ -z "$1" ] || [ -z "$menu" ] > /dev/null 2>& 1; then + exit 1 +fi + +ftype=$(xdg-mime query filetype "$2/$1") + +if [ -z "$ftype" ]; then + exit 1 +fi + +dirs=${XDG_DATA_DIRS:-/usr/local/share:/usr/share} +dirs=${dirs}:${XDG_DATA_HOME:-$HOME/.local/share}: + +while [ -n "$dirs" ]; do + d=${dirs%%:*} + if [ -n "$d" ] && [ -d "$d"/applications ]; then + set -- "$@" "$d"/applications + fi + dirs=${dirs#*:} +done + +app=$(find "$@" -iname '*.desktop' -exec grep '^Name=' {} + \ + | sort -u -t ':' -k 1,1 \ + | sed -e 's;..*/\(..*desktop\):Name=\(..*\);\2:\1;' \ + | sort -t ':' -k 1,1 \ + | column -t -s ':' -o "$(printf '\t')" \ + | $menu \ + | cut -f 2) + +if [ -n "$app" ]; then + xdg-mime default "${app%%[[:blank:]]*}" "$ftype" +fi diff --git a/.local/share/nnn/quitcd/quitcd.bash_zsh b/.local/share/nnn/quitcd/quitcd.bash_zsh new file mode 100644 index 0000000..2450b79 --- /dev/null +++ b/.local/share/nnn/quitcd/quitcd.bash_zsh @@ -0,0 +1,30 @@ +n () +{ + # Block nesting of nnn in subshells + if [[ "${NNNLVL:-0}" -ge 1 ]]; then + echo "nnn is already running" + return + fi + + # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set) + # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to + # see. To cd on quit only on ^G, remove the "export" and make sure not to + # use a custom path, i.e. set NNN_TMPFILE *exactly* as follows: + # NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" + export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" + + # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn + # stty start undef + # stty stop undef + # stty lwrap undef + # stty lnext undef + + # The backslash allows one to alias n to nnn if desired without making an + # infinitely recursive alias + \nnn "$@" + + if [ -f "$NNN_TMPFILE" ]; then + . "$NNN_TMPFILE" + rm -f "$NNN_TMPFILE" > /dev/null + fi +} diff --git a/.local/share/nnn/quitcd/quitcd.csh b/.local/share/nnn/quitcd/quitcd.csh new file mode 100644 index 0000000..72bd357 --- /dev/null +++ b/.local/share/nnn/quitcd/quitcd.csh @@ -0,0 +1,17 @@ +# NOTE: set NNN_TMPFILE correctly if you use 'XDG_CONFIG_HOME' + +# The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set) +# If NNN_TMPFILE is set to a custom path, it must be exported for nnn to see. +# To cd on quit only on ^G, set NNN_TMPFILE after the nnn invocation, and make +# sure not to use a custom path. +set NNN_TMPFILE=~/.config/nnn/.lastd + +# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn +# stty start undef +# stty stop undef +# stty lwrap undef +# stty lnext undef + +# The backslash allows one to alias n to nnn if desired without making an +# infinitely recursive alias +alias n '\nnn; source "$NNN_TMPFILE"; rm -f "$NNN_TMPFILE"' diff --git a/.local/share/nnn/quitcd/quitcd.elv b/.local/share/nnn/quitcd/quitcd.elv new file mode 100644 index 0000000..95c47a6 --- /dev/null +++ b/.local/share/nnn/quitcd/quitcd.elv @@ -0,0 +1,41 @@ +# Append this file to ~/.elvish/rc.elv (Elvish > 0.17.0) + +use path + +fn n {|@a| + # Block nesting of nnn in subshells + if (has-env NNNLVL) { + try { + if (>= $E:NNNLVL 1) { + echo "nnn is already running" + return + } + } catch e { + nop + } + } + + # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set) + # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to + # see. + if (has-env XDG_CONFIG_HOME) { + set-env NNN_TMPFILE $E:XDG_CONFIG_HOME/nnn/.lastd + } else { + set-env NNN_TMPFILE $E:HOME/.config/nnn/.lastd + } + + # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn + # stty start undef + # stty stop undef + # stty lwrap undef + # stty lnext undef + + # The e: prefix allows one to alias n to nnn if desired without making an + # infinitely recursive alias + e:nnn $@a + + if (path:is-regular $E:NNN_TMPFILE) { + eval (slurp < $E:NNN_TMPFILE) + rm $E:NNN_TMPFILE + } +} diff --git a/.local/share/nnn/quitcd/quitcd.fish b/.local/share/nnn/quitcd/quitcd.fish new file mode 100644 index 0000000..a8c3dc4 --- /dev/null +++ b/.local/share/nnn/quitcd/quitcd.fish @@ -0,0 +1,36 @@ +# Rename this file to match the name of the function +# e.g. ~/.config/fish/functions/n.fish +# or, add the lines to the 'config.fish' file. + +function n --wraps nnn --description 'support nnn quit and change directory' + # Block nesting of nnn in subshells + if test -n "$NNNLVL" -a "$NNNLVL" -ge 1 + echo "nnn is already running" + return + end + + # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set) + # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to + # see. To cd on quit only on ^G, remove the "-x" from both lines below, + # without changing the paths. + if test -n "$XDG_CONFIG_HOME" + set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd" + else + set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd" + end + + # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn + # stty start undef + # stty stop undef + # stty lwrap undef + # stty lnext undef + + # The command function allows one to alias this function to `nnn` without + # making an infinitely recursive alias + command nnn $argv + + if test -e $NNN_TMPFILE + source $NNN_TMPFILE + rm $NNN_TMPFILE + end +end diff --git a/.zsh/themes/bira.zsh-theme b/.zsh/themes/bira.zsh-theme deleted file mode 100644 index 42a70a0..0000000 --- a/.zsh/themes/bira.zsh-theme +++ /dev/null @@ -1,32 +0,0 @@ -local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" -local user_host="%B%(!.%{$fg[red]%}.%{$fg[green]%})%n@%m%{$reset_color%} " -local user_symbol='%(!.#.$)' -local current_dir="%B%{$fg[blue]%}%~ %{$reset_color%}" - -local vcs_branch='$(git_prompt_info)$(hg_prompt_info)' -local rvm_ruby='$(ruby_prompt_info)' -local venv_prompt='$(virtualenv_prompt_info)' - -ZSH_THEME_RVM_PROMPT_OPTIONS="i v g" - -PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt} -╰─%B${user_symbol}%b " -RPROMPT="%B${return_code}%b" - -ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹" -ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$fg[yellow]%}" -ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[yellow]%}" - -ZSH_THEME_HG_PROMPT_PREFIX="$ZSH_THEME_GIT_PROMPT_PREFIX" -ZSH_THEME_HG_PROMPT_SUFFIX="$ZSH_THEME_GIT_PROMPT_SUFFIX" -ZSH_THEME_HG_PROMPT_DIRTY="$ZSH_THEME_GIT_PROMPT_DIRTY" -ZSH_THEME_HG_PROMPT_CLEAN="$ZSH_THEME_GIT_PROMPT_CLEAN" - -ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}‹" -ZSH_THEME_RUBY_PROMPT_SUFFIX="› %{$reset_color%}" - -ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="%{$fg[green]%}‹" -ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX="› %{$reset_color%}" -ZSH_THEME_VIRTUALENV_PREFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX" -ZSH_THEME_VIRTUALENV_SUFFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX" diff --git a/.zsh/themes/powerlevel10k/.gitattributes b/.zsh/themes/powerlevel10k/.gitattributes deleted file mode 100644 index 41b2d3a..0000000 --- a/.zsh/themes/powerlevel10k/.gitattributes +++ /dev/null @@ -1,5 +0,0 @@ -* text=auto -*.zsh text eol=lf -*.zsh-theme text eol=lf -/prompt_powerlevel9k_setup text eol=lf -/prompt_powerlevel10k_setup text eol=lf diff --git a/.zsh/themes/powerlevel10k/.gitignore b/.zsh/themes/powerlevel10k/.gitignore deleted file mode 100644 index 416cfaa..0000000 --- a/.zsh/themes/powerlevel10k/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.zwc diff --git a/.zsh/themes/powerlevel10k/LICENSE b/.zsh/themes/powerlevel10k/LICENSE deleted file mode 100644 index 7986ede..0000000 --- a/.zsh/themes/powerlevel10k/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2009-2014 Robby Russell and contributors (see https://github.com/robbyrussell/oh-my-zsh/contributors) -Copyright (c) 2014-2017 Ben Hilburn <bhilburn@gmail.com> -Copyright (c) 2019 Roman Perepelitsa <roman.perepelitsa@gmail.com> and contributors (see https://github.com/romkatv/powerlevel10k/contributors) - -MIT LICENSE - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.zsh/themes/powerlevel10k/Makefile b/.zsh/themes/powerlevel10k/Makefile deleted file mode 100644 index 86e55ee..0000000 --- a/.zsh/themes/powerlevel10k/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -ZSH := $(shell command -v zsh 2> /dev/null) - -all: - -zwc: - $(MAKE) -C gitstatus zwc - $(or $(ZSH),:) -fc 'for f in *.zsh-theme internal/*.zsh; do zcompile -R -- $$f.zwc $$f || exit; done' - -minify: - $(MAKE) -C gitstatus minify - rm -rf -- .git .gitattributes .gitignore LICENSE Makefile README.md font.md powerlevel10k.png - -pkg: zwc - $(MAKE) -C gitstatus pkg diff --git a/.zsh/themes/powerlevel10k/README.md b/.zsh/themes/powerlevel10k/README.md deleted file mode 100644 index bd27a04..0000000 --- a/.zsh/themes/powerlevel10k/README.md +++ /dev/null @@ -1,2010 +0,0 @@ -# Powerlevel10k -[![Gitter](https://badges.gitter.im/powerlevel10k/community.svg)]( - https://gitter.im/powerlevel10k/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - -Powerlevel10k is a theme for Zsh. It emphasizes [speed](#uncompromising-performance), -[flexibility](#extremely-customizable) and [out-of-the-box experience](#configuration-wizard). - -![Powerlevel10k]( -https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/prompt-styles-high-contrast.png) - -- [Getting started](#getting-started) -- [Features](#features) -- [Installation](#installation) -- [Configuration](#configuration) -- [Fonts](#fonts) -- [Try it in Docker](#try-it-in-docker) -- [License](#license) -- [FAQ](#faq) -- [Troubleshooting](#troubleshooting) - -## Getting started - -1. [Install the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). *Optional but highly - recommended.* -1. [Install Powerlevel10k](#installation) itself. -1. Restart Zsh with `exec zsh`. -1. Type `p10k configure` if the configuration wizard doesn't start automatically. - -## Features - -- [Configuration wizard](#configuration-wizard) -- [Uncompromising performance](#uncompromising-performance) -- [Powerlevel9k compatibility](#powerlevel9k-compatibility) -- [Pure compatibility](#pure-compatibility) -- [Instant prompt](#instant-prompt) -- [Show on command](#show-on-command) -- [Transient prompt](#transient-prompt) -- [Current directory that just works](#current-directory-that-just-works) -- [Extremely customizable](#extremely-customizable) -- [Batteries included](#batteries-included) -- [Extensible](#extensible) - -### Configuration wizard - -Type `p10k configure` to access the builtin configuration wizard right from your terminal. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Configuration Wizard]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/configuration-wizard.gif) -</details> - -All styles except [Pure](#pure-compatibility) are functionally equivalent. They display the same -information and differ only in presentation. - -Configuration wizard creates `~/.p10k.zsh` based on your preferences. Additional prompt -customization can be done by editing this file. It has plenty of comments to help you navigate -through configuration options. - -*Tip*: Install [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k) before -running `p10k configure` to unlock all prompt styles. - -*FAQ:* - -- [What is the best prompt style in the configuration wizard?]( - #what-is-the-best-prompt-style-in-the-configuration-wizard) -- [What do different symbols in Git status mean?]( - #what-do-different-symbols-in-git-status-mean) -- [How do I change prompt colors?](#how-do-i-change-prompt-colors) - -*Troubleshooting*: - -- [Some prompt styles are missing from the configuration wizard]( - #some-prompt-styles-are-missing-from-the-configuration-wizard). -- [Question mark in prompt](#question-mark-in-prompt). -- [Icons, glyphs or powerline symbols don't render](#icons-glyphs-or-powerline-symbols-dont-render). -- [Sub-pixel imperfections around powerline symbols]( - #sub-pixel-imperfections-around-powerline-symbols). -- [Directory is difficult to see in prompt when using Rainbow style]( - #directory-is-difficult-to-see-in-prompt-when-using-rainbow-style). - -### Uncompromising performance - -When you hit *ENTER*, the next prompt appears instantly. With Powerlevel10k there is no prompt lag. -If you install Cygwin on Raspberry Pi, `cd` into a Linux Git repository and activate enough prompt -segments to fill four prompt lines on both sides of the screen... wait, that's just crazy and no -one ever does that. Probably impossible, too. The point is, Powerlevel10k prompt is always fast, no -matter what you do! - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Performance]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/performance.gif) -</details> - -Note how the effect of every command is instantly reflected by the very next prompt. - -| Command | Prompt Indicator | Meaning | -|-------------------------------|:----------------:|----------------------------------------------------------------------:| -| `timew start hack linux` | `⌚ hack linux` | time tracking enabled in [timewarrior](https://timewarrior.net/) | -| `touch x y` | `?2` | 2 untracked files in the Git repo | -| `rm COPYING` | `!1` | 1 unstaged change in the Git repo | -| `echo 3.7.3 >.python-version` | `🐍 3.7.3` | the current python version in [pyenv](https://github.com/pyenv/pyenv) | - -Other Zsh themes capable of displaying the same information either produce prompt lag or print -prompt that doesn't reflect the current state of the system and then refresh it later. With -Powerlevel10k you get fast prompt *and* up-to-date information. - -*FAQ*: [Is it really fast?](#is-it-really-fast) - -### Powerlevel9k compatibility - -Powerlevel10k understands all [Powerlevel9k](https://github.com/Powerlevel9k/powerlevel9k) -configuration parameters. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Compatibility with 9k]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/9k-compatibility.gif) -</details> - -[Migration](#installation) from Powerlevel9k to Powerlevel10k is a straightforward process. All -your `POWERLEVEL9K` configuration parameters will still work. Prompt will look the same as before -([almost]( - #does-powerlevel10k-always-render-exactly-the-same-prompt-as-powerlevel9k-given-the-same-config)) -but it will be [much faster](#uncompromising-performance) ([certainly](#is-it-really-fast)). - -*FAQ*: - -- [I'm using Powerlevel9k with Oh My Zsh. How do I migrate?]( - #im-using-powerlevel9k-with-oh-my-zsh-how-do-i-migrate) -- [Does Powerlevel10k always render exactly the same prompt as Powerlevel9k given the same config?]( - #does-powerlevel10k-always-render-exactly-the-same-prompt-as-powerlevel9k-given-the-same-config) -- [What is the relationship between Powerlevel9k and Powerlevel10k?]( - #What-is-the-relationship-between-powerlevel9k-and-powerlevel10k) - -### Pure compatibility - -Powerlevel10k can produce the same prompt as [Pure](https://github.com/sindresorhus/pure). Type -`p10k configure` and select *Pure* style. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Pure Style]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/pure-style.gif) -</details> - -You can still use Powerlevel10k features such as [transient prompt](#transient-prompt) or -[instant prompt](#instant-prompt) when sporting Pure style. - -To customize prompt, edit `~/.p10k.zsh`. Powerlevel10k doesn't recognize Pure configuration -parameters, so you'll need to use `POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3` instead of -`PURE_CMD_MAX_EXEC_TIME=3`, etc. All relevant parameters are in `~/.p10k.zsh`. This file has -plenty of comments to help you navigate through it. - -*FAQ:* [What is the best prompt style in the configuration wizard?]( - #what-is-the-best-prompt-style-in-the-configuration-wizard) - -### <a name='what-is-instant-prompt'></a>Instant prompt - -If your `~/.zshrc` loads many plugins, or perhaps just a few slow ones -(for example, [pyenv](https://github.com/pyenv/pyenv) or [nvm](https://github.com/nvm-sh/nvm)), you -may have noticed that it takes some time for Zsh to start. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k No Instant Prompt]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/no-instant-prompt.gif) -</details> - -Powerlevel10k can remove Zsh startup lag **even if it's not caused by a theme**. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Instant Prompt]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/instant-prompt.gif) -</details> - -This feature is called *Instant Prompt*. You need to explicitly enable it through `p10k configure` -or [manually](#how-do-i-configure-instant-prompt). It does what it says on the tin -- prints prompt -instantly upon Zsh startup allowing you to start typing while plugins are still loading. - -Other themes *increase* Zsh startup lag -- some by a lot, others by a just a little. Powerlevel10k -*removes* it outright. - -If you are curious about how *Instant Prompt* works, see -[this section in zsh-bench](https://github.com/romkatv/zsh-bench#instant-prompt). - -*FAQ:* [How do I configure instant prompt?](#how-do-i-configure-instant-prompt) - -### Show on command - -The behavior of some commands depends on global environment. For example, `kubectl run ...` runs an -image on the cluster defined by the current kubernetes context. If you frequently change context -between "prod" and "testing", you might want to display the current context in Zsh prompt. If you do -likewise for AWS, Azure and Google Cloud credentials, prompt will get pretty crowded. - -Enter *Show On Command*. This feature makes prompt segments appear only when they are relevant to -the command you are currently typing. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Show On Command]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/show-on-command.gif) -</details> - -Configs created by `p10k configure` enable show on command for several prompt segments by default. -Here's the relevant parameter for kubernetes context: - -```zsh -# Show prompt segment "kubecontext" only when the command you are typing -# invokes kubectl, helm, kubens, kubectx, oc, istioctl, kogito, k9s, helmfile, flux, fluxctl, stern, kubeseal, or skaffold. -typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold' -``` - -To customize when different prompt segments are shown, open `~/.p10k.zsh`, search for -`SHOW_ON_COMMAND` and either remove these parameters to display affected segments unconditionally, -or change their values. - -### Transient prompt - -When *Transient Prompt* is enabled through `p10k configure`, Powerlevel10k will trim down every -prompt when accepting a command line. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Transient Prompt]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/transient-prompt.gif) -</details> - -Transient prompt makes it much easier to copy-paste series of commands from the terminal scrollback. - -*Tip*: If you enable transient prompt, take advantage of two-line prompt. You'll get the benefit of -extra space for typing commands without the usual drawback of reduced scrollback density. Sparse -prompt (with an empty line before prompt) also works great in combination with transient prompt. - -### Current directory that just works - -The current working directory is perhaps the most important prompt segment. Powerlevel10k goes to -great length to highlight its important parts and to truncate it with the least loss of information -when horizontal space gets scarce. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Directory Truncation]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/directory-truncation.gif) -</details> - -When the full directory doesn't fit, the leftmost segment gets truncated to its shortest unique -prefix. In the screencast, `~/work` becomes `~/wo`. It couldn't be truncated to `~/w` because it -would be ambiguous (there was `~/wireguard` when the session was recorded). The next segment -- -`projects` -- turns into `p` as there was nothing else that started with `p` in `~/work/`. - -Directory segments are shown in one of three colors: - -- Truncated segments are bleak. -- Important segments are bright and never truncated. These include the first and the last segment, - roots of Git repositories, etc. -- Regular segments (not truncated but can be) use in-between color. - -*Tip*: If you copy-paste a truncated directory and hit *TAB*, it'll complete to the original. - -*Troubleshooting*: [Directory is difficult to see in prompt when using Rainbow style.]( - #directory-is-difficult-to-see-in-prompt-when-using-rainbow-style) - -### Extremely customizable - -Powerlevel10k can be configured to look like any other Zsh theme out there. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Other Theme Emulation]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/other-theme-emulation.gif) -</details> - -[Pure](#pure-compatibility), [Powerlevel9k](#powerlevel9k-compatibility) and [robbyrussell]( - #how-to-make-powerlevel10k-look-like-robbyrussell-oh-my-zsh-theme) emulations are built-in. -To emulate the appearance of other themes, you'll need to write a suitable configuration file. The -best way to go about it is to run `p10k configure`, select the style that is the closest to your -goal and then edit `~/.p10k.zsh`. - -The full range of Powerlevel10k appearance spans from spartan: - -![Powerlevel10k Spartan Style]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/spartan-style.png) - -To ~~ridiculous~~ extravagant: - -![Powerlevel10k Extravagant Style]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/extravagant-style.png) - -### Batteries included - -Powerlevel10k comes with dozens of built-in high quality segments. When you run `p10k configure` -and choose any style except [Pure](#pure-compatibility), many of these segments get enabled by -default while others can be manually enabled by opening `~/.p10k.zsh` and uncommenting them. You can -enable as many segments as you like. It won't slow down your prompt or Zsh startup. - -| Segment | Meaning | -|--------:|---------| -| `anaconda` | virtual environment from [conda](https://conda.io/) | -| `asdf` | tool versions from [asdf](https://github.com/asdf-vm/asdf) | -| `aws` | [aws profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) | -| `aws_eb_env` | [aws elastic beanstalk](https://aws.amazon.com/elasticbeanstalk/) environment | -| `azure` | [azure](https://docs.microsoft.com/en-us/cli/azure) account name | -| `background_jobs` | presence of background jobs | -| `battery` | internal battery state and charge level (yep, batteries *literally* included) | -| `command_execution_time` | duration (wall time) of the last command | -| `context` | user@hostname | -| `dir` | current working directory | -| `direnv` | [direnv](https://direnv.net/) status | -| `disk_usage` | disk usage | -| `dotnet_version` | [dotnet](https://dotnet.microsoft.com) version | -| `fvm` | flutter environment from [fvm](https://github.com/leoafarias/fvm) | -| `gcloud` | [google cloud](https://cloud.google.com/) cli account and project | -| `goenv` | go environment from [goenv](https://github.com/syndbg/goenv) | -| `google_app_cred` | [google application credentials](https://cloud.google.com/docs/authentication/production) | -| `go_version` | [go](https://golang.org) version | -| `haskell_stack` | haskell version from [stack](https://haskellstack.org/) | -| `ip` | IP address and bandwidth usage for a specified network interface | -| `java_version` | [java](https://www.java.com/) version | -| `jenv` | java environment from [jenv](https://github.com/jenv/jenv) | -| `kubecontext` | current [kubernetes](https://kubernetes.io/) context | -| `laravel_version` | [laravel php framework](https://laravel.com/) version | -| `load` | CPU load | -| `luaenv` | lua environment from [luaenv](https://github.com/cehoffman/luaenv) | -| `midnight_commander` | [midnight commander](https://midnight-commander.org/) shell | -| `nix_shell` | [nix shell](https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) indicator | -| `nnn` | [nnn](https://github.com/jarun/nnn) shell | -| `nodeenv` | node.js environment from [nodeenv](https://github.com/ekalinin/nodeenv) | -| `nodenv` | node.js environment from [nodenv](https://github.com/nodenv/nodenv) | -| `node_version` | [node.js](https://nodejs.org/) version | -| `nordvpn` | [nordvpn](https://nordvpn.com/) connection status | -| `nvm` | node.js environment from [nvm](https://github.com/nvm-sh/nvm) | -| `os_icon` | your OS logo (apple for macOS, swirl for debian, etc.) | -| `package` | `name@version` from [package.json](https://docs.npmjs.com/files/package.json) | -| `perlbrew` | perl version from [perlbrew](https://github.com/gugod/App-perlbrew) | -| `phpenv` | php environment from [phpenv](https://github.com/phpenv/phpenv) | -| `php_version` | [php](https://www.php.net/) version | -| `plenv` | perl environment from [plenv](https://github.com/tokuhirom/plenv) | -| `prompt_char` | multi-functional prompt symbol; changes depending on vi mode: `❯`, `❮`, `V`, `▶` for insert, command, visual and replace mode respectively; turns red on error | -| `proxy` | system-wide http/https/ftp proxy | -| `public_ip` | public IP address | -| `pyenv` | python environment from [pyenv](https://github.com/pyenv/pyenv) | -| `ram` | free RAM | -| `ranger` | [ranger](https://github.com/ranger/ranger) shell | -| `rbenv` | ruby environment from [rbenv](https://github.com/rbenv/rbenv) | -| `rust_version` | [rustc](https://www.rust-lang.org) version | -| `rvm` | ruby environment from [rvm](https://rvm.io) | -| `scalaenv` | scala version from [scalaenv](https://github.com/scalaenv/scalaenv) | -| `status` | exit code of the last command | -| `swap` | used swap | -| `taskwarrior` | [taskwarrior](https://taskwarrior.org/) task count | -| `terraform` | [terraform](https://www.terraform.io) workspace | -| `terraform_version` | [terraform](https://www.terraform.io) version | -| `time` | current time | -| `timewarrior` | [timewarrior](https://timewarrior.net/) tracking status | -| `todo` | [todo](https://github.com/todotxt/todo.txt-cli) items | -| `toolbox` | [toolbox](https://github.com/containers/toolbox) name | -| `vcs` | Git repository status | -| `vim_shell` | [vim](https://www.vim.org/) shell (`:sh`) | -| `virtualenv` | python environment from [venv](https://docs.python.org/3/library/venv.html) | -| `vi_mode` | vi mode (you don't need this if you've enabled prompt_char) | -| `vpn_ip` | virtual private network indicator | -| `wifi` | WiFi speed | -| `xplr` | [xplr](https://github.com/sayanarijit/xplr) shell | - -### Extensible - -If there is no prompt segment that does what you need, implement your own. Powerlevel10k provides -public API for defining segments that are as fast and as flexible as built-in ones. - -<details> - <summary>Screen recording</summary> - - ![Powerlevel10k Custom Segment]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/custom-segment.gif) -</details> - -On Linux you can fetch current CPU temperature by reading `/sys/class/thermal/thermal_zone0/temp`. -The screencast shows how to define a prompt segment to display this value. Once the segment is -defined, you can use it like any other segment. All standard customization parameters will work for -it out of the box. - -Type `p10k help segment` for reference. - -*Tip*: Prefix names of your own segments with `my_` to avoid clashes with future versions of -Powerlevel10k. - -## Installation - -- [Manual](#manual) 👈 **choose this if confused or uncertain** -- [Oh My Zsh](#oh-my-zsh) -- [Prezto](#prezto) -- [Zim](#zim) -- [Antibody](#antibody) -- [Antidote](#antidote) -- [Antigen](#antigen) -- [Zplug](#zplug) -- [Zgen](#zgen) -- [Zplugin](#zplugin) -- [Zinit](#zinit) -- [Zi](#zi) -- [Zap](#zap) -- [Homebrew](#homebrew) -- [Arch Linux](#arch-linux) -- [Alpine Linux](#arch-linux) -- [Fig](#fig) - -### Manual - -```zsh -git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k -echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc -``` - -Users in China can use the official mirror on gitee.com for faster download.<br> -中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. - -```zsh -git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/powerlevel10k -echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc -``` - -This is the simplest kind of installation and it works even if you are using a plugin manager. Just -make sure to disable the current theme in your plugin manager. See -[troubleshooting](#cannot-make-powerlevel10k-work-with-my-plugin-manager) for help. - -### Oh My Zsh - -1. Clone the repository: - ```zsh - git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k - ``` - Users in China can use the official mirror on gitee.com for faster download.<br> - 中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. - - ```zsh - git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k - ``` -2. Set `ZSH_THEME="powerlevel10k/powerlevel10k"` in `~/.zshrc`. - -### Prezto - -Add `zstyle :prezto:module:prompt theme powerlevel10k` to `~/.zpreztorc`. - -### Zim - -Add `zmodule romkatv/powerlevel10k --use degit` to `~/.zimrc` and run `zimfw install`. - -### Antibody - -Add `antibody bundle romkatv/powerlevel10k` to `~/.zshrc`. - -### Antidote - -Add `romkatv/powerlevel10k` to `~/.zsh_plugins.txt`. - -### Antigen - -Add `antigen theme romkatv/powerlevel10k` to `~/.zshrc`. Make sure you have `antigen apply` -somewhere after it. - -### Zplug - -Add `zplug romkatv/powerlevel10k, as:theme, depth:1` to `~/.zshrc`. - -### Zgen - -Add `zgen load romkatv/powerlevel10k powerlevel10k` to `~/.zshrc`. - -### Zplugin - -Add `zplugin ice depth=1; zplugin light romkatv/powerlevel10k` to `~/.zshrc`. - -The use of `depth=1` ice is optional. Other types of ice are neither recommended nor officially -supported by Powerlevel10k. - -### Zinit - -Add `zinit ice depth=1; zinit light romkatv/powerlevel10k` to `~/.zshrc`. - -The use of `depth=1` ice is optional. Other types of ice are neither recommended nor officially -supported by Powerlevel10k. - -### Zi - -Add `zi ice depth=1; zi light romkatv/powerlevel10k` to `~/.zshrc`. - -The use of `depth=1` ice is optional. Other types of ice are neither recommended nor officially -supported by Powerlevel10k. - -### Zap - -Add `plug "romkatv/powerlevel10k"` to `~/.zshrc`. - -### Homebrew - -```zsh -brew install romkatv/powerlevel10k/powerlevel10k -echo "source $(brew --prefix)/opt/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc -``` - -### Arch Linux - -```zsh -yay -S --noconfirm zsh-theme-powerlevel10k-git -echo 'source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc -``` - -[zsh-theme-powerlevel10k-git](https://aur.archlinux.org/packages/zsh-theme-powerlevel10k-git/) -referenced above is the official Powerlevel10k package. - -There is also [zsh-theme-powerlevel10k]( - https://www.archlinux.org/packages/community/x86_64/zsh-theme-powerlevel10k/) community package. -Historically, [it has been breaking often and for extended periods of time]( - https://github.com/romkatv/powerlevel10k/pull/786). **Do not use it.** - -### Alpine Linux - -```zsh -apk add zsh zsh-theme-powerlevel10k -mkdir -p ~/.local/share/zsh/plugins -ln -s /usr/share/zsh/plugins/powerlevel10k ~/.local/share/zsh/plugins/ -``` - -### Fig - -Follow the instructions on -[this page](https://fig.io/plugins/other/powerlevel10k). - -## Configuration - -- [For new users](#for-new-users) -- [For Powerlevel9k users](#for-powerlevel9k-users) - -### For new users - -On the first run, Powerlevel10k [configuration wizard](#configuration-wizard) will ask you a few -questions and configure your prompt. If it doesn't trigger automatically, type `p10k configure`. -Configuration wizard creates `~/.p10k.zsh` based on your preferences. Additional prompt -customization can be done by editing this file. It has plenty of comments to help you navigate -through configuration options. - -*FAQ*: - -- [What is the best prompt style in the configuration wizard?]( - #what-is-the-best-prompt-style-in-the-configuration-wizard) -- [What do different symbols in Git status mean?]( - #what-do-different-symbols-in-git-status-mean) -- [How do I change the format of Git status?](#how-do-i-change-the-format-of-git-status) -- [How do I add username and/or hostname to prompt?]( - #how-do-i-add-username-andor-hostname-to-prompt) -- [How do I change prompt colors?](#how-do-i-change-prompt-colors) -- [Why some prompt segments appear and disappear as I'm typing?]( - #why-some-prompt-segments-appear-and-disappear-as-im-typing) - -*Troubleshooting*: - -- [Question mark in prompt](#question-mark-in-prompt). -- [Icons, glyphs or powerline symbols don't render](#icons-glyphs-or-powerline-symbols-dont-render). -- [Sub-pixel imperfections around powerline symbols]( - #sub-pixel-imperfections-around-powerline-symbols). -- [Directory is difficult to see in prompt when using Rainbow style]( - #directory-is-difficult-to-see-in-prompt-when-using-rainbow-style). - -### For Powerlevel9k users - -If you've been using Powerlevel9k before, **do not remove the configuration options**. Powerlevel10k -will pick them up and provide you with the same prompt UI you are used to. See -[Powerlevel9k compatibility](#powerlevel9k-compatibility). - -*FAQ*: - -- [I'm using Powerlevel9k with Oh My Zsh. How do I migrate?]( - #im-using-powerlevel9k-with-oh-my-zsh-how-do-i-migrate) -- [What is the relationship between Powerlevel9k and Powerlevel10k?]( - #what-is-the-relationship-between-powerlevel9k-and-powerlevel10k) -- [Does Powerlevel10k always render exactly the same prompt as Powerlevel9k given the same config?]( - #does-powerlevel10k-always-render-exactly-the-same-prompt-as-powerlevel9k-given-the-same-config) - -*Troubleshooting*: [Extra or missing spaces in prompt compared to Powerlevel9k]( - #extra-or-missing-spaces-in-prompt-compared-to-powerlevel9k). - -## Fonts - -Powerlevel10k doesn't require custom fonts but can take advantage of them if they are available. -It works well with [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts), -[Source Code Pro](https://github.com/adobe-fonts/source-code-pro), -[Font Awesome](https://fontawesome.com/), [Powerline](https://github.com/powerline/fonts), and even -the default system fonts. The full choice of style options is available only when using -[Nerd Fonts](https://github.com/ryanoasis/nerd-fonts). - -👇 **Recommended font**: Meslo Nerd Font patched for Powerlevel10k. 👇 - -### <a name='recommended-meslo-nerd-font-patched-for-powerlevel10k'></a><a name='font'></a>Meslo Nerd Font patched for Powerlevel10k - -Gorgeous monospace font designed by Jim Lyles for Bitstream, customized by the same for Apple, -further customized by André Berg, and finally patched by yours truly with customized scripts -originally developed by Ryan L McIntyre of Nerd Fonts. Contains all glyphs and symbols that -Powerlevel10k may need. Battle-tested in dozens of different terminals on all major operating -systems. - -*FAQ*: [How was the recommended font created?](#how-was-the-recommended-font-created) - -#### Automatic font installation - -If you are using iTerm2 or Termux, `p10k configure` can install the recommended font for you. -Simply answer `Yes` when asked whether to install *Meslo Nerd Font*. - -If you are using a different terminal, proceed with manual font installation. 👇 - -#### Manual font installation - -1. Download these four ttf files: - - [MesloLGS NF Regular.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf) - - [MesloLGS NF Bold.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf) - - [MesloLGS NF Italic.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf) - - [MesloLGS NF Bold Italic.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf) -1. Double-click on each file and click "Install". This will make `MesloLGS NF` font available to all - applications on your system. -1. Configure your terminal to use this font: - - **iTerm2**: Type `p10k configure` and answer `Yes` when asked whether to install - *Meslo Nerd Font*. Alternatively, open *iTerm2 → Preferences → Profiles → Text* and set *Font* to - `MesloLGS NF`. - - **Apple Terminal**: Open *Terminal → Preferences → Profiles → Text*, click *Change* under *Font* - and select `MesloLGS NF` family. - - **Hyper**: Open *Hyper → Edit → Preferences* and change the value of `fontFamily` under - `module.exports.config` to `MesloLGS NF`. - - **Visual Studio Code**: Open *File → Preferences → Settings* (PC) or - *Code → Preferences → Settings* (Mac), enter `terminal.integrated.fontFamily` in the search box at - the top of *Settings* tab and set the value below to `MesloLGS NF`. - Consult [this screenshot]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/389133fb8c9a2347929a23702ce3039aacc46c3d/visual-studio-code-font-settings.jpg) - to see how it should look like or see [this issue]( - https://github.com/romkatv/powerlevel10k/issues/671) for extra information. - - **GNOME Terminal** (the default Ubuntu terminal): Open *Terminal → Preferences* and click on the - selected profile under *Profiles*. Check *Custom font* under *Text Appearance* and select - `MesloLGS NF Regular`. - - **Konsole**: Open *Settings → Edit Current Profile → Appearance*, click *Select Font* and select - `MesloLGS NF Regular`. - - **Tilix**: Open *Tilix → Preferences* and click on the selected profile under *Profiles*. Check - *Custom font* under *Text Appearance* and select `MesloLGS NF Regular`. - - **Windows Console Host** (the old thing): Click the icon in the top left corner, then - *Properties → Font* and set *Font* to `MesloLGS NF`. - - **Windows Terminal** by Microsoft (the new thing): Open *Settings* (<kbd>Ctrl+,</kbd>), click - either on the selected profile under *Profiles* or on *Defaults*, click *Appearance* and set - *Font face* to `MesloLGS NF`. - - **IntelliJ** (and other IDEs by Jet Brains): Open *IDE → Edit → Preferences → Editor → - Color Scheme → Console Font*. Select *Use console font instead of the default* and set the font - name to `MesloLGS NF`. - - **Termux**: Type `p10k configure` and answer `Yes` when asked whether to install - *Meslo Nerd Font*. - - **Blink**: Type `config`, go to *Appearance*, tap *Add a new font*, tap *Open Gallery*, select - *MesloLGS NF.css*, tap *import* and type `exit` in the home view to reload the font. - - **Terminus**: Open *Settings → Appearance* and set *Font* to `MesloLGS NF`. - - **Terminator**: Open *Preferences* using the context menu. Under *Profiles* select the *General* - tab (should be selected already), uncheck *Use the system fixed width font* (if not already) - and select `MesloLGS NF Regular`. Exit the Preferences dialog by clicking *Close*. - - **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance* - tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`. - Exit the Preferences dialog by clicking *Close*. - - **MobaXterm**: Open *Settings* → *Configuration* → *Terminal* → (under *Terminal look and feel*) - and change *Font* to `MesloLGS NF`. - - **Asbrú Connection Manager**: Open *Preferences → Local Shell Options → Look and Feel*, enable - *Use these personal options* and change *Font:* under *Terminal UI* to `MesloLGS NF Regular`. - To change the font for the remote host connections, go to *Preferences → Terminal Options → - Look and Feel* and change *Font:* under *Terminal UI* to `MesloLGS NF Regular`. - - **WSLtty**: Right click on an open terminal and then on *Options*. In the *Text* section, under - *Font*, click *"Select..."* and set Font to `MesloLGS NF Regular`. - - **Yakuake**: Click *≡* → *Manage Profiles* → *New* → *Appearance*. Click *Choose* next to the - *Font* dropdown, select `MesloLGS NF` and click *OK*. Click *OK* to save the profile. Select the - new profile and click *Set as Default*. - - **Alacritty**: Create or open `~/.config/alacritty/alacritty.yml` and add the following section - to it: - ```yaml - font: - normal: - family: "MesloLGS NF" - ``` - - **kitty**: Create or open `~/.config/kitty/kitty.conf` and add the following line to it: - ```text - font_family MesloLGS NF - ``` - Restart kitty by closing all sessions and opening a new session. - - **puTTY**: Set *Window* → *Appearance* → *Font* to `MesloLGS NF`. Requires puTTY - version >= 0.75. - - **WezTerm**: Create or open `$HOME/.config/wezterm/wezterm.lua` and add the following: - ```lua - local wezterm = require 'wezterm'; - return { - font = wezterm.font("MesloLGS NF"), - } - ``` - If the file already exists, only add the line with the font to the existing return. - Also add the first line if it is not already present. - - **urxvt**: Create or open `~/.Xresources` and add the following line to it: - ```text - URxvt.font: xft:MesloLGS NF:size=11 - ``` - You can adjust the font size to your preference. After changing the config run - `xrdb ~/.Xresources` to reload it. The new config is applied to all new terminals. - - **xterm**: Create or open `~/.Xresources` and add the following line to it: - ```text - xterm*faceName: MesloLGS NF - ``` - After changing the config run `xrdb ~/.Xresources` to reload it. The new config is applied to - all new terminals. - - Crostini (Linux on Chrome OS): Open - chrome-untrusted://terminal/html/nassh_preferences_editor.html, set *Text font family* to - `'MesloLGS NF'` (including the quotes) and *Custom CSS (inline text)* to the following: - ```css - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Regular.ttf"); - font-weight: normal; - font-style: normal; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold.ttf"); - font-weight: bold; - font-style: normal; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Italic.ttf"); - font-weight: normal; - font-style: italic; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold%20Italic.ttf"); - font-weight: bold; - font-style: italic; - } - ``` - **_CAVEAT_**: If you open the normal terminal preferences these settings will be overwritten. -1. Run `p10k configure` to generate a new `~/.p10k.zsh`. The old config may work - incorrectly with the new font. - -_Using a different terminal and know how to set the font for it? Share your knowledge by sending a -PR to expand the list!_ - -## Try it in Docker - -Try Powerlevel10k in Docker. You can safely make any changes to the file system while trying out -the theme. Once you exit Zsh, the image is deleted. - -```zsh -docker run -e TERM -e COLORTERM -e LC_ALL=C.UTF-8 -it --rm alpine sh -uec ' - apk add git zsh nano vim - git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k - echo "source ~/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc - cd ~/powerlevel10k - exec zsh' -``` - -*Tip*: Install [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k) before -running the Docker command to get access to all prompt styles. - -*Tip*: Run `p10k configure` while in Docker to try a different prompt style. - -## License - -Powerlevel10k is released under the -[MIT license](https://github.com/romkatv/powerlevel10k/blob/master/LICENSE). - -## FAQ - -- [How do I update Powerlevel10k?](#how-do-i-update-powerlevel10k) -- [How do I uninstall Powerlevel10k?](#how-do-i-uninstall-powerlevel10k) -- [How do I install Powerlevel10k on a machine without Internet access?](#how-do-i-install-powerlevel10k-on-a-machine-without-internet-access) -- [Where can I ask for help and report bugs?](#where-can-i-ask-for-help-and-report-bugs) -- [Which aspects of shell and terminal does Powerlevel10k affect?](#which-aspects-of-shell-and-terminal-does-powerlevel10k-affect) -- [I'm using Powerlevel9k with Oh My Zsh. How do I migrate?](#im-using-powerlevel9k-with-oh-my-zsh-how-do-i-migrate) -- [Is it really fast?](#is-it-really-fast) -- [How do I configure instant prompt?](#how-do-i-configure-instant-prompt) -- [How do I initialize direnv when using instant prompt?](#how-do-i-initialize-direnv-when-using-instant-prompt) -- [How do I export GPG_TTY when using instant prompt?](#how-do-i-export-gpg_tty-when-using-instant-prompt) -- [What do different symbols in Git status mean?](#what-do-different-symbols-in-git-status-mean) -- [How do I change the format of Git status?](#how-do-i-change-the-format-of-git-status) -- [Why is Git status from `$HOME/.git` not displayed in prompt?](#why-is-git-status-from-homegit-not-displayed-in-prompt) -- [Why does Git status sometimes appear grey and then gets colored after a short period of time?](#why-does-git-status-sometimes-appear-grey-and-then-gets-colored-after-a-short-period-of-time) -- [How do I add username and/or hostname to prompt?](#how-do-i-add-username-andor-hostname-to-prompt) -- [Why some prompt segments appear and disappear as I'm typing?](#why-some-prompt-segments-appear-and-disappear-as-im-typing) -- [How do I change prompt colors?](#how-do-i-change-prompt-colors) -- [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) -- [Are there configuration options that make Powerlevel10k slow?](#are-there-configuration-options-that-make-powerlevel10k-slow) -- [Is Powerlevel10k fast to load?](#is-powerlevel10k-fast-to-load) -- [What is the relationship between Powerlevel9k and Powerlevel10k?](#what-is-the-relationship-between-powerlevel9k-and-powerlevel10k) -- [Does Powerlevel10k always render exactly the same prompt as Powerlevel9k given the same config?](#does-powerlevel10k-always-render-exactly-the-same-prompt-as-powerlevel9k-given-the-same-config) -- [What is the best prompt style in the configuration wizard?](#what-is-the-best-prompt-style-in-the-configuration-wizard) -- [How to make Powerlevel10k look like robbyrussell Oh My Zsh theme?](#how-to-make-powerlevel10k-look-like-robbyrussell-oh-my-zsh-theme) -- [Can prompts for completed commands display error status for *those* commands instead of the commands preceding them?](#can-prompts-for-completed-commands-display-error-status-for-those-commands-instead-of-the-commands-preceding-them) -- [What is the minimum supported Zsh version?](#what-is-the-minimum-supported-zsh-version) -- [How were these screenshots and animated gifs created?](#how-were-these-screenshots-and-animated-gifs-created) -- [How was the recommended font created?](#how-was-the-recommended-font-created) -- [How to package Powerlevel10k for distribution?](#how-to-package-powerlevel10k-for-distribution) - -### How do I update Powerlevel10k? - -The command to update Powerlevel10k depends on how it was installed. - -| Installation | Update command | -|-------------------------------|-------------------------------------------------------------| -| [Manual](#manual) | `git -C ~/powerlevel10k pull` | -| [Oh My Zsh](#oh-my-zsh) | `git -C ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k pull` | -| [Prezto](#prezto) | `zprezto-update` | -| [Zim](#zim) | `zimfw update` | -| [Antigen](#antigen) | `antigen update` | -| [Antidote](#antidote) | `antidote update` | -| [Zplug](#zplug) | `zplug update` | -| [Zgen](#zgen) | `zgen update` | -| [Zplugin](#zplugin) | `zplugin update` | -| [Zinit](#zinit) | `zinit update` | -| [Zi](#zi) | `zi update` | -| [Zap](#zap) | `zap --update` | -| [Homebrew](#homebrew) | `brew update && brew upgrade` | -| [Arch Linux](#arch-linux) | `yay -S --noconfirm zsh-theme-powerlevel10k-git` | -| [Alpine Linux](#alpine-linux) | `apk update && apk upgrade` | - -**IMPORTANT**: Restart Zsh after updating Powerlevel10k. [Do not use `source ~/.zshrc`]( - #weird-things-happen-after-typing-source-zshrc). - -### How do I uninstall Powerlevel10k? - -1. Remove all references to "p10k" from `~/.zshrc`. You might have this snippet at the top: - ```zsh - if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" - fi - ``` - And this at the bottom: - ```zsh - [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh - ``` - These are added by the [configuration wizard](#configuration-wizard). Remove them. -2. Remove all references to "powerlevel10k" from `~/.zshrc`, `~/.zpreztorc` and `~/.zimrc` (some - of these files may be missing -- this is normal). These references have been added manually by - yourself when installing Powerlevel10k. Refer to the [installation instructions](#installation) - if you need a reminder. -3. Verify that all references to "p10k" and "powerlevel10k" are gone from `~/.zshrc`, `~/.zpreztorc` - and `~/.zimrc`. - ```zsh - grep -E 'p10k|powerlevel10k' ~/.zshrc ~/.zpreztorc ~/.zimrc 2>/dev/null - ``` - If this command produces output, there are still references to "p10k" or "powerlevel10k". You - need to remove them. -4. Delete Powerlevel10k configuration file. This file is created by the - [configuration wizard](#configuration-wizard) and may contain manual edits by yourself. - ```zsh - rm -f ~/.p10k.zsh - ``` -5. Delete Powerlevel10k source files. These files have been downloaded when you've installed - Powerlevel10k. The command to delete them depends on which installation method you'd chosen. - Refer to the [installation instructions](#installation) if you need a reminder. - - | Installation | Uninstall command | - |-------------------------------|------------------------------------------------------------------| - | [Manual](#manual) | `rm -rf ~/powerlevel10k` | - | [Oh My Zsh](#oh-my-zsh) | `rm -rf -- ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k` | - | [Prezto](#prezto) | n/a | - | [Zim](#zim) | `zimfw uninstall` | - | [Antigen](#antigen) | `antigen purge romkatv/powerlevel10k` | - | [Antidote](#antidote) | `antidote purge romkatv/powerlevel10k` | - | [Zplug](#zplug) | `zplug clean` | - | [Zgen](#zgen) | `zgen reset` | - | [Zplugin](#zplugin) | `zplugin delete romkatv/powerlevel10k` | - | [Zinit](#zinit) | `zinit delete romkatv/powerlevel10k` | - | [Zi](#zi) | `zi delete romkatv/powerlevel10k` | - | [Zap](#zap) | `zsh -ic 'zap --clean'` | - | [Homebrew](#homebrew) | `brew uninstall powerlevel10k; brew untap romkatv/powerlevel10k` | - | [Arch Linux](#arch-linux) | `yay -R --noconfirm zsh-theme-powerlevel10k-git` | - | [Alpine Linux](#alpine-linux) | `apk del zsh-theme-powerlevel10k` | -6. Restart Zsh. [Do not use `source ~/.zshrc`](#weird-things-happen-after-typing-source-zshrc). -7. Delete Powerlevel10k cache files. - ```zsh - rm -rf -- "${XDG_CACHE_HOME:-$HOME/.cache}"/p10k-*(N) "${XDG_CACHE_HOME:-$HOME/.cache}"/gitstatus - ``` - -### How do I install Powerlevel10k on a machine without Internet access? - -1. Run this command on the machine without Internet access: - ```sh - uname -sm | tr '[A-Z]' '[a-z]' - ``` -2. Run these commands on a machine connected to the Internet after replacing the value of - `target_uname` with the output of the previous command: - ```sh - target_uname="replace this with the output of the previous command" - git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k - GITSTATUS_CACHE_DIR="$HOME"/powerlevel10k/gitstatus/usrbin ~/powerlevel10k/gitstatus/install -f -s "${target_uname% *}" -m "${target_uname#* }" - ``` -3. Copy `~/powerlevel10k` from the machine connected to the Internet to the one without Internet - access. -4. Add `source ~/powerlevel10k/powerlevel10k.zsh-theme` to `~/.zshrc` on the machine without - Internet access: - ```zsh - echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc - ``` -5. If `~/.zshrc` on the machine without Internet access sets `ZSH_THEME`, remove that line. - ```zsh - sed -i.bak '/^ZSH_THEME=/d' ~/.zshrc - ``` - -To update, remove `~/powerlevel10k` on both machines and repeat steps 1-3. - -### Where can I ask for help and report bugs? - -The best way to ask for help and to report bugs is to [open an issue]( - https://github.com/romkatv/powerlevel10k/issues). - -[Gitter]( - https://gitter.im/powerlevel10k/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) -is another option. - -If all else fails, email roman.perepelitsa@gmail.com. - -If necessary, encrypt your communication with [this PGP key]( - https://api.github.com/users/romkatv/gpg_keys). - -### Which aspects of shell and terminal does Powerlevel10k affect? - -Powerlevel10k defines prompt and nothing else. It sets [prompt-related options]( - http://zsh.sourceforge.net/Doc/Release/Options.html#Prompting), and parameters `PS1` and `RPS1`. - -![Prompt Highlight]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/prompt-highlight.png) - -Everything within the highlighted areas on the screenshot is produced by Powerlevel10k. -Powerlevel10k has no control over the terminal content or colors outside these areas. - -Powerlevel10k does not affect: - -- Terminal window/tab title. -- Colors used by `ls`. -- The behavior of `git` command. -- The content and style of <kbd>Tab</kbd> completions. -- Command line colors (syntax highlighting, autosuggestions, etc.). -- Key bindings. -- Aliases. -- Prompt parameters other than `PS1` and `RPS1`. -- Zsh options other than those [related to prompt]( - http://zsh.sourceforge.net/Doc/Release/Options.html#Prompting). - -### I'm using Powerlevel9k with Oh My Zsh. How do I migrate? - -1. Run this command: -```zsh -# Add powerlevel10k to the list of Oh My Zsh themes. -git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k -# Replace ZSH_THEME="powerlevel9k/powerlevel9k" with ZSH_THEME="powerlevel10k/powerlevel10k". -sed -i.bak 's/powerlevel9k/powerlevel10k/g' ~/.zshrc -# Restart Zsh. -exec zsh -``` -2. *Optional but highly recommended:* - 1. Install [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). - 1. Type `p10k configure` and choose your favorite prompt style. - -*Related:* - - [Powerlevel9k compatibility.](#powerlevel9k-compatibility) - - [Does Powerlevel10k always render exactly the same prompt as Powerlevel9k given the same config?]( - #does-powerlevel10k-always-render-exactly-the-same-prompt-as-powerlevel9k-given-the-same-config) - - [Extra or missing spaces in prompt compared to Powerlevel9k.]( - #extra-or-missing-spaces-in-prompt-compared-to-powerlevel9k) - - [Configuration wizard.](#configuration-wizard) - -### Is it really fast? - -Yes. See [zsh-bench](https://github.com/romkatv/zsh-bench) or a direct comparison with -[Powerlevel9k](https://asciinema.org/a/NHRjK3BMePw66jtRVY2livHwZ) and -[Spaceship](https://asciinema.org/a/253094). - -### <a name='how-do-i-enable-instant-prompt'></a>How do I configure instant prompt? - -See [instant prompt](#instant-prompt) to learn about instant prompt. This section explains how you -can enable and configure it and lists caveats that you should be aware of. - -Instant prompt can be enabled either through `p10k configure` or by manually adding the following -code snippet at the top of `~/.zshrc`: - -```zsh -# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. -# Initialization code that may require console input (password prompts, [y/n] -# confirmations, etc.) must go above this block; everything else may go below. -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi -``` - -It's important that you copy the lines verbatim. Don't replace `source` with something else, don't -call `zcompile`, don't redirect output, etc. - -When instant prompt is enabled, for the duration of Zsh initialization standard input is redirected -to `/dev/null` and standard output with standard error are redirected to a temporary file. Once Zsh -is fully initialized, standard file descriptors are restored and the content of the temporary file -is printed out. - -When using instant prompt, you should carefully check any output that appears on Zsh startup as it -may indicate that initialization has been altered, or perhaps even broken, by instant prompt. -Initialization code that may require console input, such as asking for a keyring password or for a -*[y/n]* confirmation, must be moved above the instant prompt preamble in `~/.zshrc`. Initialization -code that merely prints to console but never reads from it will work correctly with instant prompt, -although output that normally has colors may appear uncolored. You can either leave it be, suppress -the output, or move it above the instant prompt preamble. - -Here's an example of `~/.zshrc` that breaks when instant prompt is enabled: - -```zsh -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi - -keychain id_rsa --agents ssh # asks for password -chatty-script # spams to stdout even when everything is fine -# ... -``` - -Fixed version: - -```zsh -keychain id_rsa --agents ssh # moved before instant prompt - -# OK to perform console I/O before this point. -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi -# From this point on, until zsh is fully initialized, console input won't work and -# console output may appear uncolored. - -chatty-script >/dev/null # spam output suppressed -# ... -``` - -If `POWERLEVEL9K_INSTANT_PROMPT` is unset or set to `verbose`, Powerlevel10k will print a warning -when it detects console output during initialization to bring attention to potential issues. You can -silence this warning (without suppressing console output) with `POWERLEVEL9K_INSTANT_PROMPT=quiet`. -This is recommended if some initialization code in `~/.zshrc` prints to console and it's infeasible -to move it above the instant prompt preamble or to suppress its output. You can completely disable -instant prompt with `POWERLEVEL9K_INSTANT_PROMPT=off`. Do this if instant prompt breaks Zsh -initialization and you don't know how to fix it. - -The value of `POWERLEVEL9K_INSTANT_PROMPT` can be changed by running `p10k configure` and selecting -the appropriate option on the *Instant Prompt* screen. Alternatively, you can search for -`POWERLEVEL9K_INSTANT_PROMPT` in the existing `~/.p10k.zsh` and change its value there. - -*Note*: Instant prompt requires Zsh >= 5.4. It's OK to enable it even when using an older version of -Zsh but it won't do anything. - -*FAQ*: - -- [How do I initialize direnv when using instant prompt?]( - #how-do-i-initialize-direnv-when-using-instant-prompt) -- [How do I export GPG_TTY when using instant prompt?]( - #how-do-i-export-gpg_tty-when-using-instant-prompt) - -### How do I initialize direnv when using instant prompt? - -If you've enabled [instant prompt](#instant-prompt), you should have these lines at the top of -`~/.zshrc`: - -```zsh -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi -``` - -To initialize direnv you need to add one line above that block and one line below it. - -```zsh -(( ${+commands[direnv]} )) && emulate zsh -c "$(direnv export zsh)" - -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi - -(( ${+commands[direnv]} )) && emulate zsh -c "$(direnv hook zsh)" -``` - -*Related*: [How do I export GPG_TTY when using instant prompt?]( - #how-do-i-export-gpg_tty-when-using-instant-prompt) - -### How do I export GPG_TTY when using instant prompt? - -You can export `GPG_TTY` like this anywhere in `~/.zshrc`: - -```zsh -export GPG_TTY=$TTY -``` - -This works whether you are using [instant prompt](#instant-prompt) or not. It works even if you -aren't using powerlevel10k. As an extra bonus, it's much faster than the commonly used -`export GPG_TTY=$(tty)`. - -*Related*: [How do I initialize direnv when using instant prompt?]( - #how-do-i-initialize-direnv-when-using-instant-prompt) - -### What do different symbols in Git status mean? - -When using Lean, Classic or Rainbow style, Git status may look like this: - -```text -feature:master wip ⇣42⇡42 ⇠42⇢42 *42 merge ~42 +42 !42 ?42 -``` - -| Symbol | Meaning | Source | -| --------- | -------------------------------------------------------------------- | ------------------------------------------------------ | -| `feature` | current branch; replaced with `#tag` or `@commit` if not on a branch | `git status --ignore-submodules=dirty` | -| `master` | remote tracking branch; only shown if different from local branch | `git rev-parse --abbrev-ref --symbolic-full-name @{upstream}` | -| `wip` | the latest commit's summary contains "wip" or "WIP" | `git show --pretty=%s --no-patch HEAD` | -| `⇣42` | this many commits behind the remote | `git rev-list --right-only --count HEAD...@{upstream}` | -| `⇡42` | this many commits ahead of the remote | `git rev-list --left-only --count HEAD...@{upstream}` | -| `⇠42` | this many commits behind the push remote | `git rev-list --right-only --count HEAD...@{push}` | -| `⇢42` | this many commits ahead of the push remote | `git rev-list --left-only --count HEAD...@{push}` | -| `*42` | this many stashes | `git stash list` | -| `merge` | repository state | `git status --ignore-submodules=dirty` | -| `~42` | this many merge conflicts | `git status --ignore-submodules=dirty` | -| `+42` | this many staged changes | `git status --ignore-submodules=dirty` | -| `!42` | this many unstaged changes | `git status --ignore-submodules=dirty` | -| `?42` | this many untracked files | `git status --ignore-submodules=dirty` | -| `─` | the number of staged, unstaged or untracked files is unknown | `echo $POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY` or `git config --get bash.showDirtyState` | - -*Related*: [How do I change the format of Git status?](#how-do-i-change-the-format-of-git-status) - -### How do I change the format of Git status? - -To change the format of Git status, open `~/.p10k.zsh`, search for `my_git_formatter` and edit its -source code. - -*Related*: [What do different symbols in Git status mean?]( - #what-do-different-symbols-in-git-status-mean) - -### Why is Git status from `$HOME/.git` not displayed in prompt? - -When using Lean, Classic or Rainbow style, `~/.p10k.zsh` contains the following parameter: - -```zsh -# Don't show Git status in prompt for repositories whose workdir matches this pattern. -# For example, if set to '~', the Git repository at $HOME/.git will be ignored. -# Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. -typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' -``` - -To see Git status for `$HOME/.git` in prompt, open `~/.p10k.zsh` and remove -`POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN`. - -### Why does Git status sometimes appear grey and then gets colored after a short period of time? - -tl;dr: When Git status in prompt is greyed out, it means Powerlevel10k is currently computing -up-to-date Git status in the background. Prompt will get automatically refreshed when this -computation completes. - -When your current directory is within a Git repository, Powerlevel10k computes up-to-date Git -status after every command. If the repository is large, or the machine is slow, this computation -can take quite a bit of time. If it takes longer than 10 milliseconds (configurable via -`POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS`), Powerlevel10k displays the last known Git status in -grey and continues to compute up-to-date Git status in the background. When the computation -completes, Powerlevel10k refreshes prompt with new information, this time with colored Git status. - -When using *Rainbow* style, Git status is displayed as black on grey while it's still being -computed. Depending on the terminal color palette, this may be difficult to read. In this case you -might want to change the background color to something ligher for more contrast. To do that, open -`~/.p10k.zsh`, search for `POWERLEVEL9K_VCS_LOADING_BACKGROUND`, uncomment it if it's commented out, -and change the value. - -```zsh -typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=244 -``` - -Type `source ~/.p10k.zsh` to apply your changes to the current Zsh session. - -*Related*: [How do I change prompt colors?](#how-do-i-change-prompt-colors) - -### How do I add username and/or hostname to prompt? - -When using Lean, Classic or Rainbow style, prompt shows `username@hostname` when you are logged in -as root or via SSH. There is little value in showing `username` or `hostname` when you are logged in -to your local machine as a normal user. So the absence of `username@hostname` in your prompt is an -indication that you are working locally and that you aren't root. You can change it, however. - -Open `~/.p10k.zsh`. Close to the top you can see the most important parameters that define which -segments are shown in your prompt. All generally useful prompt segments are listed in there. Some of -them are enabled, others are commented out. One of them is of interest to you. - -```zsh -typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( - ... - context # user@hostname - ... -) -``` - -Search for `context` to find the section in the config that lists parameters specific to this prompt -segment. You should see the following lines: - -```zsh -# Don't show context unless running with privileges or in SSH. -# Tip: Remove the next line to always show context. -typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= -``` - -If you follow the tip and remove (or comment out) the last line, you'll always see -`username@hostname` in prompt. You can change the format to just `username`, or change the color, by -adjusting the values of parameters nearby. There are plenty of comments to help you navigate. - -You can also move `context` to a different position in `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS` or even -to `POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`. - -### Why some prompt segments appear and disappear as I'm typing? - -Prompt segments can be configured to be shown only when the current command you are typing invokes -a relevant tool. - -```zsh -# Show prompt segment "kubecontext" only when the command you are typing -# invokes kubectl, helm, kubens, kubectx, oc, istioctl, kogito, k9s, helmfile, flux, fluxctl, stern, kubeseal, or skaffold. -typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold' -``` - -Configs created by `p10k configure` may contain parameters of this kind. To customize when different -prompt segments are shown, open `~/.p10k.zsh`, search for `SHOW_ON_COMMAND` and either remove these -parameters or change their values. - -You can also define a function in `~/.zshrc` to toggle the display of a prompt segment between -*always* and *on command*. This is similar to `kubeon`/`kubeoff` from -[kube-ps1](https://github.com/jonmosco/kube-ps1). - -```zsh -function kube-toggle() { - if (( ${+POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND} )); then - unset POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND - else - POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold' - fi - p10k reload - if zle; then - zle push-input - zle accept-line - fi -} -``` - -Invoke this function by typing `kube-toggle`. You can also bind it to a key by adding two more lines -to `~/.zshrc`: - -```zsh -zle -N kube-toggle -bindkey '^]' kube-toggle # ctrl-] to toggle kubecontext in powerlevel10k prompt -``` - -### How do I change prompt colors? - -You can either [change the color palette used by your terminal]( - #change-the-color-palette-used-by-your-terminal) or -[set colors through Powerlevel10k configuration parameters]( - #set-colors-through-Powerlevel10k-configuration-parameters). - -#### Change the color palette used by your terminal - -How exactly you change the terminal color palette (a.k.a. color scheme, or theme) depends on the -kind of terminal you are using. Look around in terminal's settings/preferences or consult -documentation. - -When you change the terminal color palette, it usually affects only the first 16 colors, numbered -from 0 to 15. In order to see any effect on Powerlevel10k prompt, you need to use prompt style that -utilizes these low-numbered colors. Type `p10k configure` and select *Rainbow*, *Lean* → *8 colors* -or *Pure* → *Original*. Other styles use higher-numbered colors, so they look the same in any -terminal color palette. - -#### Set colors through Powerlevel10k configuration parameters - -Open `~/.p10k.zsh`, search for "color", "foreground" and "background" and change values of -appropriate parameters. For example, here's how you can set the foreground of `time` prompt segment -to bright red: - -```zsh -typeset -g POWERLEVEL9K_TIME_FOREGROUND=160 -``` - -Colors are specified using numbers from 0 to 255. Colors from 0 to 15 look differently in different -terminals. Many terminals also support customization of these colors through color palettes -(a.k.a. color schemes, or themes). Colors from 16 to 255 always look the same. - -Type `source ~/.p10k.zsh` to apply your changes to the current Zsh session. - -To see how different colors look in your terminal, run the following command: - -```zsh -for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done -``` - -*Related:* - - [Directory is difficult to see in prompt when using Rainbow style.]( - #directory-is-difficult-to-see-in-prompt-when-using-rainbow-style) - -### Why does Powerlevel10k spawn extra processes? - -Powerlevel10k uses [gitstatus](https://github.com/romkatv/gitstatus) as the backend behind `vcs` -prompt; gitstatus spawns `gitstatusd` and `zsh`. See -[gitstatus](https://github.com/romkatv/gitstatus) for details. Powerlevel10k may also spawn `zsh` -to perform computation without blocking prompt. To avoid security hazard, these background processes -aren't shared by different interactive shells. They terminate automatically when the parent `zsh` -process terminates or runs `exec(3)`. - -### Are there configuration options that make Powerlevel10k slow? - -No, Powerlevel10k is always fast, with any configuration you throw at it. If you have noticeable -prompt latency when using Powerlevel10k, please -[open an issue](https://github.com/romkatv/powerlevel10k/issues). - -### Is Powerlevel10k fast to load? - -Yes. See [zsh-bench](https://github.com/romkatv/zsh-bench). - -### What is the relationship between Powerlevel9k and Powerlevel10k? - -Powerlevel10k was forked from Powerlevel9k in March 2019 after a week-long discussion in -[powerlevel9k#1170](https://github.com/Powerlevel9k/powerlevel9k/issues/1170). Powerlevel9k was -already a mature project with a large user base and a release cycle measured in months. Powerlevel10k -was spun off to iterate on performance improvements and new features at much higher pace. - -Powerlevel9k and Powerlevel10k are independent projects. When using one, you shouldn't install the -other. Issues should be filed against the project that you actually use. There are no individuals -that have commit rights in both repositories. All bug fixes and new features committed to -Powerlevel9k repository get ported to Powerlevel10k. - -Over time, virtually all code in Powerlevel10k has been rewritten. There is currently no meaningful -overlap between the implementations of Powerlevel9k and Powerlevel10k. - -Powerlevel10k is committed to maintaining backward compatibility with all configs indefinitely. This -commitment covers all configuration parameters recognized by Powerlevel9k (see -[Powerlevel9k compatibility](#powerlevel9k-compatibility)) and additional parameters that only -Powerlevel10k understands. Names of all parameters in Powerlevel10k start with `POWERLEVEL9K_` for -consistency. - -### Does Powerlevel10k always render exactly the same prompt as Powerlevel9k given the same config? - -Almost. There are a few differences. - -- By default only `git` vcs backend is enabled in Powerlevel10k. If you need `svn` and `hg`, add - them to `POWERLEVEL9K_VCS_BACKENDS`. These backends aren't yet optimized in Powerlevel10k, so - enabling them will make prompt *very slow*. -- Powerlevel10k doesn't support `POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY=true`. -- Powerlevel10k strives to be bug-compatible with Powerlevel9k but not when it comes to egregious - bugs. If you accidentally rely on these bugs, your prompt will differ between Powerlevel9k and - Powerlevel10k. Some examples: - - Powerlevel9k ignores some options that are set after the theme is sourced while Powerlevel10k - respects all options. If you see different icons in Powerlevel9k and Powerlevel10k, you've - probably defined `POWERLEVEL9K_MODE` before sourcing the theme. This parameter gets ignored - by Powerlevel9k but honored by Powerlevel10k. If you want your prompt to look in Powerlevel10k - the same as in Powerlevel9k, remove `POWERLEVEL9K_MODE`. - - Powerlevel9k doesn't respect `ZLE_RPROMPT_INDENT`. As a result, right prompt in Powerlevel10k - can have an extra space at the end compared to Powerlevel9k. Set `ZLE_RPROMPT_INDENT=0` if you - don't want that space. More details in - [troubleshooting](#extra-space-without-background-on-the-right-side-of-right-prompt). - - Powerlevel9k has inconsistent spacing around icons. This was fixed in Powerlevel10k. Set - `POWERLEVEL9K_LEGACY_ICON_SPACING=true` to get the same spacing as in Powerlevel9k. More - details in [troubleshooting](#extra-or-missing-spaces-around-icons). - - There are dozens more bugs in Powerlevel9k that don't exist in Powerlevel10k. - -If you notice any other changes in prompt appearance when switching from Powerlevel9k to -Powerlevel10k, please [open an issue](https://github.com/romkatv/powerlevel10k/issues). - -### What is the best prompt style in the configuration wizard? - -There are as many opinions on what constitutes the best prompt as there are people. It mostly comes -down to personal preference. There are, however, a few hidden implications of different choices. - -Pure style is an exact replication of [Pure Zsh theme](https://github.com/sindresorhus/pure). It -exists to ease the migration for users of this theme. Unless you are one of them, choose Lean -style over Pure. - -If you want to confine prompt colors to the selected terminal color palette (say, *Solarized Dark*), -use *Rainbow*, *Lean* → *8 colors* or *Pure* → *Original*. Other styles use fixed colors and thus -look the same in any terminal color palette. - -All styles except Pure have an option to use *ASCII* charset. Prompt will look less pretty but will -render correctly with all fonts and in all locales. - -If you enable transient prompt, take advantage of two-line prompt. You'll get the benefit of -extra space for typing commands without the usual drawback of reduced scrollback density. Having -all commands start from the same offset is also nice. - -Similarly, if you enable transient prompt, sparse prompt (with an empty line before prompt) is a -great choice. - -If you are using vi keymap, choose prompt with `prompt_char` in it (shown as green `❯` in the -wizard). This symbol changes depending on vi mode: `❯`, `❮`, `V`, `▶` for insert, command, visual -and replace mode respectively. When a command fails, the symbol turns red. *Lean* style always has -`prompt_char` in it. *Rainbow* and *Classic* styles have it only in the two-line configuration -without left frame. - -If you value horizontal space or prefer minimalist aesthetics: - -- Use a monospace font, such as [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). - Non-monospace fonts require extra space after icons that are larger than a single column. -- Use Lean style. Compared to Classic and Rainbow, it saves two characters per prompt segment. -- Disable *current time* and *frame*. -- Use *few icons*. The extra icons enabled by the *many icons* option primarily serve decorative - function. Informative icons, such as background job indicator, will be shown either way. - -*Note*: You can run configuration wizard as many times as you like. Type `p10k configure` to try new -prompt style. - -### How to make Powerlevel10k look like robbyrussell Oh My Zsh theme? - -Use [this config]( - https://github.com/romkatv/powerlevel10k/blob/master/config/p10k-robbyrussell.zsh). - -You can either download it, save as `~/.p10k.zsh` and `source ~/.p10k.zsh` from `~/.zshrc`, or -source `p10k-robbyrussell.zsh` directly from your cloned `powerlevel10k` repository. - -### Can prompts for completed commands display error status for *those* commands instead of the commands preceding them? - -No. When you hit *ENTER* and the command you've typed starts running, its error status isn't yet -known, so it cannot be shown in prompt. When the command completes, the error status gets known but -it's no longer possible to update prompt for *that* command. This is why the error status for every -command is reflected in the *next* prompt. - -For details, see [this post on /r/zsh]( -https://www.reddit.com/r/zsh/comments/eg49ff/powerlevel10k_prompt_history_exit_code_colors/fc5huku). - -### What is the minimum supported Zsh version? - -Zsh 5.3 or newer should work. Fast startup requires Zsh >= 5.4. - -### How were these screenshots and animated gifs created? - -All screenshots and animated gifs were recorded in GNOME Terminal with -[the recommended font](#meslo-nerd-font-patched-for-powerlevel10k) and Tango Dark color palette with -custom background color (`#171A1B` instead of `#2E3436` -- twice as dark). - -![GNOME Terminal Color Settings]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/gnome-terminal-colors.png) - -Syntax highlighting, where present, was provided by [zsh-syntax-highlighting]( - https://github.com/zsh-users/zsh-syntax-highlighting). - -### How was the recommended font created? - -[The recommended font](#meslo-nerd-font-patched-for-powerlevel10k) is the product of many -individuals. Its origin is *Bitstream Vera Sans Mono*, which has given birth to *Menlo*, which in -turn has spawned *Meslo*. Finally, extra glyphs have been added to *Meslo* with scripts forked -from Nerd Fonts. The final font is released under the terms of -[Apache License]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20License.txt). - -MesloLGS NF font can be recreated with the following command (requires `git` and `docker`): - -```zsh -git clone --depth=1 https://github.com/romkatv/nerd-fonts.git -cd nerd-fonts -./build 'Meslo/S/*' -``` - -If everything goes well, four `ttf` files will appear in `./out`. - -### How to package Powerlevel10k for distribution? - -It's currently neither easy nor recommended to package and distribute Powerlevel10k. There are no -instructions you can follow that would allow you to easily update your package when new versions of -Powerlevel10k are released. This may change in the future but not soon. - -## Troubleshooting - -- [Question mark in prompt](#question-mark-in-prompt) -- [Icons, glyphs or powerline symbols don't render](#icons-glyphs-or-powerline-symbols-dont-render) -- [Sub-pixel imperfections around powerline symbols](#sub-pixel-imperfections-around-powerline-symbols) -- [Error: character not in range](#error-character-not-in-range) -- [Cursor is in the wrong place](#cursor-is-in-the-wrong-place) -- [Prompt wrapping around in a weird way](#prompt-wrapping-around-in-a-weird-way) -- [Right prompt is in the wrong place](#right-prompt-is-in-the-wrong-place) -- [Configuration wizard runs automatically every time Zsh is started](#configuration-wizard-runs-automatically-every-time-zsh-is-started) -- [Some prompt styles are missing from the configuration wizard](#some-prompt-styles-are-missing-from-the-configuration-wizard) -- [Cannot install the recommended font](#cannot-install-the-recommended-font) -- [Extra or missing spaces in prompt compared to Powerlevel9k](#extra-or-missing-spaces-in-prompt-compared-to-powerlevel9k) - - [Extra space without background on the right side of right prompt](#extra-space-without-background-on-the-right-side-of-right-prompt) - - [Extra or missing spaces around icons](#extra-or-missing-spaces-around-icons) -- [Weird things happen after typing `source ~/.zshrc`](#weird-things-happen-after-typing-source-zshrc) -- [Transient prompt stops working after some time](#transient-prompt-stops-working-after-some-time) -- [Cannot make Powerlevel10k work with my plugin manager](#cannot-make-powerlevel10k-work-with-my-plugin-manager) -- [Directory is difficult to see in prompt when using Rainbow style](#directory-is-difficult-to-see-in-prompt-when-using-rainbow-style) -- [Horrific mess when resizing terminal window](#horrific-mess-when-resizing-terminal-window) -- [Icons cut off in Konsole](#icons-cut-off-in-konsole) -- [Arch Linux logo has a dot in the bottom right corner](#arch-linux-logo-has-a-dot-in-the-bottom-right-corner) - -### Question mark in prompt - -If it looks like a regular `?`, that's normal. It means you have untracked files in the current Git -repository. Type `git status` to see these files. You can change this symbol or disable the display -of untracked files altogether. Search for `untracked files` in `~/.p10k.zsh`. - -*FAQ*: [What do different symbols in Git status mean?]( - #what-do-different-symbols-in-git-status-mean) - -You can also get a weird-looking question mark in your prompt if your terminal's font is missing -some glyphs. See [icons, glyphs or powerline symbols don't render]( - #icons-glyphs-or-powerline-symbols-dont-render). - -### Icons, glyphs or powerline symbols don't render - -Restart your terminal, [install the recommended font](#meslo-nerd-font-patched-for-powerlevel10k) -and run `p10k configure`. - -### Sub-pixel imperfections around powerline symbols - -![Powerline Prompt Imperfections]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/powerline-imperfections.png) - -There are three imperfections on the screenshot. From left to right: - -1. A thin blue line (a sub-pixel gap) between the content of a prompt segment and the following -powerline connection. -1. Incorrect alignment of a powerline connection and the following prompt segment. The connection -appears shifted to the right. -1. A thin red line below a powerline connection. The connection appears shifted up. - -Zsh themes don't have down-to-pixel control over the terminal content. Everything you see on the -screen is made of monospace characters. A white powerline prompt segment is made of text on white -background followed by U+E0B0 (a right-pointing triangle). - -![Powerline Prompt Imperfections]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/powerline-anatomy.png) - -If Powerlevel10k prompt has imperfections around powerline symbols, you'll see exactly the same -imperfections with all powerline themes (Agnoster, Powerlevel9k, Powerline, etc.) - -There are several things you can try to deal with these imperfections: - -- Try [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). If you are already using - it, switching to another font may help but is unlikely. -- Change terminal font size one point up or down. For example, in iTerm2 powerline prompt looks - perfect at font sizes 11 and 13 but breaks down at 12. -- Enable builtin powerline glyphs in terminal settings if your terminal supports it (iTerm2 does). -- Change font hinting and/or anti-aliasing mode in the terminal settings. -- Shift all text one pixel up/down/left/right if your terminal has an option to do so. -- Try a different terminal. - -A more radical solution is to switch to prompt style without background. Type `p10k configure` and -select *Lean*. This style has a modern lightweight look. As a bonus, it doesn't suffer from -rendering imperfections that afflict powerline-style prompt. - -### Error: character not in range - -Type `echo '\u276F'`. If you get an error saying "zsh: character not in range", your locale -doesn't support UTF-8. You need to fix it. If you are running Zsh over SSH, see -[this](https://github.com/romkatv/powerlevel10k/issues/153#issuecomment-518347833). If you are -running Zsh locally, Google "set UTF-8 locale in *your OS*". - -### Cursor is in the wrong place - -Type `echo '\u276F'`. If you get an error saying "zsh: character not in range", see the -[previous section](#zsh-character-not-in-range). - -If the `echo` command prints `❯` but the cursor is still in the wrong place, install -[the recommended font](#meslo-nerd-font-patched-for-powerlevel10k) and run -`p10k configure`. - -If this doesn't help, add `unset ZLE_RPROMPT_INDENT` at the bottom of `~/.zshrc`. - -Still having issues? Run the following command to diagnose the problem: - -```zsh -() { - emulate -L zsh - setopt err_return no_unset - local text - print -rl -- 'Select a part of your prompt from the terminal window and paste it below.' '' - read -r '?Prompt: ' text - local -i len=${(m)#text} - local frame="+-${(pl.$len..-.):-}-+" - print -lr -- $frame "| $text |" $frame -} -``` - -#### If the prompt line aligns with the frame - -```text -+------------------------------+ -| romka@adam ✓ ~/powerlevel10k | -+------------------------------+ -``` - -If the output of the command is aligned for every part of your prompt (left and right), this -indicates a bug in the theme or your config. Use this command to diagnose it: - -```zsh -print -rl -- ${(eq+)PROMPT} ${(eq+)RPROMPT} -``` - -Look for `%{...%}` and backslash escapes in the output. If there are any, they are the likely -culprits. Open an issue if you get stuck. - -#### If the prompt line is longer than the frame - -```text -+-----------------------------+ -| romka@adam ✓ ~/powerlevel10k | -+-----------------------------+ -``` - -This is usually caused by a terminal bug or misconfiguration that makes it print ambiguous-width -characters as double-width instead of single width. For example, -[this issue](https://github.com/romkatv/powerlevel10k/issues/165). - -#### If the prompt line is shorter than the frame and is mangled - -```text -+------------------------------+ -| romka@adam ✓~/powerlevel10k | -+------------------------------+ -``` - -Note that this prompt is different from the original as it's missing a space after the check mark. - -This can be caused by a low-level bug in macOS. See -[this issue](https://github.com/romkatv/powerlevel10k/issues/241). - -This can also happen if prompt contains glyphs designated as "wide" in the Unicode standard and your -terminal incorrectly displays them as non-wide. Terminals suffering from this limitation include -Konsole, Hyper and the integrated VSCode Terminal. The solution is to use a different terminal or -remove all wide glyphs from prompt. - -#### If the prompt line is shorter than the frame and is not mangled - -```text -+--------------------------------+ -| romka@adam ✓ ~/powerlevel10k | -+--------------------------------+ -``` - -This can be caused by misconfigured locale. See -[this issue](https://github.com/romkatv/powerlevel10k/issues/251). - -### Prompt wrapping around in a weird way - -See [cursor is in the wrong place](#cursor-is-in-the-wrong-place). - -### Right prompt is in the wrong place - -See [cursor is in the wrong place](#cursor-is-in-the-wrong-place). - -### Configuration wizard runs automatically every time Zsh is started - -When Powerlevel10k starts, it automatically runs `p10k configure` if no `POWERLEVEL9K_*` -parameters are defined. Based on your prompt style choices, the configuration wizard creates -`~/.p10k.zsh` with a bunch of `POWERLEVEL9K_*` parameters in it and adds a line to `~/.zshrc` to -source this file. The next time you start Zsh, the configuration wizard shouldn't run automatically. -If it does, this means the evaluation of `~/.zshrc` terminates prematurely before it reaches the -line that sources `~/.p10k.zsh`. This most often happens due to syntax errors in `~/.zshrc`. These -errors get hidden by the configuration wizard screen, so you don't notice them. When you exit -configuration wizard, look for error messages. You can also use -`POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true zsh` to start Zsh without automatically running the -configuration wizard. Once you can see the errors, fix `~/.zshrc` to get rid of them. - -### Some prompt styles are missing from the configuration wizard - -If Zsh version is below 5.7.1 or `COLORTERM` environment variable is neither `24bit` nor -`truecolor`, configuration wizard won't offer Pure style with Snazzy color scheme. *Fix*: Install -Zsh >= 5.7.1 and use a terminal with truecolor support. Verify with `print -P '%F{#ff0000}red%f'`. - -If the terminal can display fewer than 256 colors, configuration wizard preselects Lean style with -8 colors. All other styles require at least 256 colors. *Fix*: Use a terminal with 256 color support -and make sure that `TERM` environment variable is set correctly. Verify with -`print $terminfo[colors]`. - -If there is no UTF-8 locale on the system, configuration wizard won't offer prompt styles that use -Unicode characters. *Fix*: Install a UTF-8 locale. Verify with `locale -a`. - -When a UTF-8 locale is available, the first few questions asked by the configuration wizard assess -capabilities of the terminal font. If your answers indicate that some glyphs don't render correctly, -configuration wizard won't offer prompt styles that use them. *Fix*: Restart your terminal and -install [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). Verify by running -`p10k configure` and checking that all glyphs render correctly. - -### Cannot install the recommended font - -Once you download [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k), -you can install it just like any other font. Google "how to install fonts on *your OS*". - -### Extra or missing spaces in prompt compared to Powerlevel9k - -tl;dr: Add `ZLE_RPROMPT_INDENT=0` and `POWERLEVEL9K_LEGACY_ICON_SPACING=true` to `~/.zshrc` to get -the same prompt spacing as in Powerlevel9k. - -When using Powerlevel10k with a Powerlevel9k config, you might get additional spaces in prompt here -and there. These come in two flavors. - -#### Extra space without background on the right side of right prompt - -tl;dr: Add `ZLE_RPROMPT_INDENT=0` to `~/.zshrc` to get rid of that space. - -From [Zsh documentation]( - http://zsh.sourceforge.net/Doc/Release/Parameters.html#index-ZLE_005fRPROMPT_005fINDENT): - -> `ZLE_RPROMPT_INDENT <S>` -> -> If set, used to give the indentation between the right hand side of the right prompt in the line -> editor as given by `RPS1` or `RPROMPT` and the right hand side of the screen. If not set, the -> value `1` is used. -> -> Typically this will be used to set the value to `0` so that the prompt appears flush with the -> right hand side of the screen. - -Powerlevel10k respects this parameter. If you set `ZLE_RPROMPT_INDENT=1` (or leave it unset, which -is the same thing as setting it to `1`), you'll get an empty space to the right of right prompt. If -you set `ZLE_RPROMPT_INDENT=0`, your prompt will go to the edge of the terminal. This is how it -works in every theme except Powerlevel9k. - -![ZLE_RPROMPT_INDENT: Powerlevel10k vs Powerlevel9k]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/p9k-vs-p10k-zle-rprompt-indent.png) - -Powerlevel9k issue: [powerlevel9k#1292](https://github.com/Powerlevel9k/powerlevel9k/issues/1292). -It's been fixed in the development branch of Powerlevel9k but the fix hasn't yet made it to -`master`. - -Add `ZLE_RPROMPT_INDENT=0` to `~/.zshrc` to get the same spacing on the right edge of prompt as in -Powerlevel9k. - -*Note:* Several versions of Zsh have bugs that get triggered when you set `ZLE_RPROMPT_INDENT=0`. -Powerlevel10k can work around these bugs when using powerline prompt style. If you notice visual -artifacts in prompt, or wrong cursor position, try removing `ZLE_RPROMPT_INDENT` from `~/.zshrc`. - -#### Extra or missing spaces around icons - -tl;dr: Add `POWERLEVEL9K_LEGACY_ICON_SPACING=true` to `~/.zshrc` to get the same spacing around -icons as in Powerlevel9k. - -Spacing around icons in Powerlevel9k is inconsistent. - -![ZLE_RPROMPT_INDENT: Powerlevel10k vs Powerlevel9k]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/p9k-vs-p10k-icon-spacing.png) - -This inconsistency is a constant source of annoyance, so it was fixed in Powerlevel10k. You can add -`POWERLEVEL9K_LEGACY_ICON_SPACING=true` to `~/.zshrc` to get the same spacing around icons as in -Powerlevel9k. - -*Note:* It's not a good idea to define `POWERLEVEL9K_LEGACY_ICON_SPACING` when using -`p10k configure`. - -### Weird things happen after typing `source ~/.zshrc` - -It's almost always a bad idea to run `source ~/.zshrc`, whether you are using Powerlevel10k or not. -This command may result in random errors, misbehaving code and progressive slowdown of Zsh. - -If you've made changes to `~/.zshrc` or to files sourced by it, restart Zsh to apply them. The most -reliable way to do this is to type `exit` and then start a new Zsh session. You can also use -`exec zsh`. While not exactly equivalent to complete Zsh restart, this command is much more reliable -than `source ~/.zshrc`. - -### Transient prompt stops working after some time - -See [weird things happen after typing `source ~/.zshrc`]( - #weird-things-happen-after-typing-source-zshrc). - -### Cannot make Powerlevel10k work with my plugin manager - -If the [installation instructions](#installation) didn't work for you, try disabling your current -theme (so that you end up with no theme) and then installing Powerlevel10k manually. - -1. Disable the current theme in your framework / plugin manager. - -- **oh-my-zsh:** Open `~/.zshrc` and remove the line that sets `ZSH_THEME`. It might look like this: - `ZSH_THEME="powerlevel9k/powerlevel9k"`. -- **zplug:** Open `~/.zshrc` and remove the `zplug` command that refers to your current theme. For - example, if you are currently using Powerlevel9k, look for - `zplug bhilburn/powerlevel9k, use:powerlevel9k.zsh-theme`. -- **prezto:** Open `~/.zpreztorc` and put `zstyle :prezto:module:prompt theme off` in it. Remove - any other command that sets `theme` such as `zstyle :prezto:module:prompt theme powerlevel9k`. -- **antigen:** Open `~/.zshrc` and remove the line that sets `antigen theme`. It might look like - this: `antigen theme powerlevel9k/powerlevel9k`. - -2. Install Powerlevel10k manually. - -```zsh -git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k -echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc -``` - -This method of installation won't make anything slower or otherwise sub-par. - -### Directory is difficult to see in prompt when using Rainbow style - -In Rainbow style the current working directory is shown with bright white text on blue background. -The white is fixed and always looks the same but the appearance of "blue" is defined by your -terminal color palette. If it's very light, it may be difficult to see white text on it. - -There are several ways to fix this. - -- Type `p10k configure` and choose a more readable prompt style. -- [Change terminal color palette](#change-the-color-palette-used-by-your-terminal). Try Tango Dark - or Solarized Dark, or change just the "blue" color. -- [Change directory background and/or foreground color](#set-colors-through-Powerlevel10k-configuration-parameters). - The parameters you are looking for are called `POWERLEVEL9K_DIR_BACKGROUND`, - `POWERLEVEL9K_DIR_FOREGROUND`, `POWERLEVEL9K_DIR_SHORTENED_FOREGROUND`, - `POWERLEVEL9K_DIR_ANCHOR_FOREGROUND` and `POWERLEVEL9K_DIR_ANCHOR_BOLD`. You can find them in - `~/.p10k.zsh`. - -### Horrific mess when resizing terminal window - -When you resize a terminal window horizontally back and forth a few times, you might see this ugly -picture. - -![Powerlevel10k Resizing Mess]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resizing-mess.png) - -tl;dr: This issue arises when a terminal reflows Zsh prompt upon resizing. It isn't specific to -Powerlevel10k. See [mitigation](#mitigation). - -*Note: This section [used to say]( - https://github.com/romkatv/powerlevel10k/blob/dce00cdb5daaa8a519df234a7012ba3257b644d4/README.md#horrific-mess-when-resizing-terminal-window) -that the problem is caused by a bug in Zsh. While it's true that it's possible to avoid the problem -in many circumstances by modifying Zsh, it cannot be completely resolved this way. Thus it's unfair -to pin the blame on Zsh.* - -#### The anatomy of the problem - -The issue is manifested when the vertical distance between the start of the current prompt and the -cursor (henceforth `VD`) changes when the terminal window is resized. - -When a terminal window gets shrunk horizontally, there are two ways for a terminal to handle long -lines that no longer fit: *reflow* or *truncate*. - -Terminal content before shrinking: - -![Terminal Content Before Shrinking]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-original.png) - -Terminal reflows text when shrinking: - -![Terminal Reflows Text When Shrinking]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-reflow.png) - -Terminal truncates text when shrinking: - -![Terminal Truncates Text When Shrinking]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-truncate.png) - -Reflowing strategy can change the height of terminal content. If such content happens to be between -the start of the current prompt and the cursor, Zsh will print prompt on the wrong line. Truncation -strategy never changes the height of terminal content, so it doesn't trigger this issue. - -Let's see how the issue plays out in slow motion. We'll start by launching `zsh -f` and pasting -the following code: - -```zsh -function pause() { read -s } -functions -M pause 0 - -reset -print -l {1..3} -setopt prompt_subst -PROMPT=$'${$((pause()))+}left>${(pl.$((COLUMNS-12))..-.)}<right\n> ' -``` - -When `PROMPT` gets expanded, it calls `pause` to let us observe the state of the terminal. Here's -the initial state: - -![Terminal Resizing Bug 1]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-bug-1.png) - -Zsh keeps track of the cursor position relative to the start of the current prompt. In this case it -knows that the cursor is one line below. When we shrink the terminal window, it looks like this: - -![Terminal Resizing Bug 2]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-bug-2.png) - -At this point the terminal sends `SIGWINCH` to Zsh to notify it about changes in the terminal -dimensions. Note that this signal is sent *after* the content of the terminal has been reflown. - -When Zsh receives `SIGWINCH`, it attempts to erase the current prompt and print it anew. It goes to -the position where it *thinks* the current prompt is -- one line above the cursor (!) -- erases all -terminal content that follows and prints reexpanded prompt there. However, after resizing prompt is -no longer one line above the cursor. It's two lines above! Zsh ends up printing new prompt one line -too low. - -![Terminal Resizing Bug 3]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-bug-3.png) - -In this case we ended up with unwanted junk content because `VD` has *increased*. When you make -terminal window wider, `VD` can also *decrease*, which would result in the new prompt being printed -higher than intended, potentially erasing useful content in the process. - -Here are a few more examples where shrinking terminal window increased `VD`. - -- Simple one-line left prompt with right prompt. No `prompt_subst`. Note that the cursor is below - the prompt line (hit *ESC-ENTER* to get it there). - ![Zsh Prompt That Breaks on Terminal Shrinking 1]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-breakable-1.png) -- Simple one-line left prompt. No `prompt_subst`, no right prompt. Here `VD` is bound to increase - upon terminal shrinking due to the command line wrapping around. - ![Zsh Prompt That Breaks on Terminal Shrinking 2]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-breakable-2.png) - -#### Zsh patch - -[This Zsh patch](https://github.com/romkatv/zsh/tree/fix-winchanged) fixes the issue on some -terminals. The idea behind the patch is to use `sc` (save cursor) terminal capability before -printing prompt and `rc` (restore cursor) to move cursor back to the original position when prompt -needs to be refreshed. - -The patch works only on terminals that reflow saved cursor position together with text when the -terminal window is resized. The patch has no observable effect on terminals that don't reflow text -on resize (both patched and unpatched Zsh behave correctly) and on terminals that reflow text but -not the saved cursor position (both patched and unpatched Zsh redraw prompt at the same incorrect -position). In other words, the patch fixes the resizing issue on some terminals while keeping the -behavior unchanged on others. - -There are two alternative approaches to patching Zsh that may seem to work at first glance but in -fact don't: - -- Instead of `sc`, use `u7` terminal capability to query the current cursor position and then `cup` - to go back to it. This doesn't work because the absolute position of the start of the current - prompt changes when text gets reflown. -- Recompute `VD` based on new terminal dimensions before attempting to refresh prompt. This doesn't - work because Zsh doesn't know whether terminal reflows text or truncates it. If Zsh could somehow - know that the terminal reflows text, this approach still wouldn't work on terminals that - continuously reflow text and rapid-fire `SIGWINCH` when the window is being resized. In such - environment real terminal dimensions go out of sync with what Zsh thinks the dimensions are. - -There is no ETA for the patch making its way into upstream Zsh. See [discussion]( - https://www.zsh.org/mla/workers//2019/msg00561.html). - -#### Mitigation - -There are a few mitigation options for this issue. - -- Use [kitty](https://sw.kovidgoyal.net/kitty/) terminal version >= 0.24.0 and enable terminal-shell - integration in Powerlevel10k by defining `POWERLEVEL9K_TERM_SHELL_INTEGRATION=true` in - `~/.p10k.zsh`. -- Apply [the patch](#zsh-patch) and [rebuild Zsh from source]( - https://github.com/zsh-users/zsh/blob/master/INSTALL). It won't help if you are using Alacritty, - kitty or some other terminal that reflows text on resize but doesn't reflow saved cursor position. - On such terminals the patch will have no visible effect. -- Disable text reflowing on window resize in terminal settings. If your terminal doesn't have this - setting, try a different terminal. -- Avoid long lines between the start of prompt and cursor. - 1. Disable ruler with `POWERLEVEL9K_SHOW_RULER=false`. - 2. Disable prompt connection with `POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' '`. - 3. Disable right frame with `POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX=''`, - `POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX=''` and - `POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX=''`. - 4. Set `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()`. Right prompt on the last prompt line will cause - resizing issues only when the cursor is below it. This isn't very common, so you might want to - keep some elements in `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS` provided that none of them are - succeeded by `newline`. - -### Icons cut off in Konsole - -When using Konsole with a non-monospace font, icons may be cut off on the right side. Here -"non-monospace" refers to any font with glyphs wider than a single column, or wider than two columns -for glyphs designated as "wide" in the Unicode standard. - -![Icons cut off in Konsole]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/konsole-non-monospace-font.png) - -The last line on the screenshot shows a cut off Arch Linux logo. - -There are several mitigation options for this issue. - -1. Use a different terminal. Konsole is the only terminal that exhibits this behavior. -2. Use a monospace font. -3. Manually add an extra space after the icon that gets cut off. For example, if the content of - `os_icon` prompt segment gets cut off, open `~/.p10k.zsh`, search for - `POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION` and change it as follows: -```zsh -typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='${P9K_CONTENT} ' # extra space at the end -``` -4. Use a different icon that is monospace. For example, if Arch Linux logo gets cut off, add - the following parameter to `~/.p10k.zsh`: -```zsh -typeset -g POWERLEVEL9K_LINUX_ARCH_ICON='Arch' # plain "Arch" in place of a logo -``` -5. Disable the display of the icon that gets cut off. For example, if the content of - `os_icon` prompt segment gets cut off, open `~/.p10k.zsh` and remove `os_icon` from - `POWERLEVEL9K_LEFT_PROMPT_ELEMENTS` and `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`. - -*Note*: [Non-monospace fonts are not officially supported by Konsole]( - https://bugs.kde.org/show_bug.cgi?id=418553#c5). - -### Arch Linux logo has a dot in the bottom right corner - -![Arch Linux Logo with a dot]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/arch-linux-logo-dot.png) - -Some fonts have this incorrect dotted icon in bold typeface. There are two ways to fix this issue. - -1. Use a font with a correct Arch Linux logo in bold typeface. For example, - [the recommended Powerlevel10k font](#meslo-nerd-font-patched-for-powerlevel10k). -2. Display the icon in regular (non-bold) typeface. To do this, open `~/.p10k.zsh`, search for - `POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION` and remove `%B` from its value. -```zsh -typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='${P9K_CONTENT}' # not bold -``` diff --git a/.zsh/themes/powerlevel10k/config/p10k-classic.zsh b/.zsh/themes/powerlevel10k/config/p10k-classic.zsh deleted file mode 100644 index 24c4022..0000000 --- a/.zsh/themes/powerlevel10k/config/p10k-classic.zsh +++ /dev/null @@ -1,1657 +0,0 @@ -# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate -# your own config based on it. -# -# Tip: Looking for a nice color? Here's a one-liner to print colormap. -# -# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done - -# Temporarily change options. -'builtin' 'local' '-a' 'p10k_config_opts' -[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -() { - emulate -L zsh -o extended_glob - - # Unset all configuration options. This allows you to apply configuration changes without - # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. - unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' - - # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return - - # The list of segments shown on the left. Fill it with the most important segments. - typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - # os_icon # os identifier - dir # current directory - vcs # git status - # =========================[ Line #2 ]========================= - newline # \n - # prompt_char # prompt symbol - ) - - # The list of segments shown on the right. Fill it with less important segments. - # Right prompt on the last prompt line (where you are typing your commands) gets - # automatically hidden when the input line reaches it. Right prompt above the - # last prompt line gets hidden if it would overlap with left prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - status # exit code of the last command - command_execution_time # duration of the last command - background_jobs # presence of background jobs - direnv # direnv status (https://direnv.net/) - asdf # asdf version manager (https://github.com/asdf-vm/asdf) - virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) - anaconda # conda environment (https://conda.io/) - pyenv # python environment (https://github.com/pyenv/pyenv) - goenv # go environment (https://github.com/syndbg/goenv) - nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) - nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) - nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) - # node_version # node.js version - # go_version # go version (https://golang.org) - # rust_version # rustc version (https://www.rust-lang.org) - # dotnet_version # .NET version (https://dotnet.microsoft.com) - # php_version # php version (https://www.php.net/) - # laravel_version # laravel php framework version (https://laravel.com/) - # java_version # java version (https://www.java.com/) - # package # name@version from package.json (https://docs.npmjs.com/files/package.json) - rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) - rvm # ruby version from rvm (https://rvm.io) - fvm # flutter version management (https://github.com/leoafarias/fvm) - luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) - jenv # java version from jenv (https://github.com/jenv/jenv) - plenv # perl version from plenv (https://github.com/tokuhirom/plenv) - perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) - phpenv # php version from phpenv (https://github.com/phpenv/phpenv) - scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) - haskell_stack # haskell version from stack (https://haskellstack.org/) - kubecontext # current kubernetes context (https://kubernetes.io/) - terraform # terraform workspace (https://www.terraform.io) - # terraform_version # terraform version (https://www.terraform.io) - aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) - aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) - azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) - gcloud # google cloud cli account and project (https://cloud.google.com/) - google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) - toolbox # toolbox name (https://github.com/containers/toolbox) - context # user@hostname - nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) - ranger # ranger shell (https://github.com/ranger/ranger) - nnn # nnn shell (https://github.com/jarun/nnn) - xplr # xplr shell (https://github.com/sayanarijit/xplr) - vim_shell # vim shell indicator (:sh) - midnight_commander # midnight commander shell (https://midnight-commander.org/) - nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) - # vi_mode # vi mode (you don't need this if you've enabled prompt_char) - # vpn_ip # virtual private network indicator - # load # CPU load - # disk_usage # disk usage - # ram # free RAM - # swap # used swap - todo # todo items (https://github.com/todotxt/todo.txt-cli) - timewarrior # timewarrior tracking status (https://timewarrior.net/) - taskwarrior # taskwarrior task count (https://taskwarrior.org/) - # cpu_arch # CPU architecture - # time # current time - # =========================[ Line #2 ]========================= - newline # \n - # ip # ip address and bandwidth usage for a specified network interface - # public_ip # public IP address - # proxy # system-wide http/https/ftp proxy - # battery # internal battery - # wifi # wifi speed - # example # example user-defined segment (see prompt_example function below) - ) - - # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. - typeset -g POWERLEVEL9K_MODE=nerdfont-complete - # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid - # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. - typeset -g POWERLEVEL9K_ICON_PADDING=none - - # When set to true, icons appear before content on both sides of the prompt. When set - # to false, icons go after content. If empty or not set, icons go before content in the left - # prompt and after content in the right prompt. - # - # You can also override it for a specific segment: - # - # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false - # - # Or for a specific segment in specific state: - # - # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false - typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT= - - # Add an empty line before each prompt. - typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true - - # Connect left prompt lines with these symbols. You'll probably want to use the same color - # as POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND below. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='%242F╭─' - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX='%242F├─' - typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='%242F╰─' - # Connect right prompt lines with these symbols. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX='%242F─╮' - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX='%242F─┤' - typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX='%242F─╯' - - # Filler between left and right prompt on the first prompt line. You can set it to ' ', '·' or - # '─'. The last two make it easier to see the alignment between left and right prompt and to - # separate prompt from command output. You might want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false - # for more compact prompt if using this option. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_BACKGROUND= - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_BACKGROUND= - if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then - # The color of the filler. You'll probably want to match the color of POWERLEVEL9K_MULTILINE - # ornaments defined above. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=242 - # Start filler from the edge of the screen if there are no left segments on the first line. - typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' - # End filler on the edge of the screen if there are no right segments on the first line. - typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' - fi - - # Default background color. - typeset -g POWERLEVEL9K_BACKGROUND=238 - - # Separator between same-color segments on the left. - typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='%246F\uE0B1' - # Separator between same-color segments on the right. - typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='%246F\uE0B3' - # Separator between different-color segments on the left. - typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0' - # Separator between different-color segments on the right. - typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0B2' - # The right end of left prompt. - typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0B0' - # The left end of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='\uE0B2' - # The left end of left prompt. - typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= - # The right end of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= - # Left prompt terminator for lines without any segments. - typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= - - #################################[ os_icon: os identifier ]################################## - # OS identifier color. - typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=255 - # Custom icon. - # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' - - ################################[ prompt_char: prompt symbol ]################################ - # Transparent background. - typeset -g POWERLEVEL9K_PROMPT_CHAR_BACKGROUND= - # Green prompt symbol if the last command succeeded. - typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 - # Red prompt symbol if the last command failed. - typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 - # Default prompt symbol. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' - # Prompt symbol in command vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' - # Prompt symbol in visual vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' - # Prompt symbol in overwrite vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' - typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true - # No line terminator if prompt_char is the last segment. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= - # No line introducer if prompt_char is the first segment. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= - # No surrounding whitespace. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_{LEFT,RIGHT}_WHITESPACE= - - ##################################[ dir: current directory ]################################## - # Default current directory color. - typeset -g POWERLEVEL9K_DIR_FOREGROUND=31 - # If directory is too long, shorten some of its segments to the shortest possible unique - # prefix. The shortened directory can be tab-completed to the original. - typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique - # Replace removed segment suffixes with this symbol. - typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= - # Color of the shortened directory segments. - typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103 - # Color of the anchor directory segments. Anchor segments are never shortened. The first - # segment is always an anchor. - typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 - # Display anchor directory segments in bold. - typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true - # Don't shorten directories that contain any of these files. They are anchors. - local anchor_files=( - .bzr - .citc - .git - .hg - .node-version - .python-version - .go-version - .ruby-version - .lua-version - .java-version - .perl-version - .php-version - .tool-version - .shorten_folder_marker - .svn - .terraform - CVS - Cargo.toml - composer.json - go.mod - package.json - stack.yaml - ) - typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" - # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains - # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is - # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) - # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers - # and other directories don't. - # - # Optionally, "first" and "last" can be followed by ":<offset>" where <offset> is an integer. - # This moves the truncation point to the right (positive offset) or to the left (negative offset) - # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" - # respectively. - typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false - # Don't shorten this many last directory segments. They are anchors. - typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 - # Shorten directory if it's longer than this even if there is space for it. The value can - # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, - # directory will be shortened only when prompt doesn't fit or when other parameters demand it - # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). - # If set to `0`, directory will always be shortened to its minimum length. - typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 - # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this - # many columns for typing commands. - typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 - # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least - # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. - typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 - # If set to true, embed a hyperlink into the directory. Useful for quickly - # opening a directory in the file manager simply by clicking the link. - # Can also be handy when the directory is shortened, as it allows you to see - # the full directory that was used in previous commands. - typeset -g POWERLEVEL9K_DIR_HYPERLINK=false - - # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON - # and POWERLEVEL9K_DIR_CLASSES below. - typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 - - # The default icon shown next to non-writable and non-existent directories when - # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. - # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' - - # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different - # directories. It must be an array with 3 * N elements. Each triplet consists of: - # - # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with - # extended_glob option enabled. - # 2. Directory class for the purpose of styling. - # 3. An empty string. - # - # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. - # - # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories - # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_DIR_CLASSES=( - # '~/work(|/*)' WORK '' - # '~(|/*)' HOME '' - # '*' DEFAULT '') - # - # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one - # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or - # WORK_NON_EXISTENT. - # - # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an - # option to define custom colors and icons for different directory classes. - # - # # Styling for WORK. - # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 - # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 - # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 - # - # # Styling for WORK_NOT_WRITABLE. - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=31 - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 - # - # # Styling for WORK_NON_EXISTENT. - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31 - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103 - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39 - # - # If a styling parameter isn't explicitly defined for some class, it falls back to the classless - # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls - # back to POWERLEVEL9K_DIR_FOREGROUND. - # - # typeset -g POWERLEVEL9K_DIR_CLASSES=() - - # Custom prefix. - # typeset -g POWERLEVEL9K_DIR_PREFIX='%248Fin ' - - #####################################[ vcs: git status ]###################################### - # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. - typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= - - # Untracked files icon. It's really a question mark, your font isn't broken. - # Change the value of this parameter to show a different icon. - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' - - # Formatter for Git status. - # - # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. - # - # You can edit the function to customize how Git status looks. - # - # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: - # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. - function my_git_formatter() { - emulate -L zsh - - if [[ -n $P9K_CONTENT ]]; then - # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from - # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. - typeset -g my_git_format=$P9K_CONTENT - return - fi - - if (( $1 )); then - # Styling for up-to-date Git status. - local meta='%248F' # grey foreground - local clean='%76F' # green foreground - local modified='%178F' # yellow foreground - local untracked='%39F' # blue foreground - local conflicted='%196F' # red foreground - else - # Styling for incomplete and stale Git status. - local meta='%244F' # grey foreground - local clean='%244F' # grey foreground - local modified='%244F' # grey foreground - local untracked='%244F' # grey foreground - local conflicted='%244F' # grey foreground - fi - - local res - - if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - local branch=${(V)VCS_STATUS_LOCAL_BRANCH} - # If local branch name is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show local branch name in full without truncation, delete the next line. - (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line - res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" - fi - - if [[ -n $VCS_STATUS_TAG - # Show tag only if not on a branch. - # Tip: To always show tag, delete the next line. - && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line - ]]; then - local tag=${(V)VCS_STATUS_TAG} - # If tag name is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show tag name in full without truncation, delete the next line. - (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line - res+="${meta}#${clean}${tag//\%/%%}" - fi - - # Display the current Git commit if there is no branch and no tag. - # Tip: To always display the current Git commit, delete the next line. - [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line - res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" - - # Show tracking branch name if it differs from local branch. - if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then - res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" - fi - - # Display "wip" if the latest commit's summary contains "wip" or "WIP". - if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then - res+=" ${modified}wip" - fi - - # ⇣42 if behind the remote. - (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" - # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. - (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " - (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" - # ⇠42 if behind the push remote. - (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" - (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " - # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. - (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" - # *42 if have stashes. - (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" - # 'merge' if the repo is in an unusual state. - [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" - # ~42 if have merge conflicts. - (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" - # +42 if have staged changes. - (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" - # !42 if have unstaged changes. - (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" - # ?42 if have untracked files. It's really a question mark, your font isn't broken. - # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. - # Remove the next line if you don't want to see untracked files at all. - (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" - # "─" if the number of unstaged files is unknown. This can happen due to - # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower - # than the number of files in the Git index, or due to bash.showDirtyState being set to false - # in the repository config. The number of staged and untracked files may also be unknown - # in this case. - (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" - - typeset -g my_git_format=$res - } - functions -M my_git_formatter 2>/dev/null - - # Don't count the number of unstaged, untracked and conflicted files in Git repositories with - # more than this many files in the index. Negative value means infinity. - # - # If you are working in Git repositories with tens of millions of files and seeing performance - # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output - # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's - # config: `git config bash.showDirtyState false`. - typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 - - # Don't show Git status in prompt for repositories whose workdir matches this pattern. - # For example, if set to '~', the Git repository at $HOME/.git will be ignored. - # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. - typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' - - # Disable the default Git status formatting. - typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true - # Install our own Git status formatter. - typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' - typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' - # Enable counters for staged, unstaged, etc. - typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 - - # Icon color. - typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 - typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 - # Custom icon. - # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_VCS_PREFIX='%248Fon ' - - # Show status of repositories of these types. You can add svn and/or hg if you are - # using them. If you do, your prompt may become slow even when your current directory - # isn't in an svn or hg reposotiry. - typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) - - # These settings are used for repositories other than Git or when gitstatusd fails and - # Powerlevel10k has to fall back to using vcs_info. - typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 - typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 - typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 - - ##########################[ status: exit code of the last command ]########################### - # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and - # style them independently from the regular OK and ERROR state. - typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true - - # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as - # it will signify success by turning green. - typeset -g POWERLEVEL9K_STATUS_OK=true - typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70 - typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' - - # Status when some part of a pipe command fails but the overall exit status is zero. It may look - # like this: 1|0. - typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true - typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70 - typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' - - # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as - # it will signify error by turning red. - typeset -g POWERLEVEL9K_STATUS_ERROR=true - typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 - typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' - - # Status when the last command was terminated by a signal. - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160 - # Use terse signal names: "INT" instead of "SIGINT(2)". - typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' - - # Status when some part of a pipe command fails and the overall exit status is also non-zero. - # It may look like this: 1|0. - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160 - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' - - ###################[ command_execution_time: duration of the last command ]################### - # Show duration of the last command if takes at least this many seconds. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 - # Show this many fractional digits. Zero means round to seconds. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 - # Execution time color. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=248 - # Duration format: 1d 2h 3m 4s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' - # Custom icon. - # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%248Ftook ' - - #######################[ background_jobs: presence of background jobs ]####################### - # Don't show the number of background jobs. - typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false - # Background jobs color. - typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=37 - # Custom icon. - # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ direnv: direnv status (https://direnv.net/) ]######################## - # Direnv color. - typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 - # Custom icon. - # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### - # Default asdf color. Only used to display tools for which there is no color override (see below). - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND. - typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66 - - # There are four parameters that can be used to hide asdf tools. Each parameter describes - # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at - # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to - # hide a tool, it gets shown. - # - # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and - # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: - # - # asdf local python 3.8.1 - # asdf global python 3.8.1 - # - # After running both commands the current python version is 3.8.1 and its source is "local" as - # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, - # it'll hide python version in this case because 3.8.1 is the same as the global version. - # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't - # contain "local". - - # Hide tool versions that don't come from one of these sources. - # - # Available sources: - # - # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" - # - local `asdf current` says "set by /some/not/home/directory/file" - # - global `asdf current` says "set by /home/username/file" - # - # Note: If this parameter is set to (shell local global), it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. - typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) - - # If set to false, hide tool versions that are the same as global. - # - # Note: The name of this parameter doesn't reflect its meaning at all. - # Note: If this parameter is set to true, it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. - typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false - - # If set to false, hide tool versions that are equal to "system". - # - # Note: If this parameter is set to true, it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. - typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true - - # If set to non-empty value, hide tools unless there is a file matching the specified file pattern - # in the current directory, or its parent directory, or its grandparent directory, and so on. - # - # Note: If this parameter is set to empty value, it won't hide tools. - # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. - # - # Example: Hide nodejs version when there is no package.json and no *.js files in the current - # directory, in `..`, in `../..` and so on. - # - # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' - typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= - - # Ruby version from asdf. - typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168 - # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Python version from asdf. - typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=37 - # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Go version from asdf. - typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37 - # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Node.js version from asdf. - typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70 - # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Rust version from asdf. - typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37 - # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' - - # .NET Core version from asdf. - typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134 - # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Flutter version from asdf. - typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38 - # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Lua version from asdf. - typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32 - # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Java version from asdf. - typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32 - # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Perl version from asdf. - typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67 - # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Erlang version from asdf. - typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125 - # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Elixir version from asdf. - typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129 - # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Postgres version from asdf. - typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31 - # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' - - # PHP version from asdf. - typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 - # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Haskell version from asdf. - typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172 - # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Julia version from asdf. - typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70 - # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' - - ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### - # NordVPN connection indicator color. - typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 - # Hide NordVPN connection indicator when not connected. - typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= - typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= - # Custom icon. - # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## - # Ranger shell color. - typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 - # Custom icon. - # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### - # Nnn shell color. - typeset -g POWERLEVEL9K_NNN_FOREGROUND=72 - # Custom icon. - # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## - # xplr shell color. - typeset -g POWERLEVEL9K_XPLR_FOREGROUND=72 - # Custom icon. - # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########################[ vim_shell: vim shell indicator (:sh) ]########################### - # Vim shell indicator color. - typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34 - # Custom icon. - # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### - # Midnight Commander shell color. - typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=178 - # Custom icon. - # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## - # Nix shell color. - typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 - - # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. - # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################################[ disk_usage: disk usage ]################################## - # Colors for different levels of disk usage. - typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 - typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=220 - typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=160 - # Thresholds for different levels of disk usage (percentage points). - typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 - typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 - # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. - typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false - # Custom icon. - # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ vi_mode: vi mode (you don't need this if you've enabled prompt_char) ]########### - # Text and color for normal (a.k.a. command) vi mode. - typeset -g POWERLEVEL9K_VI_COMMAND_MODE_STRING=NORMAL - typeset -g POWERLEVEL9K_VI_MODE_NORMAL_FOREGROUND=106 - # Text and color for visual vi mode. - typeset -g POWERLEVEL9K_VI_VISUAL_MODE_STRING=VISUAL - typeset -g POWERLEVEL9K_VI_MODE_VISUAL_FOREGROUND=68 - # Text and color for overtype (a.k.a. overwrite and replace) vi mode. - typeset -g POWERLEVEL9K_VI_OVERWRITE_MODE_STRING=OVERTYPE - typeset -g POWERLEVEL9K_VI_MODE_OVERWRITE_FOREGROUND=172 - # Text and color for insert vi mode. - typeset -g POWERLEVEL9K_VI_INSERT_MODE_STRING= - typeset -g POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND=66 - - # Custom icon. - # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################################[ ram: free RAM ]####################################### - # RAM color. - typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 - # Custom icon. - # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################################[ swap: used swap ]###################################### - # Swap color. - typeset -g POWERLEVEL9K_SWAP_FOREGROUND=96 - # Custom icon. - # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################################[ load: CPU load ]###################################### - # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. - typeset -g POWERLEVEL9K_LOAD_WHICH=5 - # Load color when load is under 50%. - typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 - # Load color when load is between 50% and 70%. - typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 - # Load color when load is over 70%. - typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 - # Custom icon. - # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ - # Todo color. - typeset -g POWERLEVEL9K_TODO_FOREGROUND=110 - # Hide todo when the total number of tasks is zero. - typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true - # Hide todo when the number of tasks after filtering is zero. - typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false - - # Todo format. The following parameters are available within the expansion. - # - # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. - # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. - # - # These variables correspond to the last line of the output of `todo.sh -p ls`: - # - # TODO: 24 of 42 tasks shown - # - # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. - # - # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' - - # Custom icon. - # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ - # Timewarrior color. - typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110 - # If the tracked task is longer than 24 characters, truncate and append "…". - # Tip: To always display tasks without truncation, delete the following parameter. - # Tip: To hide task names and display just the icon when time tracking is enabled, set the - # value of the following parameter to "". - typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' - - # Custom icon. - # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## - # Taskwarrior color. - typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74 - - # Taskwarrior segment format. The following parameters are available within the expansion. - # - # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. - # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. - # - # Zero values are represented as empty parameters. - # - # The default format: - # - # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' - # - # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' - - # Custom icon. - # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ cpu_arch: CPU architecture ]################################ - # CPU architecture color. - typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172 - - # Hide the segment when on a specific CPU architecture. - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################################[ context: user@hostname ]################################## - # Context color when running with privileges. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 - # Context color in SSH without privileges. - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180 - # Default context color (no privileges, no SSH). - typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 - - # Context format when running with privileges: bold user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' - # Context format when in SSH without privileges: user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' - # Default context format (no privileges, no SSH): user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' - - # Don't show context unless running with privileges or in SSH. - # Tip: Remove the next line to always show context. - typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%248Fwith ' - - ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### - # Python virtual environment color. - typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 - # Don't show Python version next to the virtual environment name. - typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false - # If set to "false", won't show virtualenv if pyenv is already shown. - # If set to "if-different", won't show virtualenv if it's the same as pyenv. - typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false - # Separate environment name from Python version only with a space. - typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= - # Custom icon. - # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################[ anaconda: conda environment (https://conda.io/) ]###################### - # Anaconda environment color. - typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 - - # Anaconda segment format. The following parameters are available within the expansion. - # - # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. - # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. - # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). - # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). - # - # CONDA_PROMPT_MODIFIER can be configured with the following command: - # - # conda config --set env_prompt '({default_env}) ' - # - # The last argument is a Python format string that can use the following variables: - # - # - prefix The same as CONDA_PREFIX. - # - default_env The same as CONDA_DEFAULT_ENV. - # - name The last segment of CONDA_PREFIX. - # - stacked_env Comma-separated list of names in the environment stack. The first element is - # always the same as default_env. - # - # Note: '({default_env}) ' is the default value of env_prompt. - # - # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER - # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former - # is empty. - typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' - - # Custom icon. - # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ - # Pyenv color. - typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 - # Hide python version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) - # If set to false, hide python version if it's the same as global: - # $(pyenv version-name) == $(pyenv global). - typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide python version if it's equal to "system". - typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true - - # Pyenv segment format. The following parameters are available within the expansion. - # - # - P9K_CONTENT Current pyenv environment (pyenv version-name). - # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). - # - # The default format has the following logic: - # - # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or - # starts with "$P9K_PYENV_PYTHON_VERSION/". - # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". - typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' - - # Custom icon. - # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ - # Goenv color. - typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37 - # Hide go version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) - # If set to false, hide go version if it's the same as global: - # $(goenv version-name) == $(goenv global). - typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide go version if it's equal to "system". - typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## - # Nodenv color. - typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70 - # Hide node version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) - # If set to false, hide node version if it's the same as global: - # $(nodenv version-name) == $(nodenv global). - typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide node version if it's equal to "system". - typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### - # Nvm color. - typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 - # Custom icon. - # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ - # Nodeenv color. - typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70 - # Don't show Node version next to the environment name. - typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false - # Separate environment name from Node version only with a space. - typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= - # Custom icon. - # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############################[ node_version: node.js version ]############################### - # Node version color. - typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70 - # Show node version only when in a directory tree containing package.json. - typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ go_version: go version (https://golang.org) ]######################## - # Go version color. - typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 - # Show go version only when in a go project subdirectory. - typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## - # Rust version color. - typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 - # Show rust version only when in a rust project subdirectory. - typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ - # .NET version color. - typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 - # Show .NET version only when in a .NET project subdirectory. - typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################[ php_version: php version (https://www.php.net/) ]###################### - # PHP version color. - typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 - # Show PHP version only when in a PHP project subdirectory. - typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### - # Laravel version color. - typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 - # Custom icon. - # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ####################[ java_version: java version (https://www.java.com/) ]#################### - # Java version color. - typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32 - # Show java version only when in a java project subdirectory. - typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true - # Show brief version. - typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false - # Custom icon. - # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### - # Package color. - typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117 - # Package format. The following parameters are available within the expansion. - # - # - P9K_PACKAGE_NAME The value of `name` field in package.json. - # - P9K_PACKAGE_VERSION The value of `version` field in package.json. - # - # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' - # Custom icon. - # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## - # Rbenv color. - typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 - # Hide ruby version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) - # If set to false, hide ruby version if it's the same as global: - # $(rbenv version-name) == $(rbenv global). - typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide ruby version if it's equal to "system". - typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## - # Rvm color. - typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 - # Don't show @gemset at the end. - typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false - # Don't show ruby- at the front. - typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ - # Fvm color. - typeset -g POWERLEVEL9K_FVM_FOREGROUND=38 - # Custom icon. - # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### - # Lua color. - typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32 - # Hide lua version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) - # If set to false, hide lua version if it's the same as global: - # $(luaenv version-name) == $(luaenv global). - typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide lua version if it's equal to "system". - typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ - # Java color. - typeset -g POWERLEVEL9K_JENV_FOREGROUND=32 - # Hide java version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) - # If set to false, hide java version if it's the same as global: - # $(jenv version-name) == $(jenv global). - typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide java version if it's equal to "system". - typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ - # Perl color. - typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67 - # Hide perl version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) - # If set to false, hide perl version if it's the same as global: - # $(plenv version-name) == $(plenv global). - typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide perl version if it's equal to "system". - typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ - # Perlbrew color. - typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 - # Show perlbrew version only when in a perl project subdirectory. - typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true - # Don't show "perl-" at the front. - typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ - # PHP color. - typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 - # Hide php version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) - # If set to false, hide php version if it's the same as global: - # $(phpenv version-name) == $(phpenv global). - typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide php version if it's equal to "system". - typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### - # Scala color. - typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160 - # Hide scala version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) - # If set to false, hide scala version if it's the same as global: - # $(scalaenv version-name) == $(scalaenv global). - typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide scala version if it's equal to "system". - typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### - # Haskell color. - typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172 - # Hide haskell version if it doesn't come from one of these sources. - # - # shell: version is set by STACK_YAML - # local: version is set by stack.yaml up the directory tree - # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) - typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) - # If set to false, hide haskell version if it's the same as in the implicit global project. - typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true - # Custom icon. - # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ terraform: terraform workspace (https://www.terraform.io) ]################# - # Don't show terraform workspace if it's literally "default". - typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false - # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current terraform workspace gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' OTHER) - # - # If your current terraform workspace is "project_test", its class is TEST because "project_test" - # doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' OTHER) - typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 - # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ terraform_version: terraform version (https://www.terraform.io) ]############## - # Terraform version color. - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38 - # Custom icon. - # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# - # Show kubecontext only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show kubecontext. - typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold' - - # Kubernetes context classes for the purpose of using different colors, icons and expansions with - # different contexts. - # - # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current kubernetes context gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' DEFAULT) - # - # If your current kubernetes context is "deathray-testing/default", its class is TEST - # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134 - # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext - # segment. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - # - # Within the expansion the following parameters are always available: - # - # - P9K_CONTENT The content that would've been displayed if there was no content - # expansion defined. - # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the - # output of `kubectl config get-contexts`. - # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the - # output of `kubectl config get-contexts`. - # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE - # in the output of `kubectl config get-contexts`. If there is no - # namespace, the parameter is set to "default". - # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the - # output of `kubectl config get-contexts`. - # - # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), - # the following extra parameters are available: - # - # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. - # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. - # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. - # - # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, - # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": - # - # - P9K_KUBECONTEXT_CLOUD_NAME=gke - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account - # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a - # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - # - # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": - # - # - P9K_KUBECONTEXT_CLOUD_NAME=eks - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 - # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 - # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= - # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. - POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' - # Append the current context's namespace if it's not "default". - POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' - - # Custom prefix. - # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%248Fat ' - - #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# - # Show aws only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show aws. - typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' - - # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current AWS profile gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_AWS_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' DEFAULT) - # - # If your current AWS profile is "company_test", its class is TEST - # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_AWS_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 - # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # AWS segment format. The following parameters are available within the expansion. - # - # - P9K_AWS_PROFILE The name of the current AWS profile. - # - P9K_AWS_REGION The region associated with the current AWS profile. - typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' - - #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# - # AWS Elastic Beanstalk environment color. - typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 - # Custom icon. - # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## - # Show azure only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show azure. - typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' - # Azure account name color. - typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 - # Custom icon. - # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### - # Show gcloud only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show gcloud. - typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' - # Google cloud color. - typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 - - # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or - # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative - # enough. You can use the following parameters in the expansions. Each of them corresponds to the - # output of `gcloud` tool. - # - # Parameter | Source - # -------------------------|-------------------------------------------------------------------- - # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' - # P9K_GCLOUD_ACCOUNT | gcloud config get-value account - # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project - # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' - # - # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. - # - # Obtaining project name requires sending a request to Google servers. This can take a long time - # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud - # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets - # set and gcloud prompt segment transitions to state COMPLETE. - # - # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL - # and COMPLETE. You can also hide gcloud in state PARTIAL by setting - # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and - # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. - typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' - typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' - - # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name - # this often. Negative value disables periodic polling. In this mode project name is retrieved - # only when the current configuration, account or project id changes. - typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 - - # Custom icon. - # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# - # Show google_app_cred only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show google_app_cred. - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' - - # Google application credentials classes for the purpose of using different colors, icons and - # expansions with different credentials. - # - # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first - # element in each pair defines a pattern against which the current kubernetes context gets - # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion - # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION - # parameters, you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. - # The first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( - # '*:*prod*:*' PROD - # '*:*test*:*' TEST - # '*' DEFAULT) - # - # If your current Google application credentials is "service_account deathray-testing x@y.com", - # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( - # '*:*prod*:*' PROD # These values are examples that are unlikely - # '*:*test*:*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32 - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by - # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - # - # You can use the following parameters in the expansion. Each of them corresponds to one of the - # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. - # - # Parameter | JSON key file field - # ---------------------------------+--------------- - # P9K_GOOGLE_APP_CRED_TYPE | type - # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id - # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email - # - # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' - - ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### - # Toolbox color. - typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178 - # Don't display the name of the toolbox if it matches fedora-toolbox-*. - typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' - # Custom icon. - # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%248Fin ' - - ###############################[ public_ip: public IP address ]############################### - # Public IP color. - typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 - # Custom icon. - # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ########################[ vpn_ip: virtual private network indicator ]######################### - # VPN IP color. - typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 - # When on VPN, show just an icon without the IP address. - # Tip: To display the private IP address when on VPN, remove the next line. - typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= - # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN - # to see the name of the interface. - typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*' - # If set to true, show one segment per matching network interface. If set to false, show only - # one segment corresponding to the first matching network interface. - # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. - typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false - # Custom icon. - # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### - # IP color. - typeset -g POWERLEVEL9K_IP_FOREGROUND=38 - # The following parameters are accessible within the expansion: - # - # Parameter | Meaning - # ----------------------+------------------------------------------- - # P9K_IP_IP | IP address - # P9K_IP_INTERFACE | network interface - # P9K_IP_RX_BYTES | total number of bytes received - # P9K_IP_TX_BYTES | total number of bytes sent - # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt - # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt - # P9K_IP_RX_RATE | receive rate (since last prompt) - # P9K_IP_TX_RATE | send rate (since last prompt) - typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='${P9K_IP_RX_RATE:+%70F⇣$P9K_IP_RX_RATE }${P9K_IP_TX_RATE:+%215F⇡$P9K_IP_TX_RATE }%38F$P9K_IP_IP' - # Show information for the first network interface whose name matches this regular expression. - # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. - typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' - # Custom icon. - # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #########################[ proxy: system-wide http/https/ftp proxy ]########################## - # Proxy color. - typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 - # Custom icon. - # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ battery: internal battery ]################################# - # Show battery in red when it's below this level and not connected to power supply. - typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 - typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 - # Show battery in green when it's charging or fully charged. - typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 - # Show battery in yellow when it's discharging. - typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 - # Battery pictograms going from low to high level of charge. - typeset -g POWERLEVEL9K_BATTERY_STAGES=('%K{232}▁' '%K{232}▂' '%K{232}▃' '%K{232}▄' '%K{232}▅' '%K{232}▆' '%K{232}▇' '%K{232}█') - # Don't show the remaining time to charge/discharge. - typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false - - #####################################[ wifi: wifi speed ]##################################### - # WiFi color. - typeset -g POWERLEVEL9K_WIFI_FOREGROUND=68 - # Custom icon. - # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). - # - # # Wifi colors and icons for different signal strength levels (low to high). - # typeset -g my_wifi_fg=(68 68 68 68 68) # <-- change these values - # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values - # - # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' - # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' - # - # The following parameters are accessible within the expansions: - # - # Parameter | Meaning - # ----------------------+--------------- - # P9K_WIFI_SSID | service set identifier, a.k.a. network name - # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown - # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second - # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 - # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 - # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) - - ####################################[ time: current time ]#################################### - # Current time color. - typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 - # Format for the current time: 09:51:02. See `man 3 strftime`. - typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' - # If set to true, time will update when you hit enter. This way prompts for the past - # commands will contain the start times of their commands as opposed to the default - # behavior where they contain the end times of their preceding commands. - typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false - # Custom icon. - # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TIME_PREFIX='%248Fat ' - - # Example of a user-defined prompt segment. Function prompt_example will be called on every - # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or - # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. - # - # Type `p10k help segment` for documentation and a more sophisticated example. - function prompt_example() { - p10k segment -f 208 -i '⭐' -t 'hello, %n' - } - - # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job - # is to generate the prompt segment for display in instant prompt. See - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function - # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k - # will replay these calls without actually calling instant_prompt_*. It is imperative that - # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this - # rule is not observed, the content of instant prompt will be incorrect. - # - # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If - # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. - function instant_prompt_example() { - # Since prompt_example always makes the same `p10k segment` calls, we can call it from - # instant_prompt_example. This will give us the same `example` prompt segment in the instant - # and regular prompts. - prompt_example - } - - # User-defined prompt segments can be customized the same way as built-in segments. - # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 - # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt - # when accepting a command line. Supported values: - # - # - off: Don't change prompt when accepting a command line. - # - always: Trim down prompt when accepting a command line. - # - same-dir: Trim down prompt when accepting a command line unless this is the first command - # typed after changing current working directory. - typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off - - # Instant prompt mode. - # - # - off: Disable instant prompt. Choose this if you've tried instant prompt and found - # it incompatible with your zsh configuration files. - # - quiet: Enable instant prompt and don't print warnings when detecting console output - # during zsh initialization. Choose this if you've read and understood - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - verbose: Enable instant prompt and print a warning when detecting console output during - # zsh initialization. Choose this if you've never tried instant prompt, haven't - # seen the warning, or if you are unsure what this all means. - typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose - - # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. - # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload - # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you - # really need it. - typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true - - # If p10k is already loaded, reload configuration. - # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. - (( ! $+functions[p10k] )) || p10k reload -} - -# Tell `p10k configure` which file it should overwrite. -typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} - -(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} -'builtin' 'unset' 'p10k_config_opts' diff --git a/.zsh/themes/powerlevel10k/config/p10k-lean-8colors.zsh b/.zsh/themes/powerlevel10k/config/p10k-lean-8colors.zsh deleted file mode 100644 index 1d2962a..0000000 --- a/.zsh/themes/powerlevel10k/config/p10k-lean-8colors.zsh +++ /dev/null @@ -1,1638 +0,0 @@ -# Config for Powerlevel10k with 8-color lean prompt style. Type `p10k configure` to generate -# your own config based on it. -# -# Tip: Looking for a nice color? Here's a one-liner to print colormap. -# -# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done - -# Temporarily change options. -'builtin' 'local' '-a' 'p10k_config_opts' -[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -() { - emulate -L zsh -o extended_glob - - # Unset all configuration options. This allows you to apply configuration changes without - # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. - unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' - - # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return - - # The list of segments shown on the left. Fill it with the most important segments. - typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - # os_icon # os identifier - dir # current directory - vcs # git status - # =========================[ Line #2 ]========================= - newline # \n - prompt_char # prompt symbol - ) - - # The list of segments shown on the right. Fill it with less important segments. - # Right prompt on the last prompt line (where you are typing your commands) gets - # automatically hidden when the input line reaches it. Right prompt above the - # last prompt line gets hidden if it would overlap with left prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - status # exit code of the last command - command_execution_time # duration of the last command - background_jobs # presence of background jobs - direnv # direnv status (https://direnv.net/) - asdf # asdf version manager (https://github.com/asdf-vm/asdf) - virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) - anaconda # conda environment (https://conda.io/) - pyenv # python environment (https://github.com/pyenv/pyenv) - goenv # go environment (https://github.com/syndbg/goenv) - nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) - nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) - nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) - # node_version # node.js version - # go_version # go version (https://golang.org) - # rust_version # rustc version (https://www.rust-lang.org) - # dotnet_version # .NET version (https://dotnet.microsoft.com) - # php_version # php version (https://www.php.net/) - # laravel_version # laravel php framework version (https://laravel.com/) - # java_version # java version (https://www.java.com/) - # package # name@version from package.json (https://docs.npmjs.com/files/package.json) - rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) - rvm # ruby version from rvm (https://rvm.io) - fvm # flutter version management (https://github.com/leoafarias/fvm) - luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) - jenv # java version from jenv (https://github.com/jenv/jenv) - plenv # perl version from plenv (https://github.com/tokuhirom/plenv) - perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) - phpenv # php version from phpenv (https://github.com/phpenv/phpenv) - scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) - haskell_stack # haskell version from stack (https://haskellstack.org/) - kubecontext # current kubernetes context (https://kubernetes.io/) - terraform # terraform workspace (https://www.terraform.io) - # terraform_version # terraform version (https://www.terraform.io) - aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) - aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) - azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) - gcloud # google cloud cli account and project (https://cloud.google.com/) - google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) - toolbox # toolbox name (https://github.com/containers/toolbox) - context # user@hostname - nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) - ranger # ranger shell (https://github.com/ranger/ranger) - nnn # nnn shell (https://github.com/jarun/nnn) - xplr # xplr shell (https://github.com/sayanarijit/xplr) - vim_shell # vim shell indicator (:sh) - midnight_commander # midnight commander shell (https://midnight-commander.org/) - nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) - # vpn_ip # virtual private network indicator - # load # CPU load - # disk_usage # disk usage - # ram # free RAM - # swap # used swap - todo # todo items (https://github.com/todotxt/todo.txt-cli) - timewarrior # timewarrior tracking status (https://timewarrior.net/) - taskwarrior # taskwarrior task count (https://taskwarrior.org/) - # cpu_arch # CPU architecture - # time # current time - # =========================[ Line #2 ]========================= - newline # \n - # ip # ip address and bandwidth usage for a specified network interface - # public_ip # public IP address - # proxy # system-wide http/https/ftp proxy - # battery # internal battery - # wifi # wifi speed - # example # example user-defined segment (see prompt_example function below) - ) - - # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. - typeset -g POWERLEVEL9K_MODE=nerdfont-complete - # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid - # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. - typeset -g POWERLEVEL9K_ICON_PADDING=none - - # Basic style options that define the overall look of your prompt. You probably don't want to - # change them. - typeset -g POWERLEVEL9K_BACKGROUND= # transparent background - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol - - # When set to true, icons appear before content on both sides of the prompt. When set - # to false, icons go after content. If empty or not set, icons go before content in the left - # prompt and after content in the right prompt. - # - # You can also override it for a specific segment: - # - # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false - # - # Or for a specific segment in specific state: - # - # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false - typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true - - # Add an empty line before each prompt. - typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true - - # Connect left prompt lines with these symbols. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX= - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX= - typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX= - # Connect right prompt lines with these symbols. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX= - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX= - typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX= - - # The left end of left prompt. - typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= - # The right end of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= - - # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll - # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and - # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. - typeset -g POWERLEVEL9K_SHOW_RULER=false - typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·' - typeset -g POWERLEVEL9K_RULER_FOREGROUND=7 - - # Filler between left and right prompt on the first prompt line. You can set it to '·' or '─' - # to make it easier to see the alignment between left and right prompt and to separate prompt - # from command output. It serves the same purpose as ruler (see above) without increasing - # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false - # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact - # prompt. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' - if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then - # The color of the filler. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=7 - # Add a space between the end of left prompt and the filler. - typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' - # Add a space between the filler and the start of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' ' - # Start filler from the edge of the screen if there are no left segments on the first line. - typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' - # End filler on the edge of the screen if there are no right segments on the first line. - typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' - fi - - #################################[ os_icon: os identifier ]################################## - # OS identifier color. - typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND= - # Custom icon. - # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' - - ################################[ prompt_char: prompt symbol ]################################ - # Green prompt symbol if the last command succeeded. - typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=2 - # Red prompt symbol if the last command failed. - typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=1 - # Default prompt symbol. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' - # Prompt symbol in command vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' - # Prompt symbol in visual vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' - # Prompt symbol in overwrite vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' - typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true - # No line terminator if prompt_char is the last segment. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' - # No line introducer if prompt_char is the first segment. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= - - ##################################[ dir: current directory ]################################## - # Default current directory color. - typeset -g POWERLEVEL9K_DIR_FOREGROUND=4 - # If directory is too long, shorten some of its segments to the shortest possible unique - # prefix. The shortened directory can be tab-completed to the original. - typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique - # Replace removed segment suffixes with this symbol. - typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= - # Color of the shortened directory segments. - typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=4 - # Color of the anchor directory segments. Anchor segments are never shortened. The first - # segment is always an anchor. - typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=4 - # Set to true to display anchor directory segments in bold. - typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=false - # Don't shorten directories that contain any of these files. They are anchors. - local anchor_files=( - .bzr - .citc - .git - .hg - .node-version - .python-version - .go-version - .ruby-version - .lua-version - .java-version - .perl-version - .php-version - .tool-version - .shorten_folder_marker - .svn - .terraform - CVS - Cargo.toml - composer.json - go.mod - package.json - stack.yaml - ) - typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" - # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains - # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is - # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) - # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers - # and other directories don't. - # - # Optionally, "first" and "last" can be followed by ":<offset>" where <offset> is an integer. - # This moves the truncation point to the right (positive offset) or to the left (negative offset) - # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" - # respectively. - typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false - # Don't shorten this many last directory segments. They are anchors. - typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 - # Shorten directory if it's longer than this even if there is space for it. The value can - # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, - # directory will be shortened only when prompt doesn't fit or when other parameters demand it - # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). - # If set to `0`, directory will always be shortened to its minimum length. - typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 - # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this - # many columns for typing commands. - typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 - # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least - # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. - typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 - # If set to true, embed a hyperlink into the directory. Useful for quickly - # opening a directory in the file manager simply by clicking the link. - # Can also be handy when the directory is shortened, as it allows you to see - # the full directory that was used in previous commands. - typeset -g POWERLEVEL9K_DIR_HYPERLINK=false - - # Enable special styling for non-writable directories. See POWERLEVEL9K_LOCK_ICON and - # POWERLEVEL9K_DIR_CLASSES below. - typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2 - - # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON - # and POWERLEVEL9K_DIR_CLASSES below. - typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 - - # The default icon shown next to non-writable and non-existent directories when - # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. - # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' - - # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different - # directories. It must be an array with 3 * N elements. Each triplet consists of: - # - # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with - # extended_glob option enabled. - # 2. Directory class for the purpose of styling. - # 3. An empty string. - # - # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. - # - # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories - # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_DIR_CLASSES=( - # '~/work(|/*)' WORK '' - # '~(|/*)' HOME '' - # '*' DEFAULT '') - # - # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one - # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or - # WORK_NON_EXISTENT. - # - # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an - # option to define custom colors and icons for different directory classes. - # - # # Styling for WORK. - # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=4 - # - # # Styling for WORK_NOT_WRITABLE. - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=4# - # - # Styling for WORK_NON_EXISTENT. - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=4 - # - # If a styling parameter isn't explicitly defined for some class, it falls back to the classless - # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls - # back to POWERLEVEL9K_DIR_FOREGROUND. - # - # typeset -g POWERLEVEL9K_DIR_CLASSES=() - - # Custom prefix. - # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' - - #####################################[ vcs: git status ]###################################### - # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. - typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= - - # Untracked files icon. It's really a question mark, your font isn't broken. - # Change the value of this parameter to show a different icon. - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' - - # Formatter for Git status. - # - # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. - # - # You can edit the function to customize how Git status looks. - # - # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: - # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. - function my_git_formatter() { - emulate -L zsh - - if [[ -n $P9K_CONTENT ]]; then - # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from - # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. - typeset -g my_git_format=$P9K_CONTENT - return - fi - - if (( $1 )); then - # Styling for up-to-date Git status. - local meta='%f' # default foreground - local clean='%2F' # green foreground - local modified='%3F' # yellow foreground - local untracked='%4F' # blue foreground - local conflicted='%1F' # red foreground - else - # Styling for incomplete and stale Git status. - local meta='%f' # default foreground - local clean='%f' # default foreground - local modified='%f' # default foreground - local untracked='%f' # default foreground - local conflicted='%f' # default foreground - fi - - local res - - if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - local branch=${(V)VCS_STATUS_LOCAL_BRANCH} - # If local branch name is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show local branch name in full without truncation, delete the next line. - (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line - res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" - fi - - if [[ -n $VCS_STATUS_TAG - # Show tag only if not on a branch. - # Tip: To always show tag, delete the next line. - && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line - ]]; then - local tag=${(V)VCS_STATUS_TAG} - # If tag name is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show tag name in full without truncation, delete the next line. - (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line - res+="${meta}#${clean}${tag//\%/%%}" - fi - - # Display the current Git commit if there is no branch and no tag. - # Tip: To always display the current Git commit, delete the next line. - [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line - res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" - - # Show tracking branch name if it differs from local branch. - if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then - res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" - fi - - # Display "wip" if the latest commit's summary contains "wip" or "WIP". - if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then - res+=" ${modified}wip" - fi - - # ⇣42 if behind the remote. - (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" - # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. - (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " - (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" - # ⇠42 if behind the push remote. - (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" - (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " - # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. - (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" - # *42 if have stashes. - (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" - # 'merge' if the repo is in an unusual state. - [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" - # ~42 if have merge conflicts. - (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" - # +42 if have staged changes. - (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" - # !42 if have unstaged changes. - (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" - # ?42 if have untracked files. It's really a question mark, your font isn't broken. - # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. - # Remove the next line if you don't want to see untracked files at all. - (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" - # "─" if the number of unstaged files is unknown. This can happen due to - # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower - # than the number of files in the Git index, or due to bash.showDirtyState being set to false - # in the repository config. The number of staged and untracked files may also be unknown - # in this case. - (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" - - typeset -g my_git_format=$res - } - functions -M my_git_formatter 2>/dev/null - - # Don't count the number of unstaged, untracked and conflicted files in Git repositories with - # more than this many files in the index. Negative value means infinity. - # - # If you are working in Git repositories with tens of millions of files and seeing performance - # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output - # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's - # config: `git config bash.showDirtyState false`. - typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 - - # Don't show Git status in prompt for repositories whose workdir matches this pattern. - # For example, if set to '~', the Git repository at $HOME/.git will be ignored. - # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. - typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' - - # Disable the default Git status formatting. - typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true - # Install our own Git status formatter. - typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' - typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' - # Enable counters for staged, unstaged, etc. - typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 - - # Icon color. - typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=2 - typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR= - # Custom icon. - # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_VCS_PREFIX='%fon ' - - # Show status of repositories of these types. You can add svn and/or hg if you are - # using them. If you do, your prompt may become slow even when your current directory - # isn't in an svn or hg repository. - typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) - - # These settings are used for repositories other than Git or when gitstatusd fails and - # Powerlevel10k has to fall back to using vcs_info. - typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=2 - typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=2 - typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=3 - - ##########################[ status: exit code of the last command ]########################### - # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and - # style them independently from the regular OK and ERROR state. - typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true - - # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as - # it will signify success by turning green. - typeset -g POWERLEVEL9K_STATUS_OK=false - typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=2 - typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' - - # Status when some part of a pipe command fails but the overall exit status is zero. It may look - # like this: 1|0. - typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true - typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=2 - typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' - - # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as - # it will signify error by turning red. - typeset -g POWERLEVEL9K_STATUS_ERROR=false - typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=1 - typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' - - # Status when the last command was terminated by a signal. - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=1 - # Use terse signal names: "INT" instead of "SIGINT(2)". - typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' - - # Status when some part of a pipe command fails and the overall exit status is also non-zero. - # It may look like this: 1|0. - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=1 - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' - - ###################[ command_execution_time: duration of the last command ]################### - # Show duration of the last command if takes at least this many seconds. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 - # Show this many fractional digits. Zero means round to seconds. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 - # Execution time color. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=3 - # Duration format: 1d 2h 3m 4s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' - # Custom icon. - # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook ' - - #######################[ background_jobs: presence of background jobs ]####################### - # Don't show the number of background jobs. - typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false - # Background jobs color. - typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=1 - # Custom icon. - # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ direnv: direnv status (https://direnv.net/) ]######################## - # Direnv color. - typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### - # Default asdf color. Only used to display tools for which there is no color override (see below). - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND. - typeset -g POWERLEVEL9K_ASDF_FOREGROUND=6 - - # There are four parameters that can be used to hide asdf tools. Each parameter describes - # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at - # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to - # hide a tool, it gets shown. - # - # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and - # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: - # - # asdf local python 3.8.1 - # asdf global python 3.8.1 - # - # After running both commands the current python version is 3.8.1 and its source is "local" as - # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, - # it'll hide python version in this case because 3.8.1 is the same as the global version. - # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't - # contain "local". - - # Hide tool versions that don't come from one of these sources. - # - # Available sources: - # - # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" - # - local `asdf current` says "set by /some/not/home/directory/file" - # - global `asdf current` says "set by /home/username/file" - # - # Note: If this parameter is set to (shell local global), it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. - typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) - - # If set to false, hide tool versions that are the same as global. - # - # Note: The name of this parameter doesn't reflect its meaning at all. - # Note: If this parameter is set to true, it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. - typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false - - # If set to false, hide tool versions that are equal to "system". - # - # Note: If this parameter is set to true, it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. - typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true - - # If set to non-empty value, hide tools unless there is a file matching the specified file pattern - # in the current directory, or its parent directory, or its grandparent directory, and so on. - # - # Note: If this parameter is set to empty value, it won't hide tools. - # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. - # - # Example: Hide nodejs version when there is no package.json and no *.js files in the current - # directory, in `..`, in `../..` and so on. - # - # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' - typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= - - # Ruby version from asdf. - typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=1 - # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Python version from asdf. - typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=6 - # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Go version from asdf. - typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=6 - # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Node.js version from asdf. - typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=2 - # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Rust version from asdf. - typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=4 - # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' - - # .NET Core version from asdf. - typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=5 - # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Flutter version from asdf. - typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=4 - # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Lua version from asdf. - typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=4 - # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Java version from asdf. - typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=4 - # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Perl version from asdf. - typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=6 - # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Erlang version from asdf. - typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=1 - # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Elixir version from asdf. - typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=5 - # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Postgres version from asdf. - typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=6 - # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' - - # PHP version from asdf. - typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=5 - # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Haskell version from asdf. - typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=3 - # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Julia version from asdf. - typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=2 - # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' - - ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### - # NordVPN connection indicator color. - typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=6 - # Hide NordVPN connection indicator when not connected. - typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= - typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= - # Custom icon. - # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## - # Ranger shell color. - typeset -g POWERLEVEL9K_RANGER_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### - # Nnn shell color. - typeset -g POWERLEVEL9K_NNN_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## - # xplr shell color. - typeset -g POWERLEVEL9K_XPLR_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########################[ vim_shell: vim shell indicator (:sh) ]########################### - # Vim shell indicator color. - typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### - # Midnight Commander shell color. - typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## - # Nix shell color. - typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=4 - - # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. - # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################################[ disk_usage: disk usage ]################################## - # Colors for different levels of disk usage. - typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=2 - typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=3 - typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=1 - # Thresholds for different levels of disk usage (percentage points). - typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 - typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 - # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. - typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false - # Custom icon. - # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################################[ ram: free RAM ]####################################### - # RAM color. - typeset -g POWERLEVEL9K_RAM_FOREGROUND=2 - # Custom icon. - # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################################[ swap: used swap ]###################################### - # Swap color. - typeset -g POWERLEVEL9K_SWAP_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################################[ load: CPU load ]###################################### - # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. - typeset -g POWERLEVEL9K_LOAD_WHICH=5 - # Load color when load is under 50%. - typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=2 - # Load color when load is between 50% and 70%. - typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=3 - # Load color when load is over 70%. - typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=1 - # Custom icon. - # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ - # Todo color. - typeset -g POWERLEVEL9K_TODO_FOREGROUND=4 - # Hide todo when the total number of tasks is zero. - typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true - # Hide todo when the number of tasks after filtering is zero. - typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false - - # Todo format. The following parameters are available within the expansion. - # - # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. - # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. - # - # These variables correspond to the last line of the output of `todo.sh -p ls`: - # - # TODO: 24 of 42 tasks shown - # - # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. - # - # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' - - # Custom icon. - # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ - # Timewarrior color. - typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=4 - # If the tracked task is longer than 24 characters, truncate and append "…". - # Tip: To always display tasks without truncation, delete the following parameter. - # Tip: To hide task names and display just the icon when time tracking is enabled, set the - # value of the following parameter to "". - typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' - - # Custom icon. - # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## - # Taskwarrior color. - typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=6 - - # Taskwarrior segment format. The following parameters are available within the expansion. - # - # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. - # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. - # - # Zero values are represented as empty parameters. - # - # The default format: - # - # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' - # - # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' - - # Custom icon. - # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ cpu_arch: CPU architecture ]################################ - # CPU architecture color. - typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=3 - - # Hide the segment when on a specific CPU architecture. - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################################[ context: user@hostname ]################################## - # Context color when running with privileges. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1 - # Context color in SSH without privileges. - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=7 - # Default context color (no privileges, no SSH). - typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=7 - - # Context format when running with privileges: bold user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' - # Context format when in SSH without privileges: user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' - # Default context format (no privileges, no SSH): user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' - - # Don't show context unless running with privileges or in SSH. - # Tip: Remove the next line to always show context. - typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith ' - - ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### - # Python virtual environment color. - typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=6 - # Don't show Python version next to the virtual environment name. - typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false - # If set to "false", won't show virtualenv if pyenv is already shown. - # If set to "if-different", won't show virtualenv if it's the same as pyenv. - typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false - # Separate environment name from Python version only with a space. - typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= - # Custom icon. - # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################[ anaconda: conda environment (https://conda.io/) ]###################### - # Anaconda environment color. - typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=6 - - # Anaconda segment format. The following parameters are available within the expansion. - # - # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. - # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. - # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). - # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). - # - # CONDA_PROMPT_MODIFIER can be configured with the following command: - # - # conda config --set env_prompt '({default_env}) ' - # - # The last argument is a Python format string that can use the following variables: - # - # - prefix The same as CONDA_PREFIX. - # - default_env The same as CONDA_DEFAULT_ENV. - # - name The last segment of CONDA_PREFIX. - # - stacked_env Comma-separated list of names in the environment stack. The first element is - # always the same as default_env. - # - # Note: '({default_env}) ' is the default value of env_prompt. - # - # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER - # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former - # is empty. - typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' - - # Custom icon. - # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ - # Pyenv color. - typeset -g POWERLEVEL9K_PYENV_FOREGROUND=6 - # Hide python version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) - # If set to false, hide python version if it's the same as global: - # $(pyenv version-name) == $(pyenv global). - typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide python version if it's equal to "system". - typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true - - # Pyenv segment format. The following parameters are available within the expansion. - # - # - P9K_CONTENT Current pyenv environment (pyenv version-name). - # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). - # - # The default format has the following logic: - # - # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or - # starts with "$P9K_PYENV_PYTHON_VERSION/". - # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". - typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' - - # Custom icon. - # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ - # Goenv color. - typeset -g POWERLEVEL9K_GOENV_FOREGROUND=6 - # Hide go version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) - # If set to false, hide go version if it's the same as global: - # $(goenv version-name) == $(goenv global). - typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide go version if it's equal to "system". - typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## - # Nodenv color. - typeset -g POWERLEVEL9K_NODENV_FOREGROUND=2 - # Hide node version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) - # If set to false, hide node version if it's the same as global: - # $(nodenv version-name) == $(nodenv global). - typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide node version if it's equal to "system". - typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### - # Nvm color. - typeset -g POWERLEVEL9K_NVM_FOREGROUND=2 - # Custom icon. - # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ - # Nodeenv color. - typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=2 - # Don't show Node version next to the environment name. - typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false - # Separate environment name from Node version only with a space. - typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= - # Custom icon. - # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############################[ node_version: node.js version ]############################### - # Node version color. - typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=2 - # Show node version only when in a directory tree containing package.json. - typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ go_version: go version (https://golang.org) ]######################## - # Go version color. - typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=6 - # Show go version only when in a go project subdirectory. - typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## - # Rust version color. - typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=4 - # Show rust version only when in a rust project subdirectory. - typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ - # .NET version color. - typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=5 - # Show .NET version only when in a .NET project subdirectory. - typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################[ php_version: php version (https://www.php.net/) ]###################### - # PHP version color. - typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=5 - # Show PHP version only when in a PHP project subdirectory. - typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### - # Laravel version color. - typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=1 - # Custom icon. - # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ####################[ java_version: java version (https://www.java.com/) ]#################### - # Java version color. - typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=4 - # Show java version only when in a java project subdirectory. - typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true - # Show brief version. - typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false - # Custom icon. - # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### - # Package color. - typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=6 - # Package format. The following parameters are available within the expansion. - # - # - P9K_PACKAGE_NAME The value of `name` field in package.json. - # - P9K_PACKAGE_VERSION The value of `version` field in package.json. - # - # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' - # Custom icon. - # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## - # Rbenv color. - typeset -g POWERLEVEL9K_RBENV_FOREGROUND=1 - # Hide ruby version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) - # If set to false, hide ruby version if it's the same as global: - # $(rbenv version-name) == $(rbenv global). - typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide ruby version if it's equal to "system". - typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## - # Rvm color. - typeset -g POWERLEVEL9K_RVM_FOREGROUND=1 - # Don't show @gemset at the end. - typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false - # Don't show ruby- at the front. - typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ - # Fvm color. - typeset -g POWERLEVEL9K_FVM_FOREGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### - # Lua color. - typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=4 - # Hide lua version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) - # If set to false, hide lua version if it's the same as global: - # $(luaenv version-name) == $(luaenv global). - typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide lua version if it's equal to "system". - typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ - # Java color. - typeset -g POWERLEVEL9K_JENV_FOREGROUND=4 - # Hide java version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) - # If set to false, hide java version if it's the same as global: - # $(jenv version-name) == $(jenv global). - typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide java version if it's equal to "system". - typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ - # Perl color. - typeset -g POWERLEVEL9K_PLENV_FOREGROUND=6 - # Hide perl version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) - # If set to false, hide perl version if it's the same as global: - # $(plenv version-name) == $(plenv global). - typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide perl version if it's equal to "system". - typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ - # Perlbrew color. - typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 - # Show perlbrew version only when in a perl project subdirectory. - typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true - # Don't show "perl-" at the front. - typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ - # PHP color. - typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=5 - # Hide php version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) - # If set to false, hide php version if it's the same as global: - # $(phpenv version-name) == $(phpenv global). - typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide php version if it's equal to "system". - typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### - # Scala color. - typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=1 - # Hide scala version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) - # If set to false, hide scala version if it's the same as global: - # $(scalaenv version-name) == $(scalaenv global). - typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide scala version if it's equal to "system". - typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### - # Haskell color. - typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=3 - # Hide haskell version if it doesn't come from one of these sources. - # - # shell: version is set by STACK_YAML - # local: version is set by stack.yaml up the directory tree - # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) - typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) - # If set to false, hide haskell version if it's the same as in the implicit global project. - typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true - # Custom icon. - # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# - # Show kubecontext only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show kubecontext. - typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold' - - # Kubernetes context classes for the purpose of using different colors, icons and expansions with - # different contexts. - # - # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current kubernetes context gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' DEFAULT) - # - # If your current kubernetes context is "deathray-testing/default", its class is TEST - # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=3 - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=5 - # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext - # segment. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - # - # Within the expansion the following parameters are always available: - # - # - P9K_CONTENT The content that would've been displayed if there was no content - # expansion defined. - # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the - # output of `kubectl config get-contexts`. - # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the - # output of `kubectl config get-contexts`. - # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE - # in the output of `kubectl config get-contexts`. If there is no - # namespace, the parameter is set to "default". - # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the - # output of `kubectl config get-contexts`. - # - # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), - # the following extra parameters are available: - # - # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. - # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. - # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. - # - # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, - # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": - # - # - P9K_KUBECONTEXT_CLOUD_NAME=gke - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account - # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a - # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - # - # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": - # - # - P9K_KUBECONTEXT_CLOUD_NAME=eks - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 - # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 - # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= - # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. - POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' - # Append the current context's namespace if it's not "default". - POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' - - # Custom prefix. - # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' - - ################[ terraform: terraform workspace (https://www.terraform.io) ]################# - # Don't show terraform workspace if it's literally "default". - typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false - # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current terraform workspace gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' OTHER) - # - # If your current terraform workspace is "project_test", its class is TEST because "project_test" - # doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=2 - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' OTHER) - typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=4 - # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ terraform_version: terraform version (https://www.terraform.io) ]############## - # Terraform version color. - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# - # Show aws only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show aws. - typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' - - # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current AWS profile gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_AWS_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' DEFAULT) - # - # If your current AWS profile is "company_test", its class is TEST - # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=2 - # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_AWS_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=3 - # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # AWS segment format. The following parameters are available within the expansion. - # - # - P9K_AWS_PROFILE The name of the current AWS profile. - # - P9K_AWS_REGION The region associated with the current AWS profile. - typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' - - #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# - # AWS Elastic Beanstalk environment color. - typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=2 - # Custom icon. - # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## - # Show azure only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show azure. - typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' - # Azure account name color. - typeset -g POWERLEVEL9K_AZURE_FOREGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### - # Show gcloud only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show gcloud. - typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' - # Google cloud color. - typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=4 - - # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or - # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative - # enough. You can use the following parameters in the expansions. Each of them corresponds to the - # output of `gcloud` tool. - # - # Parameter | Source - # -------------------------|-------------------------------------------------------------------- - # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' - # P9K_GCLOUD_ACCOUNT | gcloud config get-value account - # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project - # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' - # - # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. - # - # Obtaining project name requires sending a request to Google servers. This can take a long time - # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud - # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets - # set and gcloud prompt segment transitions to state COMPLETE. - # - # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL - # and COMPLETE. You can also hide gcloud in state PARTIAL by setting - # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and - # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. - typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' - typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' - - # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name - # this often. Negative value disables periodic polling. In this mode project name is retrieved - # only when the current configuration, account or project id changes. - typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 - - # Custom icon. - # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# - # Show google_app_cred only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show google_app_cred. - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' - - # Google application credentials classes for the purpose of using different colors, icons and - # expansions with different credentials. - # - # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first - # element in each pair defines a pattern against which the current kubernetes context gets - # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion - # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION - # parameters, you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. - # The first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( - # '*:*prod*:*' PROD - # '*:*test*:*' TEST - # '*' DEFAULT) - # - # If your current Google application credentials is "service_account deathray-testing x@y.com", - # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=3 - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( - # '*:*prod*:*' PROD # These values are examples that are unlikely - # '*:*test*:*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=5 - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by - # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - # - # You can use the following parameters in the expansion. Each of them corresponds to one of the - # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. - # - # Parameter | JSON key file field - # ---------------------------------+--------------- - # P9K_GOOGLE_APP_CRED_TYPE | type - # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id - # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email - # - # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' - - ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### - # Toolbox color. - typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=3 - # Don't display the name of the toolbox if it matches fedora-toolbox-*. - typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' - # Custom icon. - # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin ' - - ###############################[ public_ip: public IP address ]############################### - # Public IP color. - typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=6 - # Custom icon. - # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ########################[ vpn_ip: virtual private network indicator ]######################### - # VPN IP color. - typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=3 - # When on VPN, show just an icon without the IP address. - # Tip: To display the private IP address when on VPN, remove the next line. - typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= - # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN - # to see the name of the interface. - typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*' - # If set to true, show one segment per matching network interface. If set to false, show only - # one segment corresponding to the first matching network interface. - # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. - typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false - # Custom icon. - # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### - # IP color. - typeset -g POWERLEVEL9K_IP_FOREGROUND=4 - # The following parameters are accessible within the expansion: - # - # Parameter | Meaning - # ----------------------+------------------------------------------- - # P9K_IP_IP | IP address - # P9K_IP_INTERFACE | network interface - # P9K_IP_RX_BYTES | total number of bytes received - # P9K_IP_TX_BYTES | total number of bytes sent - # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt - # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt - # P9K_IP_RX_RATE | receive rate (since last prompt) - # P9K_IP_TX_RATE | send rate (since last prompt) - typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %2F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %3F⇡$P9K_IP_TX_RATE}' - # Show information for the first network interface whose name matches this regular expression. - # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. - typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' - # Custom icon. - # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #########################[ proxy: system-wide http/https/ftp proxy ]########################## - # Proxy color. - typeset -g POWERLEVEL9K_PROXY_FOREGROUND=2 - # Custom icon. - # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ battery: internal battery ]################################# - # Show battery in red when it's below this level and not connected to power supply. - typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 - typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=1 - # Show battery in green when it's charging or fully charged. - typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=2 - # Show battery in yellow when it's discharging. - typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=3 - # Battery pictograms going from low to high level of charge. - typeset -g POWERLEVEL9K_BATTERY_STAGES=('%K{0}▁' '%K{0}▂' '%K{0}▃' '%K{0}▄' '%K{0}▅' '%K{0}▆' '%K{0}▇' '%K{0}█') - # Don't show the remaining time to charge/discharge. - typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false - - #####################################[ wifi: wifi speed ]##################################### - # WiFi color. - typeset -g POWERLEVEL9K_WIFI_FOREGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). - # - # # Wifi colors and icons for different signal strength levels (low to high). - # typeset -g my_wifi_fg=(4 4 4 4 4) # <-- change these values - # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values - # - # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' - # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' - # - # The following parameters are accessible within the expansions: - # - # Parameter | Meaning - # ----------------------+--------------- - # P9K_WIFI_SSID | service set identifier, a.k.a. network name - # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown - # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second - # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 - # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 - # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) - - ####################################[ time: current time ]#################################### - # Current time color. - typeset -g POWERLEVEL9K_TIME_FOREGROUND=6 - # Format for the current time: 09:51:02. See `man 3 strftime`. - typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' - # If set to true, time will update when you hit enter. This way prompts for the past - # commands will contain the start times of their commands as opposed to the default - # behavior where they contain the end times of their preceding commands. - typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false - # Custom icon. - # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TIME_PREFIX='%fat ' - - # Example of a user-defined prompt segment. Function prompt_example will be called on every - # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or - # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and green text greeting the user. - # - # Type `p10k help segment` for documentation and a more sophisticated example. - function prompt_example() { - p10k segment -f 2 -i '⭐' -t 'hello, %n' - } - - # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job - # is to generate the prompt segment for display in instant prompt. See - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function - # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k - # will replay these calls without actually calling instant_prompt_*. It is imperative that - # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this - # rule is not observed, the content of instant prompt will be incorrect. - # - # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If - # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. - function instant_prompt_example() { - # Since prompt_example always makes the same `p10k segment` calls, we can call it from - # instant_prompt_example. This will give us the same `example` prompt segment in the instant - # and regular prompts. - prompt_example - } - - # User-defined prompt segments can be customized the same way as built-in segments. - # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 - # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt - # when accepting a command line. Supported values: - # - # - off: Don't change prompt when accepting a command line. - # - always: Trim down prompt when accepting a command line. - # - same-dir: Trim down prompt when accepting a command line unless this is the first command - # typed after changing current working directory. - typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off - - # Instant prompt mode. - # - # - off: Disable instant prompt. Choose this if you've tried instant prompt and found - # it incompatible with your zsh configuration files. - # - quiet: Enable instant prompt and don't print warnings when detecting console output - # during zsh initialization. Choose this if you've read and understood - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - verbose: Enable instant prompt and print a warning when detecting console output during - # zsh initialization. Choose this if you've never tried instant prompt, haven't - # seen the warning, or if you are unsure what this all means. - typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose - - # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. - # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload - # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you - # really need it. - typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true - - # If p10k is already loaded, reload configuration. - # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. - (( ! $+functions[p10k] )) || p10k reload -} - -# Tell `p10k configure` which file it should overwrite. -typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} - -(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} -'builtin' 'unset' 'p10k_config_opts' diff --git a/.zsh/themes/powerlevel10k/config/p10k-lean.zsh b/.zsh/themes/powerlevel10k/config/p10k-lean.zsh deleted file mode 100644 index 98bb814..0000000 --- a/.zsh/themes/powerlevel10k/config/p10k-lean.zsh +++ /dev/null @@ -1,1634 +0,0 @@ -# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate -# your own config based on it. -# -# Tip: Looking for a nice color? Here's a one-liner to print colormap. -# -# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done - -# Temporarily change options. -'builtin' 'local' '-a' 'p10k_config_opts' -[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -() { - emulate -L zsh -o extended_glob - - # Unset all configuration options. This allows you to apply configuration changes without - # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. - unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' - - # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return - - # The list of segments shown on the left. Fill it with the most important segments. - typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - # os_icon # os identifier - dir # current directory - vcs # git status - # =========================[ Line #2 ]========================= - newline # \n - prompt_char # prompt symbol - ) - - # The list of segments shown on the right. Fill it with less important segments. - # Right prompt on the last prompt line (where you are typing your commands) gets - # automatically hidden when the input line reaches it. Right prompt above the - # last prompt line gets hidden if it would overlap with left prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - status # exit code of the last command - command_execution_time # duration of the last command - background_jobs # presence of background jobs - direnv # direnv status (https://direnv.net/) - asdf # asdf version manager (https://github.com/asdf-vm/asdf) - virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) - anaconda # conda environment (https://conda.io/) - pyenv # python environment (https://github.com/pyenv/pyenv) - goenv # go environment (https://github.com/syndbg/goenv) - nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) - nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) - nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) - # node_version # node.js version - # go_version # go version (https://golang.org) - # rust_version # rustc version (https://www.rust-lang.org) - # dotnet_version # .NET version (https://dotnet.microsoft.com) - # php_version # php version (https://www.php.net/) - # laravel_version # laravel php framework version (https://laravel.com/) - # java_version # java version (https://www.java.com/) - # package # name@version from package.json (https://docs.npmjs.com/files/package.json) - rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) - rvm # ruby version from rvm (https://rvm.io) - fvm # flutter version management (https://github.com/leoafarias/fvm) - luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) - jenv # java version from jenv (https://github.com/jenv/jenv) - plenv # perl version from plenv (https://github.com/tokuhirom/plenv) - perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) - phpenv # php version from phpenv (https://github.com/phpenv/phpenv) - scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) - haskell_stack # haskell version from stack (https://haskellstack.org/) - kubecontext # current kubernetes context (https://kubernetes.io/) - terraform # terraform workspace (https://www.terraform.io) - # terraform_version # terraform version (https://www.terraform.io) - aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) - aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) - azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) - gcloud # google cloud cli account and project (https://cloud.google.com/) - google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) - toolbox # toolbox name (https://github.com/containers/toolbox) - context # user@hostname - nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) - ranger # ranger shell (https://github.com/ranger/ranger) - nnn # nnn shell (https://github.com/jarun/nnn) - xplr # xplr shell (https://github.com/sayanarijit/xplr) - vim_shell # vim shell indicator (:sh) - midnight_commander # midnight commander shell (https://midnight-commander.org/) - nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) - # vpn_ip # virtual private network indicator - # load # CPU load - # disk_usage # disk usage - # ram # free RAM - # swap # used swap - todo # todo items (https://github.com/todotxt/todo.txt-cli) - timewarrior # timewarrior tracking status (https://timewarrior.net/) - taskwarrior # taskwarrior task count (https://taskwarrior.org/) - # cpu_arch # CPU architecture - # time # current time - # =========================[ Line #2 ]========================= - newline - # ip # ip address and bandwidth usage for a specified network interface - # public_ip # public IP address - # proxy # system-wide http/https/ftp proxy - # battery # internal battery - # wifi # wifi speed - # example # example user-defined segment (see prompt_example function below) - ) - - # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. - typeset -g POWERLEVEL9K_MODE=nerdfont-complete - # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid - # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. - typeset -g POWERLEVEL9K_ICON_PADDING=none - - # Basic style options that define the overall look of your prompt. You probably don't want to - # change them. - typeset -g POWERLEVEL9K_BACKGROUND= # transparent background - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol - - # When set to true, icons appear before content on both sides of the prompt. When set - # to false, icons go after content. If empty or not set, icons go before content in the left - # prompt and after content in the right prompt. - # - # You can also override it for a specific segment: - # - # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false - # - # Or for a specific segment in specific state: - # - # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false - typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true - - # Add an empty line before each prompt. - typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true - - # Connect left prompt lines with these symbols. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX= - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX= - typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX= - # Connect right prompt lines with these symbols. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX= - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX= - typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX= - - # The left end of left prompt. - typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= - # The right end of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= - - # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll - # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and - # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. - typeset -g POWERLEVEL9K_SHOW_RULER=false - typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·' - typeset -g POWERLEVEL9K_RULER_FOREGROUND=240 - - # Filler between left and right prompt on the first prompt line. You can set it to '·' or '─' - # to make it easier to see the alignment between left and right prompt and to separate prompt - # from command output. It serves the same purpose as ruler (see above) without increasing - # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false - # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact - # prompt. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' - if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then - # The color of the filler. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=240 - # Add a space between the end of left prompt and the filler. - typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' - # Add a space between the filler and the start of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' ' - # Start filler from the edge of the screen if there are no left segments on the first line. - typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' - # End filler on the edge of the screen if there are no right segments on the first line. - typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' - fi - - #################################[ os_icon: os identifier ]################################## - # OS identifier color. - typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND= - # Custom icon. - # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' - - ################################[ prompt_char: prompt symbol ]################################ - # Green prompt symbol if the last command succeeded. - typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 - # Red prompt symbol if the last command failed. - typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 - # Default prompt symbol. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' - # Prompt symbol in command vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' - # Prompt symbol in visual vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' - # Prompt symbol in overwrite vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' - typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true - # No line terminator if prompt_char is the last segment. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' - # No line introducer if prompt_char is the first segment. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= - - ##################################[ dir: current directory ]################################## - # Default current directory color. - typeset -g POWERLEVEL9K_DIR_FOREGROUND=31 - # If directory is too long, shorten some of its segments to the shortest possible unique - # prefix. The shortened directory can be tab-completed to the original. - typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique - # Replace removed segment suffixes with this symbol. - typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= - # Color of the shortened directory segments. - typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103 - # Color of the anchor directory segments. Anchor segments are never shortened. The first - # segment is always an anchor. - typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 - # Display anchor directory segments in bold. - typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true - # Don't shorten directories that contain any of these files. They are anchors. - local anchor_files=( - .bzr - .citc - .git - .hg - .node-version - .python-version - .go-version - .ruby-version - .lua-version - .java-version - .perl-version - .php-version - .tool-version - .shorten_folder_marker - .svn - .terraform - CVS - Cargo.toml - composer.json - go.mod - package.json - stack.yaml - ) - typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" - # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains - # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is - # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) - # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers - # and other directories don't. - # - # Optionally, "first" and "last" can be followed by ":<offset>" where <offset> is an integer. - # This moves the truncation point to the right (positive offset) or to the left (negative offset) - # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" - # respectively. - typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false - # Don't shorten this many last directory segments. They are anchors. - typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 - # Shorten directory if it's longer than this even if there is space for it. The value can - # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, - # directory will be shortened only when prompt doesn't fit or when other parameters demand it - # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). - # If set to `0`, directory will always be shortened to its minimum length. - typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 - # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this - # many columns for typing commands. - typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 - # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least - # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. - typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 - # If set to true, embed a hyperlink into the directory. Useful for quickly - # opening a directory in the file manager simply by clicking the link. - # Can also be handy when the directory is shortened, as it allows you to see - # the full directory that was used in previous commands. - typeset -g POWERLEVEL9K_DIR_HYPERLINK=false - - # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON - # and POWERLEVEL9K_DIR_CLASSES below. - typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 - - # The default icon shown next to non-writable and non-existent directories when - # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. - # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' - - # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different - # directories. It must be an array with 3 * N elements. Each triplet consists of: - # - # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with - # extended_glob option enabled. - # 2. Directory class for the purpose of styling. - # 3. An empty string. - # - # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. - # - # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories - # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_DIR_CLASSES=( - # '~/work(|/*)' WORK '' - # '~(|/*)' HOME '' - # '*' DEFAULT '') - # - # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one - # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or - # WORK_NON_EXISTENT. - # - # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an - # option to define custom colors and icons for different directory classes. - # - # # Styling for WORK. - # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 - # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 - # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 - # - # # Styling for WORK_NOT_WRITABLE. - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=31 - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 - # - # # Styling for WORK_NON_EXISTENT. - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31 - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103 - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39 - # - # If a styling parameter isn't explicitly defined for some class, it falls back to the classless - # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls - # back to POWERLEVEL9K_DIR_FOREGROUND. - # - # typeset -g POWERLEVEL9K_DIR_CLASSES=() - - # Custom prefix. - # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' - - #####################################[ vcs: git status ]###################################### - # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. - typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= - - # Untracked files icon. It's really a question mark, your font isn't broken. - # Change the value of this parameter to show a different icon. - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' - - # Formatter for Git status. - # - # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. - # - # You can edit the function to customize how Git status looks. - # - # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: - # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. - function my_git_formatter() { - emulate -L zsh - - if [[ -n $P9K_CONTENT ]]; then - # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from - # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. - typeset -g my_git_format=$P9K_CONTENT - return - fi - - if (( $1 )); then - # Styling for up-to-date Git status. - local meta='%f' # default foreground - local clean='%76F' # green foreground - local modified='%178F' # yellow foreground - local untracked='%39F' # blue foreground - local conflicted='%196F' # red foreground - else - # Styling for incomplete and stale Git status. - local meta='%244F' # grey foreground - local clean='%244F' # grey foreground - local modified='%244F' # grey foreground - local untracked='%244F' # grey foreground - local conflicted='%244F' # grey foreground - fi - - local res - - if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - local branch=${(V)VCS_STATUS_LOCAL_BRANCH} - # If local branch name is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show local branch name in full without truncation, delete the next line. - (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line - res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" - fi - - if [[ -n $VCS_STATUS_TAG - # Show tag only if not on a branch. - # Tip: To always show tag, delete the next line. - && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line - ]]; then - local tag=${(V)VCS_STATUS_TAG} - # If tag name is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show tag name in full without truncation, delete the next line. - (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line - res+="${meta}#${clean}${tag//\%/%%}" - fi - - # Display the current Git commit if there is no branch and no tag. - # Tip: To always display the current Git commit, delete the next line. - [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line - res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" - - # Show tracking branch name if it differs from local branch. - if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then - res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" - fi - - # Display "wip" if the latest commit's summary contains "wip" or "WIP". - if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then - res+=" ${modified}wip" - fi - - # ⇣42 if behind the remote. - (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" - # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. - (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " - (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" - # ⇠42 if behind the push remote. - (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" - (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " - # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. - (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" - # *42 if have stashes. - (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" - # 'merge' if the repo is in an unusual state. - [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" - # ~42 if have merge conflicts. - (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" - # +42 if have staged changes. - (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" - # !42 if have unstaged changes. - (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" - # ?42 if have untracked files. It's really a question mark, your font isn't broken. - # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. - # Remove the next line if you don't want to see untracked files at all. - (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" - # "─" if the number of unstaged files is unknown. This can happen due to - # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower - # than the number of files in the Git index, or due to bash.showDirtyState being set to false - # in the repository config. The number of staged and untracked files may also be unknown - # in this case. - (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" - - typeset -g my_git_format=$res - } - functions -M my_git_formatter 2>/dev/null - - # Don't count the number of unstaged, untracked and conflicted files in Git repositories with - # more than this many files in the index. Negative value means infinity. - # - # If you are working in Git repositories with tens of millions of files and seeing performance - # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output - # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's - # config: `git config bash.showDirtyState false`. - typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 - - # Don't show Git status in prompt for repositories whose workdir matches this pattern. - # For example, if set to '~', the Git repository at $HOME/.git will be ignored. - # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. - typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' - - # Disable the default Git status formatting. - typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true - # Install our own Git status formatter. - typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' - typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' - # Enable counters for staged, unstaged, etc. - typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 - - # Icon color. - typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 - typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 - # Custom icon. - # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_VCS_PREFIX='%fon ' - - # Show status of repositories of these types. You can add svn and/or hg if you are - # using them. If you do, your prompt may become slow even when your current directory - # isn't in an svn or hg repository. - typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) - - # These settings are used for repositories other than Git or when gitstatusd fails and - # Powerlevel10k has to fall back to using vcs_info. - typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 - typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 - typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 - - ##########################[ status: exit code of the last command ]########################### - # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and - # style them independently from the regular OK and ERROR state. - typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true - - # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as - # it will signify success by turning green. - typeset -g POWERLEVEL9K_STATUS_OK=false - typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70 - typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' - - # Status when some part of a pipe command fails but the overall exit status is zero. It may look - # like this: 1|0. - typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true - typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70 - typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' - - # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as - # it will signify error by turning red. - typeset -g POWERLEVEL9K_STATUS_ERROR=false - typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 - typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' - - # Status when the last command was terminated by a signal. - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160 - # Use terse signal names: "INT" instead of "SIGINT(2)". - typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' - - # Status when some part of a pipe command fails and the overall exit status is also non-zero. - # It may look like this: 1|0. - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160 - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' - - ###################[ command_execution_time: duration of the last command ]################### - # Show duration of the last command if takes at least this many seconds. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 - # Show this many fractional digits. Zero means round to seconds. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 - # Execution time color. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101 - # Duration format: 1d 2h 3m 4s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' - # Custom icon. - # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook ' - - #######################[ background_jobs: presence of background jobs ]####################### - # Don't show the number of background jobs. - typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false - # Background jobs color. - typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=70 - # Custom icon. - # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ direnv: direnv status (https://direnv.net/) ]######################## - # Direnv color. - typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 - # Custom icon. - # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### - # Default asdf color. Only used to display tools for which there is no color override (see below). - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND. - typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66 - - # There are four parameters that can be used to hide asdf tools. Each parameter describes - # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at - # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to - # hide a tool, it gets shown. - # - # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and - # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: - # - # asdf local python 3.8.1 - # asdf global python 3.8.1 - # - # After running both commands the current python version is 3.8.1 and its source is "local" as - # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, - # it'll hide python version in this case because 3.8.1 is the same as the global version. - # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't - # contain "local". - - # Hide tool versions that don't come from one of these sources. - # - # Available sources: - # - # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" - # - local `asdf current` says "set by /some/not/home/directory/file" - # - global `asdf current` says "set by /home/username/file" - # - # Note: If this parameter is set to (shell local global), it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. - typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) - - # If set to false, hide tool versions that are the same as global. - # - # Note: The name of this parameter doesn't reflect its meaning at all. - # Note: If this parameter is set to true, it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. - typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false - - # If set to false, hide tool versions that are equal to "system". - # - # Note: If this parameter is set to true, it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. - typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true - - # If set to non-empty value, hide tools unless there is a file matching the specified file pattern - # in the current directory, or its parent directory, or its grandparent directory, and so on. - # - # Note: If this parameter is set to empty value, it won't hide tools. - # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. - # - # Example: Hide nodejs version when there is no package.json and no *.js files in the current - # directory, in `..`, in `../..` and so on. - # - # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' - typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= - - # Ruby version from asdf. - typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168 - # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Python version from asdf. - typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=37 - # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Go version from asdf. - typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37 - # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Node.js version from asdf. - typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70 - # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Rust version from asdf. - typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37 - # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' - - # .NET Core version from asdf. - typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134 - # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_DOTNET_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Flutter version from asdf. - typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38 - # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Lua version from asdf. - typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32 - # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Java version from asdf. - typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32 - # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Perl version from asdf. - typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67 - # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Erlang version from asdf. - typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125 - # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Elixir version from asdf. - typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129 - # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Postgres version from asdf. - typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31 - # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' - - # PHP version from asdf. - typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 - # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Haskell version from asdf. - typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172 - # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Julia version from asdf. - typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70 - # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' - - ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### - # NordVPN connection indicator color. - typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 - # Hide NordVPN connection indicator when not connected. - typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= - typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= - # Custom icon. - # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## - # Ranger shell color. - typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 - # Custom icon. - # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### - # Nnn shell color. - typeset -g POWERLEVEL9K_NNN_FOREGROUND=72 - # Custom icon. - # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## - # xplr shell color. - typeset -g POWERLEVEL9K_XPLR_FOREGROUND=72 - # Custom icon. - # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########################[ vim_shell: vim shell indicator (:sh) ]########################### - # Vim shell indicator color. - typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34 - # Custom icon. - # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### - # Midnight Commander shell color. - typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=178 - # Custom icon. - # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## - # Nix shell color. - typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 - - # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. - # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################################[ disk_usage: disk usage ]################################## - # Colors for different levels of disk usage. - typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 - typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=220 - typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=160 - # Thresholds for different levels of disk usage (percentage points). - typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 - typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 - # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. - typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false - # Custom icon. - # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################################[ ram: free RAM ]####################################### - # RAM color. - typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 - # Custom icon. - # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################################[ swap: used swap ]###################################### - # Swap color. - typeset -g POWERLEVEL9K_SWAP_FOREGROUND=96 - # Custom icon. - # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################################[ load: CPU load ]###################################### - # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. - typeset -g POWERLEVEL9K_LOAD_WHICH=5 - # Load color when load is under 50%. - typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 - # Load color when load is between 50% and 70%. - typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 - # Load color when load is over 70%. - typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 - # Custom icon. - # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ - # Todo color. - typeset -g POWERLEVEL9K_TODO_FOREGROUND=110 - # Hide todo when the total number of tasks is zero. - typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true - # Hide todo when the number of tasks after filtering is zero. - typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false - - # Todo format. The following parameters are available within the expansion. - # - # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. - # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. - # - # These variables correspond to the last line of the output of `todo.sh -p ls`: - # - # TODO: 24 of 42 tasks shown - # - # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. - # - # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' - - # Custom icon. - # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ - # Timewarrior color. - typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110 - # If the tracked task is longer than 24 characters, truncate and append "…". - # Tip: To always display tasks without truncation, delete the following parameter. - # Tip: To hide task names and display just the icon when time tracking is enabled, set the - # value of the following parameter to "". - typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' - - # Custom icon. - # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## - # Taskwarrior color. - typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74 - - # Taskwarrior segment format. The following parameters are available within the expansion. - # - # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. - # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. - # - # Zero values are represented as empty parameters. - # - # The default format: - # - # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' - # - # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' - - # Custom icon. - # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ cpu_arch: CPU architecture ]################################ - # CPU architecture color. - typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172 - - # Hide the segment when on a specific CPU architecture. - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################################[ context: user@hostname ]################################## - # Context color when running with privileges. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 - # Context color in SSH without privileges. - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180 - # Default context color (no privileges, no SSH). - typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 - - # Context format when running with privileges: bold user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' - # Context format when in SSH without privileges: user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' - # Default context format (no privileges, no SSH): user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' - - # Don't show context unless running with privileges or in SSH. - # Tip: Remove the next line to always show context. - typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith ' - - ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### - # Python virtual environment color. - typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 - # Don't show Python version next to the virtual environment name. - typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false - # If set to "false", won't show virtualenv if pyenv is already shown. - # If set to "if-different", won't show virtualenv if it's the same as pyenv. - typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false - # Separate environment name from Python version only with a space. - typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= - # Custom icon. - # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################[ anaconda: conda environment (https://conda.io/) ]###################### - # Anaconda environment color. - typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 - - # Anaconda segment format. The following parameters are available within the expansion. - # - # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. - # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. - # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). - # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). - # - # CONDA_PROMPT_MODIFIER can be configured with the following command: - # - # conda config --set env_prompt '({default_env}) ' - # - # The last argument is a Python format string that can use the following variables: - # - # - prefix The same as CONDA_PREFIX. - # - default_env The same as CONDA_DEFAULT_ENV. - # - name The last segment of CONDA_PREFIX. - # - stacked_env Comma-separated list of names in the environment stack. The first element is - # always the same as default_env. - # - # Note: '({default_env}) ' is the default value of env_prompt. - # - # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER - # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former - # is empty. - typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' - - # Custom icon. - # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ - # Pyenv color. - typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 - # Hide python version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) - # If set to false, hide python version if it's the same as global: - # $(pyenv version-name) == $(pyenv global). - typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide python version if it's equal to "system". - typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true - - # Pyenv segment format. The following parameters are available within the expansion. - # - # - P9K_CONTENT Current pyenv environment (pyenv version-name). - # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). - # - # The default format has the following logic: - # - # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or - # starts with "$P9K_PYENV_PYTHON_VERSION/". - # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". - typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' - - # Custom icon. - # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ - # Goenv color. - typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37 - # Hide go version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) - # If set to false, hide go version if it's the same as global: - # $(goenv version-name) == $(goenv global). - typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide go version if it's equal to "system". - typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## - # Nodenv color. - typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70 - # Hide node version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) - # If set to false, hide node version if it's the same as global: - # $(nodenv version-name) == $(nodenv global). - typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide node version if it's equal to "system". - typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### - # Nvm color. - typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 - # Custom icon. - # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ - # Nodeenv color. - typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70 - # Don't show Node version next to the environment name. - typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false - # Separate environment name from Node version only with a space. - typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= - # Custom icon. - # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############################[ node_version: node.js version ]############################### - # Node version color. - typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70 - # Show node version only when in a directory tree containing package.json. - typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ go_version: go version (https://golang.org) ]######################## - # Go version color. - typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 - # Show go version only when in a go project subdirectory. - typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## - # Rust version color. - typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 - # Show rust version only when in a rust project subdirectory. - typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ - # .NET version color. - typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 - # Show .NET version only when in a .NET project subdirectory. - typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################[ php_version: php version (https://www.php.net/) ]###################### - # PHP version color. - typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 - # Show PHP version only when in a PHP project subdirectory. - typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### - # Laravel version color. - typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 - # Custom icon. - # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ####################[ java_version: java version (https://www.java.com/) ]#################### - # Java version color. - typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32 - # Show java version only when in a java project subdirectory. - typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true - # Show brief version. - typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false - # Custom icon. - # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### - # Package color. - typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117 - # Package format. The following parameters are available within the expansion. - # - # - P9K_PACKAGE_NAME The value of `name` field in package.json. - # - P9K_PACKAGE_VERSION The value of `version` field in package.json. - # - # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' - # Custom icon. - # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## - # Rbenv color. - typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 - # Hide ruby version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) - # If set to false, hide ruby version if it's the same as global: - # $(rbenv version-name) == $(rbenv global). - typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide ruby version if it's equal to "system". - typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## - # Rvm color. - typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 - # Don't show @gemset at the end. - typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false - # Don't show ruby- at the front. - typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ - # Fvm color. - typeset -g POWERLEVEL9K_FVM_FOREGROUND=38 - # Custom icon. - # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### - # Lua color. - typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32 - # Hide lua version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) - # If set to false, hide lua version if it's the same as global: - # $(luaenv version-name) == $(luaenv global). - typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide lua version if it's equal to "system". - typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ - # Java color. - typeset -g POWERLEVEL9K_JENV_FOREGROUND=32 - # Hide java version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) - # If set to false, hide java version if it's the same as global: - # $(jenv version-name) == $(jenv global). - typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide java version if it's equal to "system". - typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ - # Perl color. - typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67 - # Hide perl version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) - # If set to false, hide perl version if it's the same as global: - # $(plenv version-name) == $(plenv global). - typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide perl version if it's equal to "system". - typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ - # Perlbrew color. - typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 - # Show perlbrew version only when in a perl project subdirectory. - typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true - # Don't show "perl-" at the front. - typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ - # PHP color. - typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 - # Hide php version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) - # If set to false, hide php version if it's the same as global: - # $(phpenv version-name) == $(phpenv global). - typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide php version if it's equal to "system". - typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### - # Scala color. - typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160 - # Hide scala version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) - # If set to false, hide scala version if it's the same as global: - # $(scalaenv version-name) == $(scalaenv global). - typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide scala version if it's equal to "system". - typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### - # Haskell color. - typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172 - # Hide haskell version if it doesn't come from one of these sources. - # - # shell: version is set by STACK_YAML - # local: version is set by stack.yaml up the directory tree - # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) - typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) - # If set to false, hide haskell version if it's the same as in the implicit global project. - typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true - # Custom icon. - # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# - # Show kubecontext only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show kubecontext. - typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold' - - # Kubernetes context classes for the purpose of using different colors, icons and expansions with - # different contexts. - # - # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current kubernetes context gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' DEFAULT) - # - # If your current kubernetes context is "deathray-testing/default", its class is TEST - # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134 - # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext - # segment. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - # - # Within the expansion the following parameters are always available: - # - # - P9K_CONTENT The content that would've been displayed if there was no content - # expansion defined. - # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the - # output of `kubectl config get-contexts`. - # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the - # output of `kubectl config get-contexts`. - # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE - # in the output of `kubectl config get-contexts`. If there is no - # namespace, the parameter is set to "default". - # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the - # output of `kubectl config get-contexts`. - # - # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), - # the following extra parameters are available: - # - # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. - # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. - # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. - # - # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, - # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": - # - # - P9K_KUBECONTEXT_CLOUD_NAME=gke - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account - # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a - # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - # - # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": - # - # - P9K_KUBECONTEXT_CLOUD_NAME=eks - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 - # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 - # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= - # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. - POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' - # Append the current context's namespace if it's not "default". - POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' - - # Custom prefix. - # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' - - ################[ terraform: terraform workspace (https://www.terraform.io) ]################# - # Don't show terraform workspace if it's literally "default". - typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false - # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current terraform workspace gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' OTHER) - # - # If your current terraform workspace is "project_test", its class is TEST because "project_test" - # doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' OTHER) - typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 - # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ terraform_version: terraform version (https://www.terraform.io) ]############## - # Terraform version color. - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38 - # Custom icon. - # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# - # Show aws only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show aws. - typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' - - # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current AWS profile gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_AWS_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' DEFAULT) - # - # If your current AWS profile is "company_test", its class is TEST - # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_AWS_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 - # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # AWS segment format. The following parameters are available within the expansion. - # - # - P9K_AWS_PROFILE The name of the current AWS profile. - # - P9K_AWS_REGION The region associated with the current AWS profile. - typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' - - #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# - # AWS Elastic Beanstalk environment color. - typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 - # Custom icon. - # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## - # Show azure only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show azure. - typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' - # Azure account name color. - typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 - # Custom icon. - # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### - # Show gcloud only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show gcloud. - typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' - # Google cloud color. - typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 - - # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or - # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative - # enough. You can use the following parameters in the expansions. Each of them corresponds to the - # output of `gcloud` tool. - # - # Parameter | Source - # -------------------------|-------------------------------------------------------------------- - # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' - # P9K_GCLOUD_ACCOUNT | gcloud config get-value account - # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project - # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' - # - # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. - # - # Obtaining project name requires sending a request to Google servers. This can take a long time - # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud - # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets - # set and gcloud prompt segment transitions to state COMPLETE. - # - # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL - # and COMPLETE. You can also hide gcloud in state PARTIAL by setting - # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and - # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. - typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' - typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' - - # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name - # this often. Negative value disables periodic polling. In this mode project name is retrieved - # only when the current configuration, account or project id changes. - typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 - - # Custom icon. - # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# - # Show google_app_cred only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show google_app_cred. - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' - - # Google application credentials classes for the purpose of using different colors, icons and - # expansions with different credentials. - # - # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first - # element in each pair defines a pattern against which the current kubernetes context gets - # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion - # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION - # parameters, you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. - # The first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( - # '*:*prod*:*' PROD - # '*:*test*:*' TEST - # '*' DEFAULT) - # - # If your current Google application credentials is "service_account deathray-testing x@y.com", - # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( - # '*:*prod*:*' PROD # These values are examples that are unlikely - # '*:*test*:*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32 - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by - # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - # - # You can use the following parameters in the expansion. Each of them corresponds to one of the - # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. - # - # Parameter | JSON key file field - # ---------------------------------+--------------- - # P9K_GOOGLE_APP_CRED_TYPE | type - # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id - # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email - # - # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' - - ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### - # Toolbox color. - typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178 - # Don't display the name of the toolbox if it matches fedora-toolbox-*. - typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' - # Custom icon. - # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin ' - - ###############################[ public_ip: public IP address ]############################### - # Public IP color. - typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 - # Custom icon. - # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ########################[ vpn_ip: virtual private network indicator ]######################### - # VPN IP color. - typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 - # When on VPN, show just an icon without the IP address. - # Tip: To display the private IP address when on VPN, remove the next line. - typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= - # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN - # to see the name of the interface. - typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*' - # If set to true, show one segment per matching network interface. If set to false, show only - # one segment corresponding to the first matching network interface. - # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. - typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false - # Custom icon. - # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### - # IP color. - typeset -g POWERLEVEL9K_IP_FOREGROUND=38 - # The following parameters are accessible within the expansion: - # - # Parameter | Meaning - # ----------------------+------------------------------------------- - # P9K_IP_IP | IP address - # P9K_IP_INTERFACE | network interface - # P9K_IP_RX_BYTES | total number of bytes received - # P9K_IP_TX_BYTES | total number of bytes sent - # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt - # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt - # P9K_IP_RX_RATE | receive rate (since last prompt) - # P9K_IP_TX_RATE | send rate (since last prompt) - typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %70F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %215F⇡$P9K_IP_TX_RATE}' - # Show information for the first network interface whose name matches this regular expression. - # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. - typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' - # Custom icon. - # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #########################[ proxy: system-wide http/https/ftp proxy ]########################## - # Proxy color. - typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 - # Custom icon. - # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ battery: internal battery ]################################# - # Show battery in red when it's below this level and not connected to power supply. - typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 - typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 - # Show battery in green when it's charging or fully charged. - typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 - # Show battery in yellow when it's discharging. - typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 - # Battery pictograms going from low to high level of charge. - typeset -g POWERLEVEL9K_BATTERY_STAGES=('%K{232}▁' '%K{232}▂' '%K{232}▃' '%K{232}▄' '%K{232}▅' '%K{232}▆' '%K{232}▇' '%K{232}█') - # Don't show the remaining time to charge/discharge. - typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false - - #####################################[ wifi: wifi speed ]##################################### - # WiFi color. - typeset -g POWERLEVEL9K_WIFI_FOREGROUND=68 - # Custom icon. - # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). - # - # # Wifi colors and icons for different signal strength levels (low to high). - # typeset -g my_wifi_fg=(68 68 68 68 68) # <-- change these values - # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values - # - # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' - # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' - # - # The following parameters are accessible within the expansions: - # - # Parameter | Meaning - # ----------------------+--------------- - # P9K_WIFI_SSID | service set identifier, a.k.a. network name - # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown - # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second - # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 - # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 - # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) - - ####################################[ time: current time ]#################################### - # Current time color. - typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 - # Format for the current time: 09:51:02. See `man 3 strftime`. - typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' - # If set to true, time will update when you hit enter. This way prompts for the past - # commands will contain the start times of their commands as opposed to the default - # behavior where they contain the end times of their preceding commands. - typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false - # Custom icon. - # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TIME_PREFIX='%fat ' - - # Example of a user-defined prompt segment. Function prompt_example will be called on every - # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or - # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. - # - # Type `p10k help segment` for documentation and a more sophisticated example. - function prompt_example() { - p10k segment -f 208 -i '⭐' -t 'hello, %n' - } - - # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job - # is to generate the prompt segment for display in instant prompt. See - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function - # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k - # will replay these calls without actually calling instant_prompt_*. It is imperative that - # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this - # rule is not observed, the content of instant prompt will be incorrect. - # - # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If - # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. - function instant_prompt_example() { - # Since prompt_example always makes the same `p10k segment` calls, we can call it from - # instant_prompt_example. This will give us the same `example` prompt segment in the instant - # and regular prompts. - prompt_example - } - - # User-defined prompt segments can be customized the same way as built-in segments. - # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 - # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt - # when accepting a command line. Supported values: - # - # - off: Don't change prompt when accepting a command line. - # - always: Trim down prompt when accepting a command line. - # - same-dir: Trim down prompt when accepting a command line unless this is the first command - # typed after changing current working directory. - typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off - - # Instant prompt mode. - # - # - off: Disable instant prompt. Choose this if you've tried instant prompt and found - # it incompatible with your zsh configuration files. - # - quiet: Enable instant prompt and don't print warnings when detecting console output - # during zsh initialization. Choose this if you've read and understood - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - verbose: Enable instant prompt and print a warning when detecting console output during - # zsh initialization. Choose this if you've never tried instant prompt, haven't - # seen the warning, or if you are unsure what this all means. - typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose - - # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. - # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload - # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you - # really need it. - typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true - - # If p10k is already loaded, reload configuration. - # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. - (( ! $+functions[p10k] )) || p10k reload -} - -# Tell `p10k configure` which file it should overwrite. -typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} - -(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} -'builtin' 'unset' 'p10k_config_opts' diff --git a/.zsh/themes/powerlevel10k/config/p10k-pure.zsh b/.zsh/themes/powerlevel10k/config/p10k-pure.zsh deleted file mode 100644 index 97c1a20..0000000 --- a/.zsh/themes/powerlevel10k/config/p10k-pure.zsh +++ /dev/null @@ -1,193 +0,0 @@ -# Config file for Powerlevel10k with the style of Pure (https://github.com/sindresorhus/pure). -# -# Differences from Pure: -# -# - Git: -# - `@c4d3ec2c` instead of something like `v1.4.0~11` when in detached HEAD state. -# - No automatic `git fetch` (the same as in Pure with `PURE_GIT_PULL=0`). -# -# Apart from the differences listed above, the replication of Pure prompt is exact. This includes -# even the questionable parts. For example, just like in Pure, there is no indication of Git status -# being stale; prompt symbol is the same in command, visual and overwrite vi modes; when prompt -# doesn't fit on one line, it wraps around with no attempt to shorten it. -# -# If you like the general style of Pure but not particularly attached to all its quirks, type -# `p10k configure` and pick "Lean" style. This will give you slick minimalist prompt while taking -# advantage of Powerlevel10k features that aren't present in Pure. - -# Temporarily change options. -'builtin' 'local' '-a' 'p10k_config_opts' -[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -() { - emulate -L zsh -o extended_glob - - # Unset all configuration options. - unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' - - # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return - - # Prompt colors. - local grey=242 - local red=1 - local yellow=3 - local blue=4 - local magenta=5 - local cyan=6 - local white=7 - - # Left prompt segments. - typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - context # user@host - dir # current directory - vcs # git status - command_execution_time # previous command duration - # =========================[ Line #2 ]========================= - newline # \n - virtualenv # python virtual environment - prompt_char # prompt symbol - ) - - # Right prompt segments. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - # command_execution_time # previous command duration - # virtualenv # python virtual environment - # context # user@host - # time # current time - # =========================[ Line #2 ]========================= - newline # \n - ) - - # Basic style options that define the overall prompt look. - typeset -g POWERLEVEL9K_BACKGROUND= # transparent background - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol - typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION= # no segment icons - - # Add an empty line before each prompt except the first. This doesn't emulate the bug - # in Pure that makes prompt drift down whenever you use the Alt-C binding from fzf or similar. - typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true - - # Magenta prompt symbol if the last command succeeded. - typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=$magenta - # Red prompt symbol if the last command failed. - typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=$red - # Default prompt symbol. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' - # Prompt symbol in command vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' - # Prompt symbol in visual vi mode is the same as in command mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='❮' - # Prompt symbol in overwrite vi mode is the same as in command mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=false - - # Grey Python Virtual Environment. - typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=$grey - # Don't show Python version. - typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false - typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= - - # Blue current directory. - typeset -g POWERLEVEL9K_DIR_FOREGROUND=$blue - - # Context format when root: user@host. The first part white, the rest grey. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE="%F{$white}%n%f%F{$grey}@%m%f" - # Context format when not root: user@host. The whole thing grey. - typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE="%F{$grey}%n@%m%f" - # Don't show context unless root or in SSH. - typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_CONTENT_EXPANSION= - - # Show previous command duration only if it's >= 5s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5 - # Don't show fractional seconds. Thus, 7s rather than 7.3s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 - # Duration format: 1d 2h 3m 4s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' - # Yellow previous command duration. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=$yellow - - # Grey Git prompt. This makes stale prompts indistinguishable from up-to-date ones. - typeset -g POWERLEVEL9K_VCS_FOREGROUND=$grey - - # Disable async loading indicator to make directories that aren't Git repositories - # indistinguishable from large Git repositories without known state. - typeset -g POWERLEVEL9K_VCS_LOADING_TEXT= - - # Don't wait for Git status even for a millisecond, so that prompt always updates - # asynchronously when Git state changes. - typeset -g POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS=0 - - # Cyan ahead/behind arrows. - typeset -g POWERLEVEL9K_VCS_{INCOMING,OUTGOING}_CHANGESFORMAT_FOREGROUND=$cyan - # Don't show remote branch, current tag or stashes. - typeset -g POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind) - # Don't show the branch icon. - typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= - # When in detached HEAD state, show @commit where branch normally goes. - typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@' - # Don't show staged, unstaged, untracked indicators. - typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED}_ICON= - # Show '*' when there are staged, unstaged or untracked files. - typeset -g POWERLEVEL9K_VCS_DIRTY_ICON='*' - # Show '⇣' if local branch is behind remote. - typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON=':⇣' - # Show '⇡' if local branch is ahead of remote. - typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON=':⇡' - # Don't show the number of commits next to the ahead/behind arrows. - typeset -g POWERLEVEL9K_VCS_{COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=1 - # Remove space between '⇣' and '⇡' and all trailing spaces. - typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${${${P9K_CONTENT/⇣* :⇡/⇣⇡}// }//:/ }' - - # Grey current time. - typeset -g POWERLEVEL9K_TIME_FOREGROUND=$grey - # Format for the current time: 09:51:02. See `man 3 strftime`. - typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' - # If set to true, time will update when you hit enter. This way prompts for the past - # commands will contain the start times of their commands rather than the end times of - # their preceding commands. - typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false - - # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt - # when accepting a command line. Supported values: - # - # - off: Don't change prompt when accepting a command line. - # - always: Trim down prompt when accepting a command line. - # - same-dir: Trim down prompt when accepting a command line unless this is the first command - # typed after changing current working directory. - typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off - - # Instant prompt mode. - # - # - off: Disable instant prompt. Choose this if you've tried instant prompt and found - # it incompatible with your zsh configuration files. - # - quiet: Enable instant prompt and don't print warnings when detecting console output - # during zsh initialization. Choose this if you've read and understood - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - verbose: Enable instant prompt and print a warning when detecting console output during - # zsh initialization. Choose this if you've never tried instant prompt, haven't - # seen the warning, or if you are unsure what this all means. - typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose - - # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. - # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload - # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you - # really need it. - typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true - - # If p10k is already loaded, reload configuration. - # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. - (( ! $+functions[p10k] )) || p10k reload -} - -# Tell `p10k configure` which file it should overwrite. -typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} - -(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} -'builtin' 'unset' 'p10k_config_opts' diff --git a/.zsh/themes/powerlevel10k/config/p10k-rainbow.zsh b/.zsh/themes/powerlevel10k/config/p10k-rainbow.zsh deleted file mode 100644 index c12c286..0000000 --- a/.zsh/themes/powerlevel10k/config/p10k-rainbow.zsh +++ /dev/null @@ -1,1746 +0,0 @@ -# Config for Powerlevel10k with powerline prompt style with colorful background. -# Type `p10k configure` to generate your own config based on it. -# -# Tip: Looking for a nice color? Here's a one-liner to print colormap. -# -# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done - -# Temporarily change options. -'builtin' 'local' '-a' 'p10k_config_opts' -[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -() { - emulate -L zsh -o extended_glob - - # Unset all configuration options. This allows you to apply configuration changes without - # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. - unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' - - # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return - - # The list of segments shown on the left. Fill it with the most important segments. - typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - # os_icon # os identifier - dir # current directory - vcs # git status - # =========================[ Line #2 ]========================= - newline # \n - # prompt_char # prompt symbol - ) - - # The list of segments shown on the right. Fill it with less important segments. - # Right prompt on the last prompt line (where you are typing your commands) gets - # automatically hidden when the input line reaches it. Right prompt above the - # last prompt line gets hidden if it would overlap with left prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( - # =========================[ Line #1 ]========================= - status # exit code of the last command - command_execution_time # duration of the last command - background_jobs # presence of background jobs - direnv # direnv status (https://direnv.net/) - asdf # asdf version manager (https://github.com/asdf-vm/asdf) - virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) - anaconda # conda environment (https://conda.io/) - pyenv # python environment (https://github.com/pyenv/pyenv) - goenv # go environment (https://github.com/syndbg/goenv) - nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) - nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) - nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) - # node_version # node.js version - # go_version # go version (https://golang.org) - # rust_version # rustc version (https://www.rust-lang.org) - # dotnet_version # .NET version (https://dotnet.microsoft.com) - # php_version # php version (https://www.php.net/) - # laravel_version # laravel php framework version (https://laravel.com/) - # java_version # java version (https://www.java.com/) - # package # name@version from package.json (https://docs.npmjs.com/files/package.json) - rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) - rvm # ruby version from rvm (https://rvm.io) - fvm # flutter version management (https://github.com/leoafarias/fvm) - luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) - jenv # java version from jenv (https://github.com/jenv/jenv) - plenv # perl version from plenv (https://github.com/tokuhirom/plenv) - perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) - phpenv # php version from phpenv (https://github.com/phpenv/phpenv) - scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) - haskell_stack # haskell version from stack (https://haskellstack.org/) - kubecontext # current kubernetes context (https://kubernetes.io/) - terraform # terraform workspace (https://www.terraform.io) - # terraform_version # terraform version (https://www.terraform.io) - aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) - aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) - azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) - gcloud # google cloud cli account and project (https://cloud.google.com/) - google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) - toolbox # toolbox name (https://github.com/containers/toolbox) - context # user@hostname - nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) - ranger # ranger shell (https://github.com/ranger/ranger) - nnn # nnn shell (https://github.com/jarun/nnn) - xplr # xplr shell (https://github.com/sayanarijit/xplr) - vim_shell # vim shell indicator (:sh) - midnight_commander # midnight commander shell (https://midnight-commander.org/) - nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) - # vi_mode # vi mode (you don't need this if you've enabled prompt_char) - # vpn_ip # virtual private network indicator - # load # CPU load - # disk_usage # disk usage - # ram # free RAM - # swap # used swap - todo # todo items (https://github.com/todotxt/todo.txt-cli) - timewarrior # timewarrior tracking status (https://timewarrior.net/) - taskwarrior # taskwarrior task count (https://taskwarrior.org/) - # cpu_arch # CPU architecture - # time # current time - # =========================[ Line #2 ]========================= - newline - # ip # ip address and bandwidth usage for a specified network interface - # public_ip # public IP address - # proxy # system-wide http/https/ftp proxy - # battery # internal battery - # wifi # wifi speed - # example # example user-defined segment (see prompt_example function below) - ) - - # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. - typeset -g POWERLEVEL9K_MODE=nerdfont-complete - # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid - # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. - typeset -g POWERLEVEL9K_ICON_PADDING=none - - # When set to true, icons appear before content on both sides of the prompt. When set - # to false, icons go after content. If empty or not set, icons go before content in the left - # prompt and after content in the right prompt. - # - # You can also override it for a specific segment: - # - # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false - # - # Or for a specific segment in specific state: - # - # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false - typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT= - - # Add an empty line before each prompt. - typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true - - # Connect left prompt lines with these symbols. You'll probably want to use the same color - # as POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND below. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='%242F╭─' - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX='%242F├─' - typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='%242F╰─' - # Connect right prompt lines with these symbols. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX='%242F─╮' - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX='%242F─┤' - typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX='%242F─╯' - - # Filler between left and right prompt on the first prompt line. You can set it to ' ', '·' or - # '─'. The last two make it easier to see the alignment between left and right prompt and to - # separate prompt from command output. You might want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false - # for more compact prompt if using this option. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_BACKGROUND= - typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_BACKGROUND= - if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then - # The color of the filler. You'll probably want to match the color of POWERLEVEL9K_MULTILINE - # ornaments defined above. - typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=242 - # Start filler from the edge of the screen if there are no left segments on the first line. - typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' - # End filler on the edge of the screen if there are no right segments on the first line. - typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' - fi - - # Separator between same-color segments on the left. - typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='\uE0B1' - # Separator between same-color segments on the right. - typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='\uE0B3' - # Separator between different-color segments on the left. - typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0' - # Separator between different-color segments on the right. - typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0B2' - # The right end of left prompt. - typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0B0' - # The left end of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='\uE0B2' - # The left end of left prompt. - typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= - # The right end of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= - # Left prompt terminator for lines without any segments. - typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= - - #################################[ os_icon: os identifier ]################################## - # OS identifier color. - typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=232 - typeset -g POWERLEVEL9K_OS_ICON_BACKGROUND=7 - # Custom icon. - # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' - - ################################[ prompt_char: prompt symbol ]################################ - # Transparent background. - typeset -g POWERLEVEL9K_PROMPT_CHAR_BACKGROUND= - # Green prompt symbol if the last command succeeded. - typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 - # Red prompt symbol if the last command failed. - typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 - # Default prompt symbol. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' - # Prompt symbol in command vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' - # Prompt symbol in visual vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' - # Prompt symbol in overwrite vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' - typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true - # No line terminator if prompt_char is the last segment. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= - # No line introducer if prompt_char is the first segment. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= - # No surrounding whitespace. - typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_{LEFT,RIGHT}_WHITESPACE= - - ##################################[ dir: current directory ]################################## - # Current directory background color. - typeset -g POWERLEVEL9K_DIR_BACKGROUND=4 - # Default current directory foreground color. - typeset -g POWERLEVEL9K_DIR_FOREGROUND=254 - # If directory is too long, shorten some of its segments to the shortest possible unique - # prefix. The shortened directory can be tab-completed to the original. - typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique - # Replace removed segment suffixes with this symbol. - typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= - # Color of the shortened directory segments. - typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=250 - # Color of the anchor directory segments. Anchor segments are never shortened. The first - # segment is always an anchor. - typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=255 - # Display anchor directory segments in bold. - typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true - # Don't shorten directories that contain any of these files. They are anchors. - local anchor_files=( - .bzr - .citc - .git - .hg - .node-version - .python-version - .go-version - .ruby-version - .lua-version - .java-version - .perl-version - .php-version - .tool-version - .shorten_folder_marker - .svn - .terraform - CVS - Cargo.toml - composer.json - go.mod - package.json - stack.yaml - ) - typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" - # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains - # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is - # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) - # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers - # and other directories don't. - # - # Optionally, "first" and "last" can be followed by ":<offset>" where <offset> is an integer. - # This moves the truncation point to the right (positive offset) or to the left (negative offset) - # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" - # respectively. - typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false - # Don't shorten this many last directory segments. They are anchors. - typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 - # Shorten directory if it's longer than this even if there is space for it. The value can - # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, - # directory will be shortened only when prompt doesn't fit or when other parameters demand it - # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). - # If set to `0`, directory will always be shortened to its minimum length. - typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 - # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this - # many columns for typing commands. - typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 - # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least - # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. - typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 - # If set to true, embed a hyperlink into the directory. Useful for quickly - # opening a directory in the file manager simply by clicking the link. - # Can also be handy when the directory is shortened, as it allows you to see - # the full directory that was used in previous commands. - typeset -g POWERLEVEL9K_DIR_HYPERLINK=false - - # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON - # and POWERLEVEL9K_DIR_CLASSES below. - typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 - - # The default icon shown next to non-writable and non-existent directories when - # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. - # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' - - # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different - # directories. It must be an array with 3 * N elements. Each triplet consists of: - # - # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with - # extended_glob option enabled. - # 2. Directory class for the purpose of styling. - # 3. An empty string. - # - # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. - # - # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories - # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_DIR_CLASSES=( - # '~/work(|/*)' WORK '' - # '~(|/*)' HOME '' - # '*' DEFAULT '') - # - # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one - # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or - # WORK_NON_EXISTENT. - # - # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an - # option to define custom colors and icons for different directory classes. - # - # # Styling for WORK. - # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_BACKGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=254 - # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=250 - # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=255 - # - # # Styling for WORK_NOT_WRITABLE. - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_BACKGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=254 - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=250 - # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=255 - # - # # Styling for WORK_NON_EXISTENT. - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_BACKGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=254 - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=250 - # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=255 - # - # If a styling parameter isn't explicitly defined for some class, it falls back to the classless - # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls - # back to POWERLEVEL9K_DIR_FOREGROUND. - # - # typeset -g POWERLEVEL9K_DIR_CLASSES=() - - # Custom prefix. - # typeset -g POWERLEVEL9K_DIR_PREFIX='in ' - - #####################################[ vcs: git status ]###################################### - # Version control background colors. - typeset -g POWERLEVEL9K_VCS_CLEAN_BACKGROUND=2 - typeset -g POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=3 - typeset -g POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=2 - typeset -g POWERLEVEL9K_VCS_CONFLICTED_BACKGROUND=3 - typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=8 - - # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. - typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= - - # Untracked files icon. It's really a question mark, your font isn't broken. - # Change the value of this parameter to show a different icon. - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' - - # Formatter for Git status. - # - # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. - # - # You can edit the function to customize how Git status looks. - # - # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: - # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. - function my_git_formatter() { - emulate -L zsh - - if [[ -n $P9K_CONTENT ]]; then - # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from - # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. - typeset -g my_git_format=$P9K_CONTENT - return - fi - - # Styling for different parts of Git status. - local meta='%7F' # white foreground - local clean='%0F' # black foreground - local modified='%0F' # black foreground - local untracked='%0F' # black foreground - local conflicted='%1F' # red foreground - - local res - - if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - local branch=${(V)VCS_STATUS_LOCAL_BRANCH} - # If local branch name is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show local branch name in full without truncation, delete the next line. - (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line - res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" - fi - - if [[ -n $VCS_STATUS_TAG - # Show tag only if not on a branch. - # Tip: To always show tag, delete the next line. - && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line - ]]; then - local tag=${(V)VCS_STATUS_TAG} - # If tag name is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show tag name in full without truncation, delete the next line. - (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line - res+="${meta}#${clean}${tag//\%/%%}" - fi - - # Display the current Git commit if there is no branch and no tag. - # Tip: To always display the current Git commit, delete the next line. - [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line - res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" - - # Show tracking branch name if it differs from local branch. - if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then - res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" - fi - - # Display "wip" if the latest commit's summary contains "wip" or "WIP". - if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then - res+=" ${modified}wip" - fi - - # ⇣42 if behind the remote. - (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" - # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. - (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " - (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" - # ⇠42 if behind the push remote. - (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" - (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " - # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. - (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" - # *42 if have stashes. - (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" - # 'merge' if the repo is in an unusual state. - [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" - # ~42 if have merge conflicts. - (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" - # +42 if have staged changes. - (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" - # !42 if have unstaged changes. - (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" - # ?42 if have untracked files. It's really a question mark, your font isn't broken. - # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. - # Remove the next line if you don't want to see untracked files at all. - (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" - # "─" if the number of unstaged files is unknown. This can happen due to - # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower - # than the number of files in the Git index, or due to bash.showDirtyState being set to false - # in the repository config. The number of staged and untracked files may also be unknown - # in this case. - (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" - - typeset -g my_git_format=$res - } - functions -M my_git_formatter 2>/dev/null - - # Don't count the number of unstaged, untracked and conflicted files in Git repositories with - # more than this many files in the index. Negative value means infinity. - # - # If you are working in Git repositories with tens of millions of files and seeing performance - # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output - # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's - # config: `git config bash.showDirtyState false`. - typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 - - # Don't show Git status in prompt for repositories whose workdir matches this pattern. - # For example, if set to '~', the Git repository at $HOME/.git will be ignored. - # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. - typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' - - # Disable the default Git status formatting. - typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true - # Install our own Git status formatter. - typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter()))+${my_git_format}}' - # Enable counters for staged, unstaged, etc. - typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 - - # Custom icon. - # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_VCS_PREFIX='on ' - - # Show status of repositories of these types. You can add svn and/or hg if you are - # using them. If you do, your prompt may become slow even when your current directory - # isn't in an svn or hg repository. - typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) - - ##########################[ status: exit code of the last command ]########################### - # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and - # style them independently from the regular OK and ERROR state. - typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true - - # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as - # it will signify success by turning green. - typeset -g POWERLEVEL9K_STATUS_OK=true - typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' - typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=2 - typeset -g POWERLEVEL9K_STATUS_OK_BACKGROUND=0 - - # Status when some part of a pipe command fails but the overall exit status is zero. It may look - # like this: 1|0. - typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true - typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' - typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=2 - typeset -g POWERLEVEL9K_STATUS_OK_PIPE_BACKGROUND=0 - - # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as - # it will signify error by turning red. - typeset -g POWERLEVEL9K_STATUS_ERROR=true - typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' - typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=3 - typeset -g POWERLEVEL9K_STATUS_ERROR_BACKGROUND=1 - - # Status when the last command was terminated by a signal. - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true - # Use terse signal names: "INT" instead of "SIGINT(2)". - typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=3 - typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_BACKGROUND=1 - - # Status when some part of a pipe command fails and the overall exit status is also non-zero. - # It may look like this: 1|0. - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=3 - typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_BACKGROUND=1 - - ###################[ command_execution_time: duration of the last command ]################### - # Execution time color. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=0 - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND=3 - # Show duration of the last command if takes at least this many seconds. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 - # Show this many fractional digits. Zero means round to seconds. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 - # Duration format: 1d 2h 3m 4s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' - # Custom icon. - # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='took ' - - #######################[ background_jobs: presence of background jobs ]####################### - # Background jobs color. - typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=6 - typeset -g POWERLEVEL9K_BACKGROUND_JOBS_BACKGROUND=0 - # Don't show the number of background jobs. - typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false - # Custom icon. - # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ direnv: direnv status (https://direnv.net/) ]######################## - # Direnv color. - typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=3 - typeset -g POWERLEVEL9K_DIRENV_BACKGROUND=0 - # Custom icon. - # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### - # Default asdf color. Only used to display tools for which there is no color override (see below). - # Tip: Override these parameters for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND and - # POWERLEVEL9K_ASDF_${TOOL}_BACKGROUND. - typeset -g POWERLEVEL9K_ASDF_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_BACKGROUND=7 - - # There are four parameters that can be used to hide asdf tools. Each parameter describes - # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at - # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to - # hide a tool, it gets shown. - # - # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and - # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: - # - # asdf local python 3.8.1 - # asdf global python 3.8.1 - # - # After running both commands the current python version is 3.8.1 and its source is "local" as - # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, - # it'll hide python version in this case because 3.8.1 is the same as the global version. - # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't - # contain "local". - - # Hide tool versions that don't come from one of these sources. - # - # Available sources: - # - # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" - # - local `asdf current` says "set by /some/not/home/directory/file" - # - global `asdf current` says "set by /home/username/file" - # - # Note: If this parameter is set to (shell local global), it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. - typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) - - # If set to false, hide tool versions that are the same as global. - # - # Note: The name of this parameter doesn't reflect its meaning at all. - # Note: If this parameter is set to true, it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. - typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false - - # If set to false, hide tool versions that are equal to "system". - # - # Note: If this parameter is set to true, it won't hide tools. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. - typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true - - # If set to non-empty value, hide tools unless there is a file matching the specified file pattern - # in the current directory, or its parent directory, or its grandparent directory, and so on. - # - # Note: If this parameter is set to empty value, it won't hide tools. - # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. - # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. - # - # Example: Hide nodejs version when there is no package.json and no *.js files in the current - # directory, in `..`, in `../..` and so on. - # - # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' - typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= - - # Ruby version from asdf. - typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_RUBY_BACKGROUND=1 - # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Python version from asdf. - typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_PYTHON_BACKGROUND=4 - # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Go version from asdf. - typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_GOLANG_BACKGROUND=4 - # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Node.js version from asdf. - typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_NODEJS_BACKGROUND=2 - # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Rust version from asdf. - typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_RUST_BACKGROUND=208 - # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' - - # .NET Core version from asdf. - typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_BACKGROUND=5 - # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Flutter version from asdf. - typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_FLUTTER_BACKGROUND=4 - # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Lua version from asdf. - typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_LUA_BACKGROUND=4 - # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Java version from asdf. - typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=1 - typeset -g POWERLEVEL9K_ASDF_JAVA_BACKGROUND=7 - # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Perl version from asdf. - typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_PERL_BACKGROUND=4 - # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Erlang version from asdf. - typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_ERLANG_BACKGROUND=1 - # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Elixir version from asdf. - typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_ELIXIR_BACKGROUND=5 - # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Postgres version from asdf. - typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_POSTGRES_BACKGROUND=6 - # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' - - # PHP version from asdf. - typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_PHP_BACKGROUND=5 - # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Haskell version from asdf. - typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_HASKELL_BACKGROUND=3 - # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' - - # Julia version from asdf. - typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=0 - typeset -g POWERLEVEL9K_ASDF_JULIA_BACKGROUND=2 - # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' - - ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### - # NordVPN connection indicator color. - typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=7 - typeset -g POWERLEVEL9K_NORDVPN_BACKGROUND=4 - # Hide NordVPN connection indicator when not connected. - typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= - typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= - # Custom icon. - # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## - # Ranger shell color. - typeset -g POWERLEVEL9K_RANGER_FOREGROUND=3 - typeset -g POWERLEVEL9K_RANGER_BACKGROUND=0 - # Custom icon. - # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### - # Nnn shell color. - typeset -g POWERLEVEL9K_NNN_FOREGROUND=0 - typeset -g POWERLEVEL9K_NNN_BACKGROUND=6 - # Custom icon. - # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## - # xplr shell color. - typeset -g POWERLEVEL9K_XPLR_FOREGROUND=0 - typeset -g POWERLEVEL9K_XPLR_BACKGROUND=6 - # Custom icon. - # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########################[ vim_shell: vim shell indicator (:sh) ]########################### - # Vim shell indicator color. - typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=0 - typeset -g POWERLEVEL9K_VIM_SHELL_BACKGROUND=2 - # Custom icon. - # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### - # Midnight Commander shell color. - typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=3 - typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_BACKGROUND=0 - # Custom icon. - # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## - # Nix shell color. - typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=0 - typeset -g POWERLEVEL9K_NIX_SHELL_BACKGROUND=4 - - # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. - # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################################[ disk_usage: disk usage ]################################## - # Colors for different levels of disk usage. - typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=3 - typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_BACKGROUND=0 - typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=0 - typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_BACKGROUND=3 - typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=7 - typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_BACKGROUND=1 - # Thresholds for different levels of disk usage (percentage points). - typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 - typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 - # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. - typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false - # Custom icon. - # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ vi_mode: vi mode (you don't need this if you've enabled prompt_char) ]########### - # Foreground color. - typeset -g POWERLEVEL9K_VI_MODE_FOREGROUND=0 - # Text and color for normal (a.k.a. command) vi mode. - typeset -g POWERLEVEL9K_VI_COMMAND_MODE_STRING=NORMAL - typeset -g POWERLEVEL9K_VI_MODE_NORMAL_BACKGROUND=2 - # Text and color for visual vi mode. - typeset -g POWERLEVEL9K_VI_VISUAL_MODE_STRING=VISUAL - typeset -g POWERLEVEL9K_VI_MODE_VISUAL_BACKGROUND=4 - # Text and color for overtype (a.k.a. overwrite and replace) vi mode. - typeset -g POWERLEVEL9K_VI_OVERWRITE_MODE_STRING=OVERTYPE - typeset -g POWERLEVEL9K_VI_MODE_OVERWRITE_BACKGROUND=3 - # Text and color for insert vi mode. - typeset -g POWERLEVEL9K_VI_INSERT_MODE_STRING= - typeset -g POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND=8 - - ######################################[ ram: free RAM ]####################################### - # RAM color. - typeset -g POWERLEVEL9K_RAM_FOREGROUND=0 - typeset -g POWERLEVEL9K_RAM_BACKGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################################[ swap: used swap ]###################################### - # Swap color. - typeset -g POWERLEVEL9K_SWAP_FOREGROUND=0 - typeset -g POWERLEVEL9K_SWAP_BACKGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ######################################[ load: CPU load ]###################################### - # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. - typeset -g POWERLEVEL9K_LOAD_WHICH=5 - # Load color when load is under 50%. - typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=0 - typeset -g POWERLEVEL9K_LOAD_NORMAL_BACKGROUND=2 - # Load color when load is between 50% and 70%. - typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=0 - typeset -g POWERLEVEL9K_LOAD_WARNING_BACKGROUND=3 - # Load color when load is over 70%. - typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=0 - typeset -g POWERLEVEL9K_LOAD_CRITICAL_BACKGROUND=1 - # Custom icon. - # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ - # Todo color. - typeset -g POWERLEVEL9K_TODO_FOREGROUND=0 - typeset -g POWERLEVEL9K_TODO_BACKGROUND=8 - # Hide todo when the total number of tasks is zero. - typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true - # Hide todo when the number of tasks after filtering is zero. - typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false - - # Todo format. The following parameters are available within the expansion. - # - # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. - # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. - # - # These variables correspond to the last line of the output of `todo.sh -p ls`: - # - # TODO: 24 of 42 tasks shown - # - # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. - # - # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' - - # Custom icon. - # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ - # Timewarrior color. - typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=255 - typeset -g POWERLEVEL9K_TIMEWARRIOR_BACKGROUND=8 - - # If the tracked task is longer than 24 characters, truncate and append "…". - # Tip: To always display tasks without truncation, delete the following parameter. - # Tip: To hide task names and display just the icon when time tracking is enabled, set the - # value of the following parameter to "". - typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' - - # Custom icon. - # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## - # Taskwarrior color. - typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=0 - typeset -g POWERLEVEL9K_TASKWARRIOR_BACKGROUND=6 - - # Taskwarrior segment format. The following parameters are available within the expansion. - # - # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. - # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. - # - # Zero values are represented as empty parameters. - # - # The default format: - # - # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' - # - # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' - - # Custom icon. - # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ cpu_arch: CPU architecture ]################################ - # CPU architecture color. - typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=0 - typeset -g POWERLEVEL9K_CPU_ARCH_BACKGROUND=3 - - # Hide the segment when on a specific CPU architecture. - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################################[ context: user@hostname ]################################## - # Context color when running with privileges. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1 - typeset -g POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND=0 - # Context color in SSH without privileges. - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=3 - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_BACKGROUND=0 - # Default context color (no privileges, no SSH). - typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=3 - typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=0 - - # Context format when running with privileges: user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m' - # Context format when in SSH without privileges: user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' - # Default context format (no privileges, no SSH): user@hostname. - typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' - - # Don't show context unless running with privileges or in SSH. - # Tip: Remove the next line to always show context. - typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='with ' - - ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### - # Python virtual environment color. - typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=0 - typeset -g POWERLEVEL9K_VIRTUALENV_BACKGROUND=4 - # Don't show Python version next to the virtual environment name. - typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false - # If set to "false", won't show virtualenv if pyenv is already shown. - # If set to "if-different", won't show virtualenv if it's the same as pyenv. - typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false - # Separate environment name from Python version only with a space. - typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= - # Custom icon. - # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################[ anaconda: conda environment (https://conda.io/) ]###################### - # Anaconda environment color. - typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=0 - typeset -g POWERLEVEL9K_ANACONDA_BACKGROUND=4 - - # Anaconda segment format. The following parameters are available within the expansion. - # - # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. - # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. - # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). - # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). - # - # CONDA_PROMPT_MODIFIER can be configured with the following command: - # - # conda config --set env_prompt '({default_env}) ' - # - # The last argument is a Python format string that can use the following variables: - # - # - prefix The same as CONDA_PREFIX. - # - default_env The same as CONDA_DEFAULT_ENV. - # - name The last segment of CONDA_PREFIX. - # - stacked_env Comma-separated list of names in the environment stack. The first element is - # always the same as default_env. - # - # Note: '({default_env}) ' is the default value of env_prompt. - # - # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER - # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former - # is empty. - typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' - - # Custom icon. - # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ - # Pyenv color. - typeset -g POWERLEVEL9K_PYENV_FOREGROUND=0 - typeset -g POWERLEVEL9K_PYENV_BACKGROUND=4 - # Hide python version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) - # If set to false, hide python version if it's the same as global: - # $(pyenv version-name) == $(pyenv global). - typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide python version if it's equal to "system". - typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true - - # Pyenv segment format. The following parameters are available within the expansion. - # - # - P9K_CONTENT Current pyenv environment (pyenv version-name). - # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). - # - # The default format has the following logic: - # - # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or - # starts with "$P9K_PYENV_PYTHON_VERSION/". - # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". - typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' - - # Custom icon. - # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ - # Goenv color. - typeset -g POWERLEVEL9K_GOENV_FOREGROUND=0 - typeset -g POWERLEVEL9K_GOENV_BACKGROUND=4 - # Hide go version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) - # If set to false, hide go version if it's the same as global: - # $(goenv version-name) == $(goenv global). - typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide go version if it's equal to "system". - typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## - # Nodenv color. - typeset -g POWERLEVEL9K_NODENV_FOREGROUND=2 - typeset -g POWERLEVEL9K_NODENV_BACKGROUND=0 - # Hide node version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) - # If set to false, hide node version if it's the same as global: - # $(nodenv version-name) == $(nodenv global). - typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide node version if it's equal to "system". - typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### - # Nvm color. - typeset -g POWERLEVEL9K_NVM_FOREGROUND=0 - typeset -g POWERLEVEL9K_NVM_BACKGROUND=5 - # Custom icon. - # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ - # Nodeenv color. - typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=2 - typeset -g POWERLEVEL9K_NODEENV_BACKGROUND=0 - # Don't show Node version next to the environment name. - typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false - # Separate environment name from Node version only with a space. - typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= - # Custom icon. - # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##############################[ node_version: node.js version ]############################### - # Node version color. - typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=7 - typeset -g POWERLEVEL9K_NODE_VERSION_BACKGROUND=2 - # Show node version only when in a directory tree containing package.json. - typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ go_version: go version (https://golang.org) ]######################## - # Go version color. - typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=255 - typeset -g POWERLEVEL9K_GO_VERSION_BACKGROUND=2 - # Show go version only when in a go project subdirectory. - typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## - # Rust version color. - typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=0 - typeset -g POWERLEVEL9K_RUST_VERSION_BACKGROUND=208 - # Show rust version only when in a rust project subdirectory. - typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ - # .NET version color. - typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=7 - typeset -g POWERLEVEL9K_DOTNET_VERSION_BACKGROUND=5 - # Show .NET version only when in a .NET project subdirectory. - typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #####################[ php_version: php version (https://www.php.net/) ]###################### - # PHP version color. - typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=0 - typeset -g POWERLEVEL9K_PHP_VERSION_BACKGROUND=5 - # Show PHP version only when in a PHP project subdirectory. - typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true - # Custom icon. - # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### - # Laravel version color. - typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=1 - typeset -g POWERLEVEL9K_LARAVEL_VERSION_BACKGROUND=7 - # Custom icon. - # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## - # Rbenv color. - typeset -g POWERLEVEL9K_RBENV_FOREGROUND=0 - typeset -g POWERLEVEL9K_RBENV_BACKGROUND=1 - # Hide ruby version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) - # If set to false, hide ruby version if it's the same as global: - # $(rbenv version-name) == $(rbenv global). - typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide ruby version if it's equal to "system". - typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ####################[ java_version: java version (https://www.java.com/) ]#################### - # Java version color. - typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=1 - typeset -g POWERLEVEL9K_JAVA_VERSION_BACKGROUND=7 - # Show java version only when in a java project subdirectory. - typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true - # Show brief version. - typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false - # Custom icon. - # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### - # Package color. - typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=0 - typeset -g POWERLEVEL9K_PACKAGE_BACKGROUND=6 - - # Package format. The following parameters are available within the expansion. - # - # - P9K_PACKAGE_NAME The value of `name` field in package.json. - # - P9K_PACKAGE_VERSION The value of `version` field in package.json. - # - # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' - - # Custom icon. - # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## - # Rvm color. - typeset -g POWERLEVEL9K_RVM_FOREGROUND=0 - typeset -g POWERLEVEL9K_RVM_BACKGROUND=240 - # Don't show @gemset at the end. - typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false - # Don't show ruby- at the front. - typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ - # Fvm color. - typeset -g POWERLEVEL9K_FVM_FOREGROUND=0 - typeset -g POWERLEVEL9K_FVM_BACKGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### - # Lua color. - typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=0 - typeset -g POWERLEVEL9K_LUAENV_BACKGROUND=4 - # Hide lua version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) - # If set to false, hide lua version if it's the same as global: - # $(luaenv version-name) == $(luaenv global). - typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide lua version if it's equal to "system". - typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ - # Java color. - typeset -g POWERLEVEL9K_JENV_FOREGROUND=1 - typeset -g POWERLEVEL9K_JENV_BACKGROUND=7 - # Hide java version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) - # If set to false, hide java version if it's the same as global: - # $(jenv version-name) == $(jenv global). - typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide java version if it's equal to "system". - typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ - # Perl color. - typeset -g POWERLEVEL9K_PLENV_FOREGROUND=0 - typeset -g POWERLEVEL9K_PLENV_BACKGROUND=4 - # Hide perl version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) - # If set to false, hide perl version if it's the same as global: - # $(plenv version-name) == $(plenv global). - typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide perl version if it's equal to "system". - typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ - # Perlbrew color. - typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 - # Show perlbrew version only when in a perl project subdirectory. - typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true - # Don't show "perl-" at the front. - typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ - # PHP color. - typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=0 - typeset -g POWERLEVEL9K_PHPENV_BACKGROUND=5 - # Hide php version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) - # If set to false, hide php version if it's the same as global: - # $(phpenv version-name) == $(phpenv global). - typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide PHP version if it's equal to "system". - typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### - # Scala color. - typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=0 - typeset -g POWERLEVEL9K_SCALAENV_BACKGROUND=1 - # Hide scala version if it doesn't come from one of these sources. - typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) - # If set to false, hide scala version if it's the same as global: - # $(scalaenv version-name) == $(scalaenv global). - typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false - # If set to false, hide scala version if it's equal to "system". - typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true - # Custom icon. - # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### - # Haskell color. - typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=0 - typeset -g POWERLEVEL9K_HASKELL_STACK_BACKGROUND=3 - - # Hide haskell version if it doesn't come from one of these sources. - # - # shell: version is set by STACK_YAML - # local: version is set by stack.yaml up the directory tree - # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) - typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) - # If set to false, hide haskell version if it's the same as in the implicit global project. - typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true - # Custom icon. - # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ terraform: terraform workspace (https://www.terraform.io) ]################# - # Don't show terraform workspace if it's literally "default". - typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false - # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current terraform workspace gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' OTHER) - # - # If your current terraform workspace is "project_test", its class is TEST because "project_test" - # doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=2 - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_BACKGROUND=0 - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' OTHER) - typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=4 - typeset -g POWERLEVEL9K_TERRAFORM_OTHER_BACKGROUND=0 - # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #############[ terraform_version: terraform version (https://www.terraform.io) ]############## - # Terraform version color. - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=4 - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_BACKGROUND=0 - # Custom icon. - # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ terraform_version: It shows active terraform version (https://www.terraform.io) ]################# - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_SHOW_ON_COMMAND='terraform|tf' - - #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# - # Show kubecontext only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show kubecontext. - typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold' - - # Kubernetes context classes for the purpose of using different colors, icons and expansions with - # different contexts. - # - # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current kubernetes context gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' DEFAULT) - # - # If your current kubernetes context is "deathray-testing/default", its class is TEST - # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=0 - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_BACKGROUND=2 - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=7 - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_BACKGROUND=5 - # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext - # segment. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - # - # Within the expansion the following parameters are always available: - # - # - P9K_CONTENT The content that would've been displayed if there was no content - # expansion defined. - # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the - # output of `kubectl config get-contexts`. - # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the - # output of `kubectl config get-contexts`. - # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE - # in the output of `kubectl config get-contexts`. If there is no - # namespace, the parameter is set to "default". - # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the - # output of `kubectl config get-contexts`. - # - # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), - # the following extra parameters are available: - # - # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. - # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. - # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. - # - # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, - # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": - # - # - P9K_KUBECONTEXT_CLOUD_NAME=gke - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account - # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a - # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - # - # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": - # - # - P9K_KUBECONTEXT_CLOUD_NAME=eks - # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 - # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 - # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= - # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. - POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' - # Append the current context's namespace if it's not "default". - POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' - - # Custom prefix. - # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='at ' - - #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# - # Show aws only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show aws. - typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' - - # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current AWS profile gets matched. - # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) - # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_AWS_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' DEFAULT) - # - # If your current AWS profile is "company_test", its class is TEST - # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_AWS_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=7 - typeset -g POWERLEVEL9K_AWS_DEFAULT_BACKGROUND=1 - # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # AWS segment format. The following parameters are available within the expansion. - # - # - P9K_AWS_PROFILE The name of the current AWS profile. - # - P9K_AWS_REGION The region associated with the current AWS profile. - typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' - - #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# - # AWS Elastic Beanstalk environment color. - typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=2 - typeset -g POWERLEVEL9K_AWS_EB_ENV_BACKGROUND=0 - # Custom icon. - # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## - # Show azure only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show azure. - typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' - # Azure account name color. - typeset -g POWERLEVEL9K_AZURE_FOREGROUND=7 - typeset -g POWERLEVEL9K_AZURE_BACKGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### - # Show gcloud only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show gcloud. - typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' - # Google cloud color. - typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=7 - typeset -g POWERLEVEL9K_GCLOUD_BACKGROUND=4 - - # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or - # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative - # enough. You can use the following parameters in the expansions. Each of them corresponds to the - # output of `gcloud` tool. - # - # Parameter | Source - # -------------------------|-------------------------------------------------------------------- - # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' - # P9K_GCLOUD_ACCOUNT | gcloud config get-value account - # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project - # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' - # - # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. - # - # Obtaining project name requires sending a request to Google servers. This can take a long time - # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud - # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets - # set and gcloud prompt segment transitions to state COMPLETE. - # - # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL - # and COMPLETE. You can also hide gcloud in state PARTIAL by setting - # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and - # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. - typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' - typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' - - # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name - # this often. Negative value disables periodic polling. In this mode project name is retrieved - # only when the current configuration, account or project id changes. - typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 - - # Custom icon. - # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# - # Show google_app_cred only when the command you are typing invokes one of these tools. - # Tip: Remove the next line to always show google_app_cred. - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' - - # Google application credentials classes for the purpose of using different colors, icons and - # expansions with different credentials. - # - # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first - # element in each pair defines a pattern against which the current kubernetes context gets - # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion - # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION - # parameters, you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. - # The first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( - # '*:*prod*:*' PROD - # '*:*test*:*' TEST - # '*' DEFAULT) - # - # If your current Google application credentials is "service_account deathray-testing x@y.com", - # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. - # - # You can define different colors, icons and content expansions for different classes: - # - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( - # '*:*prod*:*' PROD # These values are examples that are unlikely - # '*:*test*:*' TEST # to match your needs. Customize them as needed. - '*' DEFAULT) - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=7 - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_BACKGROUND=4 - # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by - # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - # - # You can use the following parameters in the expansion. Each of them corresponds to one of the - # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. - # - # Parameter | JSON key file field - # ---------------------------------+--------------- - # P9K_GOOGLE_APP_CRED_TYPE | type - # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id - # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email - # - # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. - typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' - - ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### - # Toolbox color. - typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=0 - typeset -g POWERLEVEL9K_TOOLBOX_BACKGROUND=3 - # Don't display the name of the toolbox if it matches fedora-toolbox-*. - typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' - # Custom icon. - # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='in ' - - ###############################[ public_ip: public IP address ]############################### - # Public IP color. - typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=7 - typeset -g POWERLEVEL9K_PUBLIC_IP_BACKGROUND=0 - # Custom icon. - # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ########################[ vpn_ip: virtual private network indicator ]######################### - # VPN IP color. - typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=0 - typeset -g POWERLEVEL9K_VPN_IP_BACKGROUND=6 - # When on VPN, show just an icon without the IP address. - # Tip: To display the private IP address when on VPN, remove the next line. - typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= - # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN - # to see the name of the interface. - typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*' - # If set to true, show one segment per matching network interface. If set to false, show only - # one segment corresponding to the first matching network interface. - # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. - typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false - # Custom icon. - # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### - # IP color. - typeset -g POWERLEVEL9K_IP_BACKGROUND=4 - typeset -g POWERLEVEL9K_IP_FOREGROUND=0 - # The following parameters are accessible within the expansion: - # - # Parameter | Meaning - # ----------------------+------------------------------------------- - # P9K_IP_IP | IP address - # P9K_IP_INTERFACE | network interface - # P9K_IP_RX_BYTES | total number of bytes received - # P9K_IP_TX_BYTES | total number of bytes sent - # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt - # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt - # P9K_IP_RX_RATE | receive rate (since last prompt) - # P9K_IP_TX_RATE | send rate (since last prompt) - typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='${P9K_IP_RX_RATE:+⇣$P9K_IP_RX_RATE }${P9K_IP_TX_RATE:+⇡$P9K_IP_TX_RATE }$P9K_IP_IP' - # Show information for the first network interface whose name matches this regular expression. - # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. - typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' - # Custom icon. - # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' - - #########################[ proxy: system-wide http/https/ftp proxy ]########################## - # Proxy color. - typeset -g POWERLEVEL9K_PROXY_FOREGROUND=4 - typeset -g POWERLEVEL9K_PROXY_BACKGROUND=0 - # Custom icon. - # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ battery: internal battery ]################################# - # Show battery in red when it's below this level and not connected to power supply. - typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 - typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=1 - # Show battery in green when it's charging or fully charged. - typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=2 - # Show battery in yellow when it's discharging. - typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=3 - # Battery pictograms going from low to high level of charge. - typeset -g POWERLEVEL9K_BATTERY_STAGES=('%K{232}▁' '%K{232}▂' '%K{232}▃' '%K{232}▄' '%K{232}▅' '%K{232}▆' '%K{232}▇' '%K{232}█') - # Don't show the remaining time to charge/discharge. - typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false - typeset -g POWERLEVEL9K_BATTERY_BACKGROUND=0 - - #####################################[ wifi: wifi speed ]##################################### - # WiFi color. - typeset -g POWERLEVEL9K_WIFI_FOREGROUND=0 - typeset -g POWERLEVEL9K_WIFI_BACKGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). - # - # # Wifi colors and icons for different signal strength levels (low to high). - # typeset -g my_wifi_fg=(0 0 0 0 0) # <-- change these values - # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values - # - # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' - # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' - # - # The following parameters are accessible within the expansions: - # - # Parameter | Meaning - # ----------------------+--------------- - # P9K_WIFI_SSID | service set identifier, a.k.a. network name - # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown - # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second - # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 - # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 - # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) - - ####################################[ time: current time ]#################################### - # Current time color. - typeset -g POWERLEVEL9K_TIME_FOREGROUND=0 - typeset -g POWERLEVEL9K_TIME_BACKGROUND=7 - # Format for the current time: 09:51:02. See `man 3 strftime`. - typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' - # If set to true, time will update when you hit enter. This way prompts for the past - # commands will contain the start times of their commands as opposed to the default - # behavior where they contain the end times of their preceding commands. - typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false - # Custom icon. - # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TIME_PREFIX='at ' - - # Example of a user-defined prompt segment. Function prompt_example will be called on every - # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or - # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and yellow text on red background - # greeting the user. - # - # Type `p10k help segment` for documentation and a more sophisticated example. - function prompt_example() { - p10k segment -b 1 -f 3 -i '⭐' -t 'hello, %n' - } - - # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job - # is to generate the prompt segment for display in instant prompt. See - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function - # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k - # will replay these calls without actually calling instant_prompt_*. It is imperative that - # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this - # rule is not observed, the content of instant prompt will be incorrect. - # - # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If - # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. - function instant_prompt_example() { - # Since prompt_example always makes the same `p10k segment` calls, we can call it from - # instant_prompt_example. This will give us the same `example` prompt segment in the instant - # and regular prompts. - prompt_example - } - - # User-defined prompt segments can be customized the same way as built-in segments. - typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=3 - typeset -g POWERLEVEL9K_EXAMPLE_BACKGROUND=1 - # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' - - # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt - # when accepting a command line. Supported values: - # - # - off: Don't change prompt when accepting a command line. - # - always: Trim down prompt when accepting a command line. - # - same-dir: Trim down prompt when accepting a command line unless this is the first command - # typed after changing current working directory. - typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off - - # Instant prompt mode. - # - # - off: Disable instant prompt. Choose this if you've tried instant prompt and found - # it incompatible with your zsh configuration files. - # - quiet: Enable instant prompt and don't print warnings when detecting console output - # during zsh initialization. Choose this if you've read and understood - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - verbose: Enable instant prompt and print a warning when detecting console output during - # zsh initialization. Choose this if you've never tried instant prompt, haven't - # seen the warning, or if you are unsure what this all means. - typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose - - # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. - # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload - # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you - # really need it. - typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true - - # If p10k is already loaded, reload configuration. - # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. - (( ! $+functions[p10k] )) || p10k reload -} - -# Tell `p10k configure` which file it should overwrite. -typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} - -(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} -'builtin' 'unset' 'p10k_config_opts' diff --git a/.zsh/themes/powerlevel10k/config/p10k-robbyrussell.zsh b/.zsh/themes/powerlevel10k/config/p10k-robbyrussell.zsh deleted file mode 100644 index a59e222..0000000 --- a/.zsh/themes/powerlevel10k/config/p10k-robbyrussell.zsh +++ /dev/null @@ -1,111 +0,0 @@ -# Config file for Powerlevel10k with the style of robbyrussell theme from Oh My Zsh. -# -# Original: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#robbyrussell. -# -# Replication of robbyrussell theme is exact. The only observable difference is in -# performance. Powerlevel10k prompt is very fast everywhere, even in large Git repositories. -# -# Usage: Source this file either before or after loading Powerlevel10k. -# -# source ~/powerlevel10k/config/p10k-robbyrussell.zsh -# source ~/powerlevel10k/powerlevel10k.zsh-theme - -# Temporarily change options. -'builtin' 'local' '-a' 'p10k_config_opts' -[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -() { - emulate -L zsh -o extended_glob - - # Unset all configuration options. - unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' - - # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return - - # Left prompt segments. - typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(prompt_char dir vcs) - # Right prompt segments. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=() - - # Basic style options that define the overall prompt look. - typeset -g POWERLEVEL9K_BACKGROUND= # transparent background - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space - typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol - typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION= # no segment icons - - # Green prompt symbol if the last command succeeded. - typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=green - # Red prompt symbol if the last command failed. - typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=red - # Prompt symbol: bold arrow. - typeset -g POWERLEVEL9K_PROMPT_CHAR_CONTENT_EXPANSION='%B➜ ' - - # Cyan current directory. - typeset -g POWERLEVEL9K_DIR_FOREGROUND=cyan - # Show only the last segment of the current directory. - typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_last - # Bold directory. - typeset -g POWERLEVEL9K_DIR_CONTENT_EXPANSION='%B$P9K_CONTENT' - - # Git status formatter. - function my_git_formatter() { - emulate -L zsh - if [[ -n $P9K_CONTENT ]]; then - # If P9K_CONTENT is not empty, it's either "loading" or from vcs_info (not from - # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. - typeset -g my_git_format=$P9K_CONTENT - else - # Use VCS_STATUS_* parameters to assemble Git status. See reference: - # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. - typeset -g my_git_format="${1+%B%4F}git:(${1+%1F}" - my_git_format+=${${VCS_STATUS_LOCAL_BRANCH:-${VCS_STATUS_COMMIT[1,8]}}//\%/%%} - my_git_format+="${1+%4F})" - if (( VCS_STATUS_NUM_CONFLICTED || VCS_STATUS_NUM_STAGED || - VCS_STATUS_NUM_UNSTAGED || VCS_STATUS_NUM_UNTRACKED )); then - my_git_format+=" ${1+%3F}✗" - fi - fi - } - functions -M my_git_formatter 2>/dev/null - - # Disable the default Git status formatting. - typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true - # Install our own Git status formatter. - typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' - typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter()))+${my_git_format}}' - # Grey Git status when loading. - typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=246 - - # Instant prompt mode. - # - # - off: Disable instant prompt. Choose this if you've tried instant prompt and found - # it incompatible with your zsh configuration files. - # - quiet: Enable instant prompt and don't print warnings when detecting console output - # during zsh initialization. Choose this if you've read and understood - # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. - # - verbose: Enable instant prompt and print a warning when detecting console output during - # zsh initialization. Choose this if you've never tried instant prompt, haven't - # seen the warning, or if you are unsure what this all means. - typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose - - # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. - # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload - # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you - # really need it. - typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true - - # If p10k is already loaded, reload configuration. - # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. - (( ! $+functions[p10k] )) || p10k reload -} - -# Tell `p10k configure` which file it should overwrite. -typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} - -(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} -'builtin' 'unset' 'p10k_config_opts' diff --git a/.zsh/themes/powerlevel10k/font.md b/.zsh/themes/powerlevel10k/font.md deleted file mode 100644 index 429af32..0000000 --- a/.zsh/themes/powerlevel10k/font.md +++ /dev/null @@ -1,152 +0,0 @@ -# Recommended font: Meslo Nerd Font patched for Powerlevel10k - -Gorgeous monospace font designed by Jim Lyles for Bitstream, customized by the same for Apple, -further customized by André Berg, and finally patched by yours truly with customized scripts -originally developed by Ryan L McIntyre of Nerd Fonts. Contains all glyphs and symbols that -Powerlevel10k may need. Battle-tested in dozens of different terminals on all major operating -systems. - -*FAQ*: [How was the recommended font created?](README.md#how-was-the-recommended-font-created) - -## Automatic font installation - -If you are using iTerm2 or Termux, `p10k configure` can install the recommended font for you. -Simply answer `Yes` when asked whether to install *Meslo Nerd Font*. - -If you are using a different terminal, proceed with manual font installation. 👇 - -## Manual font installation - -1. Download these four ttf files: - - [MesloLGS NF Regular.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf) - - [MesloLGS NF Bold.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf) - - [MesloLGS NF Italic.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf) - - [MesloLGS NF Bold Italic.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf) -1. Double-click on each file and click "Install". This will make `MesloLGS NF` font available to all - applications on your system. -1. Configure your terminal to use this font: - - **iTerm2**: Type `p10k configure` and answer `Yes` when asked whether to install - *Meslo Nerd Font*. Alternatively, open *iTerm2 → Preferences → Profiles → Text* and set *Font* to - `MesloLGS NF`. - - **Apple Terminal**: Open *Terminal → Preferences → Profiles → Text*, click *Change* under *Font* - and select `MesloLGS NF` family. - - **Hyper**: Open *Hyper → Edit → Preferences* and change the value of `fontFamily` under - `module.exports.config` to `MesloLGS NF`. - - **Visual Studio Code**: Open *File → Preferences → Settings* (PC) or - *Code → Preferences → Settings* (Mac), enter `terminal.integrated.fontFamily` in the search box at - the top of *Settings* tab and set the value below to `MesloLGS NF`. - Consult [this screenshot]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/389133fb8c9a2347929a23702ce3039aacc46c3d/visual-studio-code-font-settings.jpg) - to see how it should look like or see [this issue]( - https://github.com/romkatv/powerlevel10k/issues/671) for extra information. - - **GNOME Terminal** (the default Ubuntu terminal): Open *Terminal → Preferences* and click on the - selected profile under *Profiles*. Check *Custom font* under *Text Appearance* and select - `MesloLGS NF Regular`. - - **Konsole**: Open *Settings → Edit Current Profile → Appearance*, click *Select Font* and select - `MesloLGS NF Regular`. - - **Tilix**: Open *Tilix → Preferences* and click on the selected profile under *Profiles*. Check - *Custom font* under *Text Appearance* and select `MesloLGS NF Regular`. - - **Windows Console Host** (the old thing): Click the icon in the top left corner, then - *Properties → Font* and set *Font* to `MesloLGS NF`. - - **Windows Terminal** by Microsoft (the new thing): Open *Settings* (<kbd>Ctrl+,</kbd>), click - either on the selected profile under *Profiles* or on *Defaults*, click *Appearance* and set - *Font face* to `MesloLGS NF`. - - **IntelliJ** (and other IDEs by Jet Brains): Open *IDE → Edit → Preferences → Editor → - Color Scheme → Console Font*. Select *Use console font instead of the default* and set the font - name to `MesloLGS NF`. - - **Termux**: Type `p10k configure` and answer `Yes` when asked whether to install - *Meslo Nerd Font*. - - **Blink**: Type `config`, go to *Appearance*, tap *Add a new font*, tap *Open Gallery*, select - *MesloLGS NF.css*, tap *import* and type `exit` in the home view to reload the font. - - **Terminus**: Open *Settings → Appearance* and set *Font* to `MesloLGS NF`. - - **Terminator**: Open *Preferences* using the context menu. Under *Profiles* select the *General* - tab (should be selected already), uncheck *Use the system fixed width font* (if not already) - and select `MesloLGS NF Regular`. Exit the Preferences dialog by clicking *Close*. - - **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance* - tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`. - Exit the Preferences dialog by clicking *Close*. - - **MobaXterm**: Open *Settings* → *Configuration* → *Terminal* → (under *Terminal look and feel*) - and change *Font* to `MesloLGS NF`. - - **Asbrú Connection Manager**: Open *Preferences → Local Shell Options → Look and Feel*, enable - *Use these personal options* and change *Font:* under *Terminal UI* to `MesloLGS NF Regular`. - To change the font for the remote host connections, go to *Preferences → Terminal Options → - Look and Feel* and change *Font:* under *Terminal UI* to `MesloLGS NF Regular`. - - **WSLtty**: Right click on an open terminal and then on *Options*. In the *Text* section, under - *Font*, click *"Select..."* and set Font to `MesloLGS NF Regular`. - - **Yakuake**: Click *≡* → *Manage Profiles* → *New* → *Appearance*. Click *Choose* next to the - *Font* dropdown, select `MesloLGS NF` and click *OK*. Click *OK* to save the profile. Select the - new profile and click *Set as Default*. - - **Alacritty**: Create or open `~/.config/alacritty/alacritty.yml` and add the following section - to it: - ```yaml - font: - normal: - family: "MesloLGS NF" - ``` - - **kitty**: Create or open `~/.config/kitty/kitty.conf` and add the following line to it: - ```text - font_family MesloLGS NF - ``` - Restart kitty by closing all sessions and opening a new session. - - **puTTY**: Set *Window* → *Appearance* → *Font* to `MesloLGS NF`. Requires puTTY - version >= 0.75. - - **WezTerm**: Create or open `$HOME/.config/wezterm/wezterm.lua` and add the following: - ```lua - local wezterm = require 'wezterm'; - return { - font = wezterm.font("MesloLGS NF"), - } - ``` - If the file already exists, only add the line with the font to the existing return. - Also add the first line if it is not already present. - - **urxvt**: Create or open `~/.Xresources` and add the following line to it: - ```text - URxvt.font: xft:MesloLGS NF:size=11 - ``` - You can adjust the font size to your preference. After changing the config run - `xrdb ~/.Xresources` to reload it. The new config is applied to all new terminals. - - **xterm**: Create or open `~/.Xresources` and add the following line to it: - ```text - xterm*faceName: MesloLGS NF - ``` - After changing the config run `xrdb ~/.Xresources` to reload it. The new config is applied to - all new terminals. - - Crostini (Linux on Chrome OS): Open - chrome-untrusted://terminal/html/nassh_preferences_editor.html, set *Text font family* to - `'MesloLGS NF'` (including the quotes) and *Custom CSS (inline text)* to the following: - ```css - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Regular.ttf"); - font-weight: normal; - font-style: normal; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold.ttf"); - font-weight: bold; - font-style: normal; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Italic.ttf"); - font-weight: normal; - font-style: italic; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold%20Italic.ttf"); - font-weight: bold; - font-style: italic; - } - ``` - **_CAVEAT_**: If you open the normal terminal preferences these settings will be overwritten. -1. Run `p10k configure` to generate a new `~/.p10k.zsh`. The old config may work - incorrectly with the new font. - -_Using a different terminal and know how to set the font for it? Share your knowledge by sending a -PR to expand the list!_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/.clang-format b/.zsh/themes/powerlevel10k/gitstatus/.clang-format deleted file mode 100644 index f5e3c53..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/.clang-format +++ /dev/null @@ -1,4 +0,0 @@ -BasedOnStyle: Google -ColumnLimit: 100 -DerivePointerAlignment: false -PointerAlignment: Left diff --git a/.zsh/themes/powerlevel10k/gitstatus/.gitattributes b/.zsh/themes/powerlevel10k/gitstatus/.gitattributes deleted file mode 100644 index 5c1135c..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/.gitattributes +++ /dev/null @@ -1,16 +0,0 @@ -* text=auto - -*.cc text eol=lf -*.h text eol=lf -*.info text eol=lf -*.json text eol=lf -*.md text eol=lf -*.sh text eol=lf -*.zsh text eol=lf - -/.clang-format text eol=lf -/LICENSE text eol=lf -/Makefile text eol=lf -/build text eol=lf -/install text eol=lf -/mbuild text eol=lf diff --git a/.zsh/themes/powerlevel10k/gitstatus/.gitignore b/.zsh/themes/powerlevel10k/gitstatus/.gitignore deleted file mode 100644 index 4915fe6..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.zwc -/core -/deps/libgit2-*.tar.gz -/locks -/logs -/obj -/usrbin/gitstatusd* -/.vscode/ipch diff --git a/.zsh/themes/powerlevel10k/gitstatus/.vscode/c_cpp_properties.json b/.zsh/themes/powerlevel10k/gitstatus/.vscode/c_cpp_properties.json deleted file mode 100644 index 323a6cd..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/src" - ], - "defines": [ - ], - "compilerPath": "/usr/bin/g++", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "gcc-x64" - } - ], - "version": 4 -} diff --git a/.zsh/themes/powerlevel10k/gitstatus/.vscode/settings.json b/.zsh/themes/powerlevel10k/gitstatus/.vscode/settings.json deleted file mode 100644 index bec79f9..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/.vscode/settings.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "files.exclude": { - "*.zwc": true, - "core": true, - "locks/": true, - "logs/": true, - "obj/": true, - "usrbin/": true, - }, - "files.associations": { - "array": "cpp", - "atomic": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "complex": "cpp", - "condition_variable": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "fstream": "cpp", - "functional": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "memory": "cpp", - "mutex": "cpp", - "new": "cpp", - "numeric": "cpp", - "optional": "cpp", - "ostream": "cpp", - "ratio": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "thread": "cpp", - "type_traits": "cpp", - "tuple": "cpp", - "typeinfo": "cpp", - "utility": "cpp", - "variant": "cpp", - "cstdarg": "cpp", - "charconv": "cpp", - "algorithm": "cpp", - "cinttypes": "cpp", - "iterator": "cpp", - "map": "cpp", - "memory_resource": "cpp", - "random": "cpp", - "string": "cpp", - "bit": "cpp", - "netfwd": "cpp" - } -} diff --git a/.zsh/themes/powerlevel10k/gitstatus/LICENSE b/.zsh/themes/powerlevel10k/gitstatus/LICENSE deleted file mode 100644 index f288702..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - <program> Copyright (C) <year> <name of author> - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -<https://www.gnu.org/licenses/>. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -<https://www.gnu.org/licenses/why-not-lgpl.html>. diff --git a/.zsh/themes/powerlevel10k/gitstatus/Makefile b/.zsh/themes/powerlevel10k/gitstatus/Makefile deleted file mode 100644 index 450d5ea..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -APPNAME ?= gitstatusd -OBJDIR ?= obj - -CXX ?= g++ -ZSH := $(shell command -v zsh 2> /dev/null) - -VERSION ?= $(shell . ./build.info && printf "%s" "$$gitstatus_version") - -# Note: -fsized-deallocation is not used to avoid binary compatibility issues on macOS. -# -# Sized delete is implemented as __ZdlPvm in /usr/lib/libc++.1.dylib but this symbol is -# missing in macOS prior to 10.13. -CXXFLAGS += -std=c++14 -funsigned-char -O3 -DNDEBUG -DGITSTATUS_VERSION=$(VERSION) -Wall -Werror # -g -fsanitize=thread -LDFLAGS += -pthread # -fsanitize=thread -LDLIBS += -lgit2 # -lprofiler -lunwind - -SRCS := $(shell find src -name "*.cc") -OBJS := $(patsubst src/%.cc, $(OBJDIR)/%.o, $(SRCS)) - -all: $(APPNAME) - -$(APPNAME): usrbin/$(APPNAME) - -usrbin/$(APPNAME): $(OBJS) - $(CXX) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@ - -$(OBJDIR): - mkdir -p -- $(OBJDIR) - -$(OBJDIR)/%.o: src/%.cc Makefile build.info | $(OBJDIR) - $(CXX) $(CXXFLAGS) -MM -MT $@ src/$*.cc >$(OBJDIR)/$*.dep - $(CXX) $(CXXFLAGS) -Wall -c -o $@ src/$*.cc - -clean: - rm -rf -- $(OBJDIR) - -zwc: - $(or $(ZSH),:) -fc 'for f in *.zsh install; do zcompile -R -- $$f.zwc $$f || exit; done' - -minify: - rm -rf -- .clang-format .git .gitattributes .gitignore .vscode deps docs src usrbin/.gitkeep LICENSE Makefile README.md build mbuild - -pkg: zwc - GITSTATUS_DAEMON= GITSTATUS_CACHE_DIR=$(shell pwd)/usrbin ./install -f - --include $(OBJS:.o=.dep) diff --git a/.zsh/themes/powerlevel10k/gitstatus/README.md b/.zsh/themes/powerlevel10k/gitstatus/README.md deleted file mode 100644 index 82a1998..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/README.md +++ /dev/null @@ -1,530 +0,0 @@ -# gitstatus - -**gitstatus** is a 10x faster alternative to `git status` and `git describe`. Its primary use -case is to enable fast git prompt in interactive shells. - -Heavy lifting is done by **gitstatusd** -- a custom binary written in C++. It comes with Zsh and -Bash bindings for integration with shell. - -## Table of Contents - -1. [Using from Zsh](#using-from-zsh) -1. [Using from Bash](#using-from-bash) -2. [Using from other shells](#using-from-other-shells) -1. [How it works](#how-it-works) -1. [Benchmarks](#benchmarks) -1. [Why fast](#why-fast) -1. [Requirements](#requirements) -1. [Compiling](#compiling) -1. [License](#license) - -## Using from Zsh - -The easiest way to take advantage of gitstatus from Zsh is to use a theme that's already integrated -with it. For example, [Powerlevel10k](https://github.com/romkatv/powerlevel10k) is a flexible and -fast theme with first-class gitstatus integration. If you install Powerlevel10k, you don't need to -install gitstatus. - -![Powerlevel10k Zsh Theme]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/prompt-styles-high-contrast.png) - -For those who wish to use gitstatus without a theme, there is -[gitstatus.prompt.zsh](gitstatus.prompt.zsh). Install it as follows: - -```zsh -git clone --depth=1 https://github.com/romkatv/gitstatus.git ~/gitstatus -echo 'source ~/gitstatus/gitstatus.prompt.zsh' >>! ~/.zshrc -``` - -Users in China can use the official mirror on gitee.com for faster download.<br> -中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. - -```zsh -git clone --depth=1 https://gitee.com/romkatv/gitstatus.git ~/gitstatus -echo 'source ~/gitstatus/gitstatus.prompt.zsh' >>! ~/.zshrc -``` - -Alternatively, if you have Homebrew installed: - -```zsh -brew install romkatv/gitstatus/gitstatus -echo "source $(brew --prefix)/opt/gitstatus/gitstatus.prompt.zsh" >>! ~/.zshrc -``` - -(If you choose this option, replace `~/gitstatus` with `$(brew --prefix)/opt/gitstatus/gitstatus` -in all code snippets below.) - -_Make sure to disable your current theme if you have one._ - -This will give you a basic yet functional prompt with git status in it. It's -[over 10x faster](#benchmarks) than any alternative that can give you comparable prompt. In order -to customize it, set `PROMPT` and/or `RPROMPT` at the end of `~/.zshrc` after sourcing -`gitstatus.prompt.zsh`. Insert `${GITSTATUS_PROMPT}` where you want git status to go. For example: - -```zsh -source ~/gitstatus/gitstatus.prompt.zsh - -PROMPT='%~%# ' # left prompt: directory followed by %/# (normal/root) -RPROMPT='$GITSTATUS_PROMPT' # right prompt: git status -``` - -The expansion of `${GITSTATUS_PROMPT}` can contain the following bits: - -| segment | meaning | -|-------------|-------------------------------------------------------| -| `master` | current branch | -| `#v1` | HEAD is tagged with `v1`; not shown when on a branch | -| `@5fc6fca4` | current commit; not shown when on a branch or tag | -| `⇣1` | local branch is behind the remote by 1 commit | -| `⇡2` | local branch is ahead of the remote by 2 commits | -| `⇠3` | local branch is behind the push remote by 3 commits | -| `⇢4` | local branch is ahead of the push remote by 4 commits | -| `*5` | there are 5 stashes | -| `merge` | merge is in progress (could be some other action) | -| `~6` | there are 6 merge conflicts | -| `+7` | there are 7 staged changes | -| `!8` | there are 8 unstaged changes | -| `?9` | there are 9 untracked files | - -`$GITSTATUS_PROMPT_LEN` tells you how long `$GITSTATUS_PROMPT` is when printed to the console. -[gitstatus.prompt.zsh](gitstatus.prompt.zsh) has an example of using it to truncate the current -directory. - -If you'd like to change the format of git status, or want to have greater control over the -process of assembling `PROMPT`, you can copy and modify parts of -[gitstatus.prompt.zsh](gitstatus.prompt.zsh) instead of sourcing the script. Your `~/.zshrc` -might look something like this: - -```zsh -source ~/gitstatus/gitstatus.plugin.zsh - -function my_set_prompt() { - PROMPT='%~%# ' - RPROMPT='' - - if gitstatus_query MY && [[ $VCS_STATUS_RESULT == ok-sync ]]; then - RPROMPT=${${VCS_STATUS_LOCAL_BRANCH:-@${VCS_STATUS_COMMIT}}//\%/%%} # escape % - (( VCS_STATUS_NUM_STAGED )) && RPROMPT+='+' - (( VCS_STATUS_NUM_UNSTAGED )) && RPROMPT+='!' - (( VCS_STATUS_NUM_UNTRACKED )) && RPROMPT+='?' - fi - - setopt no_prompt_{bang,subst} prompt_percent # enable/disable correct prompt expansions -} - -gitstatus_stop 'MY' && gitstatus_start -s -1 -u -1 -c -1 -d -1 'MY' -autoload -Uz add-zsh-hook -add-zsh-hook precmd my_set_prompt -``` - -This snippet is sourcing `gitstatus.plugin.zsh` rather than `gitstatus.prompt.zsh`. The former -defines low-level bindings that communicate with gitstatusd over pipes. The latter is a simple -script that uses these bindings to assemble git prompt. - -Unlike [Powerlevel10k](https://github.com/romkatv/powerlevel10k), code based on -[gitstatus.prompt.zsh](gitstatus.prompt.zsh) is communicating with gitstatusd synchronously. This -can make your prompt slow when working in a large git repository or on a slow machine. To avoid -this problem, call `gitstatus_query` asynchronously as documented in -[gitstatus.plugin.zsh](gitstatus.plugin.zsh). This can be quite challenging. - -## Using from Bash - -The easiest way to take advantage of gitstatus from Bash is via -[gitstatus.prompt.sh](gitstatus.prompt.sh). Install it as follows: - -```bash -git clone --depth=1 https://github.com/romkatv/gitstatus.git ~/gitstatus -echo 'source ~/gitstatus/gitstatus.prompt.sh' >> ~/.bashrc -``` - -Users in China can use the official mirror on gitee.com for faster download.<br> -中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. - -```bash -git clone --depth=1 https://gitee.com/romkatv/gitstatus.git ~/gitstatus -echo 'source ~/gitstatus/gitstatus.prompt.sh' >> ~/.bashrc -``` - -Alternatively, if you have Homebrew installed: - -```zsh -brew install romkatv/gitstatus/gitstatus -echo "source $(brew --prefix)/opt/gitstatus/gitstatus.prompt.sh" >> ~/.bashrc -``` - -(If you choose this option, replace `~/gitstatus` with `$(brew --prefix)/opt/gitstatus/gitstatus` -in all code snippets below.) - -This will give you a basic yet functional prompt with git status in it. It's -[over 10x faster](#benchmarks) than any alternative that can give you comparable prompt. - -![Bash Prompt with GitStatus]( - https://raw.githubusercontent.com/romkatv/gitstatus/1ac366952366d89980b3f3484f270b4fa5ae4293/bash-prompt.png) - -In order to customize your prompt, set `PS1` at the end of `~/.bashrc` after sourcing -`gitstatus.prompt.sh`. Insert `${GITSTATUS_PROMPT}` where you want git status to go. For example: - -```bash -source ~/gitstatus/gitstatus.prompt.sh - -PS1='\w ${GITSTATUS_PROMPT}\n\$ ' # directory followed by git status and $/# (normal/root) -``` - -The expansion of `${GITSTATUS_PROMPT}` can contain the following bits: - -| segment | meaning | -|-------------|-------------------------------------------------------| -| `master` | current branch | -| `#v1` | HEAD is tagged with `v1`; not shown when on a branch | -| `@5fc6fca4` | current commit; not shown when on a branch or tag | -| `⇣1` | local branch is behind the remote by 1 commit | -| `⇡2` | local branch is ahead of the remote by 2 commits | -| `⇠3` | local branch is behind the push remote by 3 commits | -| `⇢4` | local branch is ahead of the push remote by 4 commits | -| `*5` | there are 5 stashes | -| `merge` | merge is in progress (could be some other action) | -| `~6` | there are 6 merge conflicts | -| `+7` | there are 7 staged changes | -| `!8` | there are 8 unstaged changes | -| `?9` | there are 9 untracked files | - -If you'd like to change the format of git status, or want to have greater control over the -process of assembling `PS1`, you can copy and modify parts of -[gitstatus.prompt.sh](gitstatus.prompt.sh) instead of sourcing the script. Your `~/.bashrc` might -look something like this: - -```bash -source ~/gitstatus/gitstatus.plugin.sh - -function my_set_prompt() { - PS1='\w' - - if gitstatus_query && [[ "$VCS_STATUS_RESULT" == ok-sync ]]; then - if [[ -n "$VCS_STATUS_LOCAL_BRANCH" ]]; then - PS1+=" ${VCS_STATUS_LOCAL_BRANCH//\\/\\\\}" # escape backslash - else - PS1+=" @${VCS_STATUS_COMMIT//\\/\\\\}" # escape backslash - fi - (( VCS_STATUS_HAS_STAGED" )) && PS1+='+' - (( VCS_STATUS_HAS_UNSTAGED" )) && PS1+='!' - (( VCS_STATUS_HAS_UNTRACKED" )) && PS1+='?' - fi - - PS1+='\n\$ ' - - shopt -u promptvars # disable expansion of '$(...)' and the like -} - -gitstatus_stop && gitstatus_start -PROMPT_COMMAND=my_set_prompt -``` - -This snippet is sourcing `gitstatus.plugin.sh` rather than `gitstatus.prompt.sh`. The former -defines low-level bindings that communicate with gitstatusd over pipes. The latter is a simple -script that uses these bindings to assemble git prompt. - -Note: Bash bindings, unlike Zsh bindings, don't support asynchronous calls. - -## Using from other shells - -If there are no gitstatusd bindings for your shell, you'll need to get your hands dirty. -Use the existing bindings for inspiration; run `gitstatusd --help` or read the same thing in -[options.cc](src/options.cc). - -## How it works - -gitstatusd reads requests from stdin and prints responses to stdout. Requests contain an ID and -a directory. Responses contain the same ID and machine-readable git status for the directory. -gitstatusd keeps some state in memory for the directories it has seen in order to serve future -requests faster. - -[Zsh bindings](gitstatus.plugin.zsh) and [Bash bindings](gitstatus.plugin.sh) start gitstatusd in -the background and communicate with it via pipes. Themes such as -[Powerlevel10k](https://github.com/romkatv/powerlevel10k) use these bindings to put git status in -`PROMPT`. - -Note that gitstatus cannot be used as a drop-in replacement for `git status` command as it doesn't -produce output in the same format. It does perform the same computation though. - -## Benchmarks - -The following benchmark results were obtained on Intel i9-7900X running Ubuntu 18.04 in -a clean [chromium](https://github.com/chromium/chromium) repository synced to `9394e49a`. The -repository was checked out to an ext4 filesystem on M.2 SSD. - -Three functionally equivalent tools for computing git status were benchmarked: - -* `gitstatusd` -* `git` with untracked cache enabled -* `lg2` -- a demo/example executable from [libgit2](https://github.com/romkatv/libgit2) that - implements a subset of `git` functionality on top of libgit2 API; for the purposes of this - benchmark the subset is sufficient to generate the same data as the other tools - -Every tool was benchmark in cold and hot conditions. For `git` the first run in a repository was -considered cold, with the following runs considered hot. `lg2` was patched to compute results twice -in a single invocation without freeing the repository in between; the second run was considered hot. -The same patching was not done for `git` because `git` cannot be easily modified to refresh inmemory -index state between invocations; in fact, this limitation is one of the primary reasons developers -use libgit2. `gitstatusd` was benchmarked similarly to `lg2` with two result computations in the -same invocation. - -Two commands were benchmarked: `status` and `describe`. - -### Status - -In this benchmark all tools were computing the equivalent of `git status`. Lower numbers are better. - -| Tool | Cold | Hot | -|---------------|-----------:|------------:| -| **gitstatus** | **291 ms** | **30.9 ms** | -| git | 876 ms | 295 ms | -| lg2 | 1730 ms | 1310 ms | - -gitstatusd is substantially faster than the alternatives, especially on hot runs. Note that hot runs -are of primary importance to the main use case of gitstatus in interactive shells. - -The performance of `git status` fluctuated wildly in this benchmarks for reasons unknown to the -author. Moreover, performance is sticky -- once `git status` settles around a number, it stays -there for a long time. Numbers as diverse as 295, 352, 663 and 730 had been observed on hot runs on -the same repository. The number in the table is the lowest (fastest or best) that `git status` had -shown. - -### Describe - -In this benchmark all tools were computing the equivalent of `git describe --tags --exact-match` -to find tags that resolve to the same commit as `HEAD`. Lower numbers are better. - -| Tool | Cold | Hot | -|---------------|------------:|--------------:| -| **gitstatus** | **4.04 ms** | **0.0345 ms** | -| git | 18.0 ms | 14.5 ms | -| lg2 | 185 ms | 45.2 ms | - -gitstatusd is once again faster than the alternatives, more so on hot runs. - -## Why fast - -Since gitstatusd doesn't have to print all staged/unstaged/untracked files but only report -whether there are any, it can terminate repository scan early. It can also remember which files -were dirty on the previous run and check them first on the next run to avoid the scan entirely if -the files are still dirty. However, the benchmarks above were performed in a clean repository where -these shortcuts do not trigger. All benchmarked tools had to do the same work -- check the status -of every file in the index to see if it has changed, check every directory for newly created files, -etc. And yet, gitstatusd came ahead by a large margin. This section describes what it does that -makes it so fast. - -Most of the following comparisons are done against libgit2 rather than git because of the author's -familiarity with the former but not the with latter. libgit2 has clean, well-documented APIs and an -elegant implementation, which makes it so much easier to work with and to analyze performance -bottlenecks. - -### Summary for the impatient - -Under the benchmark conditions described above, the equivalent of libgit2's -`git_diff_index_to_workdir` (the most expensive part of `status` command) is 46.3 times faster in -gitstatusd. The speedup comes from the following sources. - -* gitstatusd uses more efficient data structures and algorithms and employs performance-conscious -coding style throughout the codebase. This reduces CPU time in userspace by 32x compared to libgit2. -* gitstatusd uses less expensive system calls and makes fewer of them. This reduces CPU time spent -in kernel by 1.9x. -* gitstatusd can utilize multiple cores to scan index and workdir in parallel with almost perfect -scaling. This reduces total run time by 12.4x while having virtually no effect on total CPU time. - -### Problem statement - -The most resource-intensive part of the `status` command is finding the difference between _index_ -and _workdir_ (`git_diff_index_to_workdir` in libgit2). Index is a list of all files in the git -repository with their last modification times. This is an obvious simplification but it suffices for -this exposition. On disk, index is stored sorted by file path. Here's an example of git index: - -| File | Last modification time | -|-------------|-----------------------:| -| Makefile | 2019-04-01T14:12:32Z | -| src/hello.c | 2019-04-01T14:12:00Z | -| src/hello.h | 2019-04-01T14:12:32Z | - -This list needs to be compared to the list of files in the working directory. If any of the files -listed in the index are missing from the workdir or have different last modification time, they are -"unstaged" in gitstatusd parlance. If you run `git status`, they'll be shown as "changes not staged -for commit". Thus, any implementation of `status` command has to call `stat()` or one of its -variants on every file in the index. - -In addition, all files in the working directory for which there is no entry in the index at all are -"untracked". `git status` will show them as "untracked files". Finding untracked files requires some -form of work directory traversal. - -### Single-threaded scan - -Let's see how `git_diff_index_to_workdir` from libgit2 accomplishes these tasks. Here's its CPU -profile from 200 hot runs over chromium repository. - -![libgit2 CPU profile (hot)]( - https://raw.githubusercontent.com/romkatv/gitstatus/1ac366952366d89980b3f3484f270b4fa5ae4293/cpu-profile-libgit2.png) - -(The CPU profile was created with [gperftools](https://github.com/gperftools/gperftools) and -rendered with [pprof](https://github.com/google/pprof)). - -We can see `__GI__lxstat` taking a lot of time. This is the `stat()` call for every file in the -index. We can also identify `__opendir`, `__readdir` and `__GI___close_nocancel` -- glibc wrappers -for reading the contents of a directory. This is for finding untracked files. Out of the total 232 -seconds, 111 seconds -- or 47.7% -- was spent on these calls. The rest is computation -- comparing -strings, sorting arrays, etc. - -Now let's take a look at the CPU profile of gitstatusd on the same task. - -![gitstatusd CPU profile (hot)]( - https://raw.githubusercontent.com/romkatv/gitstatus/1ac366952366d89980b3f3484f270b4fa5ae4293/cpu-profile-gitstatusd-hot.png) - -The first impression is that this profile looks pruned. This isn't an artifact. The profile was -generated with the same tools and the same flags as the profile of libgit2. - -Since both profiles were generated from the same workload, absolute numbers can be compared. We can -see that gitstatusd took 62 seconds in total compared to libgit2's 232 seconds. System calls at the -core of the algorithm are cleary visible. `__GI___fxstatat` is a flavor of `stat()`, and the other -three calls -- `__libc_openat64`, `__libc_close` and `__GI___fxstat` are responsible for opening -directories and finding untracked files. Notice that there is almost nothing else in the profile -apart from these calls. The rest of the code accounts for 3.77 seconds of CPU time -- 32 times less -than in libgit2. - -So, one reason gitstatusd is fast is that it has efficient diffing code -- very little time is spent -outside of kernel. However, if we look closely, we can notice that system calls in gitstatusd are -_also_ faster than in libgit2. For example, libgit2 spent 72.07 seconds in `__GI__lxstat` while -gitstatusd spent only 48.82 seconds in `__GI___fxstatat`. There are two reasons for this difference. -First, libgit2 makes more `stat()` calls than is strictly required. It's not necessary to stat -directories because index only has files. There are 25k directories in chromium repository (and 300k -files) -- that's 25k `stat()` calls that could be avoided. The second reason is that libgit2 and -gitstatusd use different flavors of `stat()`. libgit2 uses `lstat()`, which takes a path to the file -as input. Its performance is linear in the number of subdirectories in the path because it needs to -perform a lookup for every one of them and to check permissions. gitstatusd uses `fstatat()`, which -takes a file descriptor to the parent directory and a name of the file. Just a single lookup, less -CPU time. - -Similarly to `lstat()` vs `fstatat()`, it's faster to open files and directories with `openat()` -from the parent directory file descriptor than with regular `open()` that accepts full file path. -gitstatusd takes advantage of `openat()` to open directories as fast as possible. It opens about 90% -of the directories (this depends on the actual directory structure of the repository) from the -immediate parent -- the most efficient way -- and the remaining 10% it opens from the repository's -root directory. The reason it's done this way is to keep the maximum number of simultaneously open -file descriptors bounded. libgit2 can have O(repository depth) simultaneously open file descriptors, -which may be OK for a single-threaded application but can balloon to a large number when scans are -done by many threads simultaneously, like in gitstatusd. - -There is no equivalent to `__opendir` or `__readdir` in the gitstatusd profile because it uses the -equivalent of [untracked cache](https://git-scm.com/docs/git-update-index#_untracked_cache) from -git. On the first scan of the workdir gitstatusd lists all files just like libgit2. But, unlike -libgit2, it remembers the last modification time of every directory along with the list of -untracked files under it. On the next scan, gitstatusd can skip listing files in directories whose -last modification time hasn't changed. - -To summarize, here's what gitstatusd was doing when the CPU profile was captured: - -1. `__libc_openat64`: Open every directory for which there are files in the index. -2. `__GI___fxstat`: Check last modification time of the directory. Since it's the same as on the - last scan, this directory has the same list of untracked files as before, which is empty (the - repository is clean). -3. `__GI___fxstatat`: Check last modification time for every file in the index that belongs to this - directory. -4. `__libc_close`: Close the file descriptor to the directory. - -Here's how the very first scan of a repository looks like in gitstatusd: - -![gitstatusd CPU profile (cold)]( - https://raw.githubusercontent.com/romkatv/gitstatus/1ac366952366d89980b3f3484f270b4fa5ae4293/cpu-profile-gitstatusd-cold.png) - -(Some glibc functions are mislabel on this profile. `explicit_bzero` and `__nss_passwd_lookup` are -in reality `strcmp` and `memcmp`.) - -This is a superset of the previous -- hot -- profile, with an extra `syscall` and string sorting for -directory listing. gitstatusd uses `getdents64` Linux system call directly, bypassing the glibc -wrapper that libgit2 uses. This is 23% faster. The details of this optimization can be found in a -[separate document](docs/listdir.md). - -### Multithreading - -The diffing algorithm in gitstatusd was designed from the ground up with the intention of using it -concurrently from multiple threads. With a fast SSD, `status` is CPU bound, so taking advantage of -all available CPU cores is an obvious way to yield results faster. - -gitstatusd exhibits almost perfect scaling from multithreading. Engaging all cores allows it to -produce results 12.4 times faster than in single-threaded execution. This is on Intel i9-7900X with -10 cores (20 with hyperthreading) with single-core frequency of 4.3GHz and all-core frequency of -4.0GHz. - -Note: `git status` also uses all available cores in some parts of its algorithm while `lg2` does -everything in a single thread. - -### Postprocessing - -Once the difference between the index and the workdir is found, we have a list of _candidates_ -- -files that may be unstaged or untracked. To make the final judgement, these files need to be checked -against `.gitignore` rules and a few other things. - -gitstatusd uses [patched libgit2](https://github.com/romkatv/libgit2) for this step. This fork -adds several optimizations that make libgit2 faster. The patched libgit2 performs more than twice -as fast in the benchmark as the original even without changes in the user code (that is, in the -code that uses the libgit2 APIs). The fork also adds several API extensions, most notable of which -is the support for multi-threaded scans. If `lg2 status` is modified to take advantage of these -extensions, it outperforms the original libgit2 by a factor of 18. Lastly, the fork fixes a score of -bugs, most of which become apparent only when using libgit2 from multiple threads. - -_WARNING: Changes to libgit2 are extensive but the testing they underwent isn't. It is -**not recommended** to use the patched libgit2 in production._ - -## Requirements - -* To compile: binutils, cmake, gcc, g++, git and GNU make. -* To run: Linux, macOS, FreeBSD, Android, WSL, Cygwin or MSYS2. - -## Compiling - -There are prebuilt `gitstatusd` binaries in [releases]( - https://github.com/romkatv/gitstatus/releases). When using the official shell bindings -provided by gitstatus, the right binary for your architecture gets downloaded automatically. - -If prebuilt binaries don't work for you, you'll need to get your hands dirty. - -### Compiling for personal use - -```zsh -git clone --depth=1 https://github.com/romkatv/gitstatus.git -cd gitstatus -./build -w -s -d docker -``` - -Users in China can use the official mirror on gitee.com for faster download.<br> -中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. - -```zsh -git clone --depth=1 https://gitee.com/romkatv/gitstatus.git -cd gitstatus -./build -w -s -d docker -``` - -- If it says that `-d docker` is not supported on your OS, remove this flag. -- If it says that `-s` is not supported on your OS, remove this flag. -- If it tell you to install docker but you cannot or don't want to, remove `-d docker`. -- If it says that some command is missing, install it. - -If everything goes well, the newly built binary will appear in `./usrbin`. It'll be picked up -by shell bindings automatically. - -When you update shell bindings, they may refuse to work with the binary you've built earlier. In -this case you'll need to rebuild. - -If you are using gitstatus through [Powerlevel10k](https://github.com/romkatv/powerlevel10k), the -instructions are the same except that you don't need to clone gitstatus. Instead, change your -current directory to `/path/to/powerlevel10k/gitstatus` (`/path/to/powerlevel10k` is the directory -where you've installed Powerlevel10k) and run `./build -w -s -d docker` from there as described -above. - -### Compiling for distribution - -It's currently neither easy nor recommended to package and distribute gitstatus. There are no -instructions you can follow that would allow you to easily update your package when new versions of -gitstatus are released. This may change in the future but not soon. - -## License - -GNU General Public License v3.0. See [LICENSE](LICENSE). Contributions are covered by the same -license. diff --git a/.zsh/themes/powerlevel10k/gitstatus/build b/.zsh/themes/powerlevel10k/gitstatus/build deleted file mode 100644 index e116abb..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/build +++ /dev/null @@ -1,656 +0,0 @@ -#!/bin/sh -# -# Type `build -h` for help and see https://github.com/romkatv/gitstatus -# for full documentation. - -set -ue - -if [ -n "${ZSH_VERSION:-}" ]; then - emulate sh -o err_exit -o no_unset -fi - -export LC_ALL=C - -if [ -z "${ZSH_VERSION-}" ] && command -v zsh >/dev/null 2>&1; then - # Avoid bash 3.*. - case "${BASH_VERSION-}" in - [0-3].*) exec zsh "$0" "$@";; - esac -fi - -# Avoid ksh: https://github.com/romkatv/gitstatus/issues/282. -if [ -n "${KSH_VERSION-}" ]; then - if [ -z "${ZSH_VERSION-}" ] && command -v zsh >/dev/null 2>&1; then - exec zsh "$0" "$@" - elif [ -z "${BASH_VERSION-}" ] && command -v bash >/dev/null 2>&1 && - bash_version="$(bash --version 2>&1)"; then - case "$bash_version" in - *version\ [4-9]*|*version\ [1-9][0-9]*) exec bash "$0" "$@";; - esac - fi -fi - -usage="$(command cat <<\END -Usage: build [-m ARCH] [-c CPU] [-d CMD] [-i IMAGE] [-s] [-w] - -Options: - - -m ARCH `uname -m` from the target machine; defaults to `uname -m` - from the local machine - -c CPU generate machine instructions for CPU of this type; this - value gets passed as `-march` (or `-mcpu` for ppc64le) to gcc; - inferred from ARCH if not set explicitly - -d CMD build in a Docker container and use CMD as the `docker` - command; e.g., `-d docker` or `-d podman` - -i IMAGE build in this Docker image; inferred from ARCH if not set - explicitly - -s install whatever software is necessary for build to - succeed; on some operating systems this option is not - supported; on others it can have partial effect - -w automatically download tarballs for dependencies if they - do not already exist in ./deps; dependencies are described - in ./build.info -END -)" - -build="$(command cat <<\END -outdir="$(command pwd)" - -if command -v mktemp >/dev/null 2>&1; then - workdir="$(command mktemp -d "${TMPDIR:-/tmp}"/gitstatus-build.XXXXXXXXXX)" -else - workdir="${TMPDIR:-/tmp}/gitstatus-build.tmp.$$" - command mkdir -- "$workdir" -fi - -cd -- "$workdir" -workdir="$(command pwd)" - -narg() { echo $#; } - -if [ "$(narg $workdir)" != 1 -o -z "${workdir##*:*}" -o -z "${workdir##*=*}" ]; then - >&2 echo "[error] cannot build in this directory: $workdir" - exit 1 -fi - -appname=gitstatusd -libgit2_tmp="$outdir"/deps/"$appname".libgit2.tmp - -cleanup() { - trap - INT QUIT TERM ILL PIPE - cd / - if ! command rm -rf -- "$workdir" "$outdir"/usrbin/"$appname".tmp "$libgit2_tmp"; then - command sleep 5 - command rm -rf -- "$workdir" "$outdir"/usrbin/"$appname".tmp "$libgit2_tmp" - fi -} -trap cleanup INT QUIT TERM ILL PIPE - -if [ -n "$gitstatus_install_tools" ]; then - case "$gitstatus_kernel" in - linux) - if command -v apk >/dev/null 2>&1; then - command apk update - command apk add binutils cmake gcc g++ git make musl-dev perl-utils - elif command -v apt-get >/dev/null 2>&1; then - apt-get update - apt-get install -y binutils cmake gcc g++ make wget - else - >&2 echo "[error] -s is not supported on this system" - exit 1 - fi - ;; - freebsd|dragonfly) - command pkg install -y cmake gmake binutils git perl5 wget - ;; - openbsd) - command pkg_add cmake gmake gcc g++ git wget - ;; - netbsd) - command pkgin -y install cmake gmake binutils git - ;; - darwin) - if ! command -v make >/dev/null 2>&1 || ! command -v gcc >/dev/null 2>&1; then - >&2 echo "[error] please run 'xcode-select --install' and retry" - exit 1 - fi - if command -v port >/dev/null 2>&1; then - sudo port -N install libiconv cmake wget - elif command -v brew >/dev/null 2>&1; then - for formula in libiconv cmake git wget; do - if command brew ls --version "$formula" &>/dev/null; then - command brew upgrade "$formula" - else - command brew install "$formula" - fi - done - else - >&2 echo "[error] please install MacPorts or Homebrew and retry" - exit 1 - fi - ;; - msys*|mingw*) - command pacman -Syu --noconfirm - command pacman -S --needed --noconfirm binutils cmake gcc git make perl - ;; - *) - >&2 echo "[internal error] unhandled kernel: $gitstatus_kernel" - exit 1 - ;; - esac -fi - -cpus="$(command getconf _NPROCESSORS_ONLN 2>/dev/null)" || - cpus="$(command sysctl -n hw.ncpu 2>/dev/null)" || - cpus=8 - -case "$gitstatus_cpu" in - powerpc64|powerpc64le) - archflag="-mcpu" - ;; - *) - archflag="-march" - ;; -esac - -cflags="$archflag=$gitstatus_cpu -fno-plt -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fpie" -ldflags= -static_pie= - -if [ -z "${CC-}" ]; then - case "$gitstatus_kernel" in - freebsd) export CC=clang;; - *) export CC=cc;; - esac -fi - -printf 'int main() {}\n' >"$workdir"/cc-test.c -if 2>/dev/null "$CC" \ - -ffile-prefix-map=x=y \ - -Werror \ - -c "$workdir"/cc-test.c \ - -o "$workdir"/cc-test.o; then - cflags="$cflags -ffile-prefix-map=$workdir/=" -fi - -command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o -if 2>/dev/null "$CC" \ - -fstack-clash-protection \ - -Werror \ - -c "$workdir"/cc-test.c \ - -o "$workdir"/cc-test.o; then - cflags="$cflags -fstack-clash-protection" -fi - -command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o -if 2>/dev/null "$CC" \ - -fcf-protection \ - -Werror \ - -c "$workdir"/cc-test.c \ - -o "$workdir"/cc-test.o; then - cflags="$cflags -fcf-protection" -fi - -command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o -if 2>/dev/null "$CC" \ - -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now \ - -Werror \ - "$workdir"/cc-test.c \ - -o "$workdir"/cc-test; then - ldflags="$ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" -fi - -command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o -if 2>/dev/null "$CC" \ - -fpie -static-pie \ - -Werror \ - "$workdir"/cc-test.c \ - -o "$workdir"/cc-test; then - static_pie='-static-pie' -fi - -if [ "$gitstatus_cpu" = x86-64 ]; then - cflags="$cflags -mtune=generic" -fi - -libgit2_cmake_flags= -libgit2_cflags="${CFLAGS-} $cflags -O3 -DNDEBUG" - -gitstatus_cxx=g++ -gitstatus_cxxflags="${CXXFLAGS-} $cflags -I${workdir}/libgit2/include -DGITSTATUS_ZERO_NSEC -D_GNU_SOURCE -D_GLIBCXX_ASSERTIONS" -gitstatus_ldflags="${LDFLAGS-} $ldflags -L${workdir}/libgit2/build" -gitstatus_ldlibs= -gitstatus_make=make - -case "$gitstatus_kernel" in - linux) - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" - ;; - freebsd) - gitstatus_cxx=clang++ - gitstatus_make=gmake - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" - ;; - dragonfly) - gitstatus_cxx=clang++12 - gitstatus_make=gmake - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" - ;; - openbsd) - gitstatus_cxx=eg++ - gitstatus_make=gmake - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" - ;; - netbsd) - gitstatus_make=gmake - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" - ;; - darwin) - command mkdir -- "$workdir"/lib - if [ -e /opt/local/lib/libiconv.a ]; then - command ln -s -- /opt/local/lib/libiconv.a "$workdir"/lib - libgit2_cflags="$libgit2_cflags -I/opt/local/include" - gitstatus_cxxflags="$gitstatus_cxxflags -I/opt/local/include" - else - brew_prefix="$(command brew --prefix)" - command ln -s -- "$brew_prefix"/opt/libiconv/lib/libiconv.a "$workdir"/lib - libgit2_cflags="$libgit2_cflags -I"$brew_prefix"/opt/libiconv/include" - gitstatus_cxxflags="$gitstatus_cxxflags -I"$brew_prefix"/opt/libiconv/include" - fi - libgit2_cmake_flags="$libgit2_cmake_flags -DUSE_ICONV=ON" - gitstatus_ldlibs="$gitstatus_ldlibs -liconv" - gitstatus_ldflags="$gitstatus_ldflags -L${workdir}/lib" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=OFF" - ;; - msys*|mingw*) - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" - ;; - cygwin*) - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" - ;; - *) - >&2 echo "[internal error] unhandled kernel: $gitstatus_kernel" - exit 1 - ;; -esac - -for cmd in cat cmake git ld ln mkdir rm strip tar "$gitstatus_make"; do - if ! command -v "$cmd" >/dev/null 2>&1; then - if [ -n "$gitstatus_install_tools" ]; then - >&2 echo "[internal error] $cmd not found" - exit 1 - else - >&2 echo "[error] command not found: $cmd" - exit 1 - fi - fi -done - -. "$outdir"/build.info -if [ -z "${libgit2_version:-}" ]; then - >&2 echo "[internal error] libgit2_version not set" - exit 1 -fi -if [ -z "${libgit2_sha256:-}" ]; then - >&2 echo "[internal error] libgit2_sha256 not set" - exit 1 -fi -libgit2_tarball="$outdir"/deps/libgit2-"$libgit2_version".tar.gz -if [ ! -e "$libgit2_tarball" ]; then - if [ -n "$gitstatus_download_deps" ]; then - if ! command -v wget >/dev/null 2>&1; then - if [ -n "$gitstatus_install_tools" ]; then - >&2 echo "[internal error] wget not found" - exit 1 - else - >&2 echo "[error] command not found: wget" - exit 1 - fi - fi - libgit2_url=https://github.com/romkatv/libgit2/archive/"$libgit2_version".tar.gz - if ! >"$libgit2_tmp" command wget --no-config -qO- -- "$libgit2_url" && - ! >"$libgit2_tmp" command wget -qO- -- "$libgit2_url"; then - set -x - >&2 command which wget - >&2 command ls -lAd -- "$(command which wget)" - >&2 command ls -lAd -- "$outdir" - >&2 command ls -lA -- "$outdir" - >&2 command ls -lAd -- "$outdir"/deps - >&2 command ls -lA -- "$outdir"/deps - set +x - exit 1 - fi - command mv -f -- "$libgit2_tmp" "$libgit2_tarball" - else - >&2 echo "[error] file not found: deps/libgit2-"$libgit2_version".tar.gz" - exit 1 - fi -fi - -libgit2_actual_sha256= -if command -v shasum >/dev/null 2>/dev/null; then - libgit2_actual_sha256="$(command shasum -b -a 256 -- "$libgit2_tarball")" - libgit2_actual_sha256="${libgit2_actual_sha256%% *}" -elif command -v sha256sum >/dev/null 2>/dev/null; then - libgit2_actual_sha256="$(command sha256sum -b -- "$libgit2_tarball")" - libgit2_actual_sha256="${libgit2_actual_sha256%% *}" -elif command -v sha256 >/dev/null 2>/dev/null; then - libgit2_actual_sha256="$(command sha256 -- "$libgit2_tarball" </dev/null)" - # Ignore sha256 output if it's from hashalot. It's incompatible. - if [ ${#libgit2_actual_sha256} -lt 64 ]; then - libgit2_actual_sha256= - else - libgit2_actual_sha256="${libgit2_actual_sha256##* }" - fi -fi - -if [ -z "$libgit2_actual_sha256" ]; then - >&2 echo "[error] command not found: shasum or sha256sum" - exit 1 -fi - -if [ "$libgit2_actual_sha256" != "$libgit2_sha256" ]; then - >&2 echo "[error] sha256 mismatch" - >&2 echo "" - >&2 echo " file : deps/libgit2-$libgit2_version.tar.gz" - >&2 echo " expected: $libgit2_sha256" - >&2 echo " actual : $libgit2_actual_sha256" - exit 1 -fi - -cd -- "$workdir" -command tar -xzf "$libgit2_tarball" -command mv -- libgit2-"$libgit2_version" libgit2 -command mkdir libgit2/build -cd libgit2/build - -CFLAGS="$libgit2_cflags" command cmake \ - -DCMAKE_BUILD_TYPE=None \ - -DZERO_NSEC=ON \ - -DTHREADSAFE=ON \ - -DUSE_BUNDLED_ZLIB=ON \ - -DREGEX_BACKEND=builtin \ - -DUSE_HTTP_PARSER=builtin \ - -DUSE_SSH=OFF \ - -DUSE_HTTPS=OFF \ - -DBUILD_CLAR=OFF \ - -DUSE_GSSAPI=OFF \ - -DUSE_NTLMCLIENT=OFF \ - -DBUILD_SHARED_LIBS=OFF \ - $libgit2_cmake_flags \ - .. -command make -j "$cpus" VERBOSE=1 - -APPNAME="$appname".tmp \ - OBJDIR="$workdir"/gitstatus \ - CXX="${CXX:-$gitstatus_cxx}" \ - CXXFLAGS="$gitstatus_cxxflags" \ - LDFLAGS="$gitstatus_ldflags" \ - LDLIBS="$gitstatus_ldlibs" \ - command "$gitstatus_make" -C "$outdir" -j "$cpus" - -app="$outdir"/usrbin/"$appname" - -command strip "$app".tmp - -command mkdir -- "$workdir"/repo -printf '[init]\n defaultBranch = master\n' >"$workdir"/.gitconfig -( - cd -- "$workdir"/repo - GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git init - GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git config user.name "Your Name" - GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git config user.email "you@example.com" - GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git commit \ - --allow-empty --allow-empty-message --no-gpg-sign -m '' -) - -resp="$(printf "hello\037$workdir/repo\036" | "$app".tmp)" -case "$resp" in - hello*1*/repo*master*);; - *) - >&2 echo 'error: invalid gitstatusd response for a git repo' - exit 1 - ;; -esac - -resp="$(printf 'hello\037\036' | "$app".tmp)" -case "$resp" in - hello*0*);; - *) - >&2 echo 'error: invalid gitstatusd response for a non-repo' - exit 1 - ;; -esac - -command mv -f -- "$app".tmp "$app" - -cleanup - -command cat >&2 <<-END - ------------------------------------------------- - SUCCESS: created usrbin/$appname - END -END -)" - -docker_image= -docker_cmd= - -gitstatus_arch= -gitstatus_cpu= -gitstatus_install_tools= -gitstatus_download_deps= - -while getopts ':m:c:i:d:swh' opt "$@"; do - case "$opt" in - h) - printf '%s\n' "$usage" - exit - ;; - m) - if [ -n "$gitstatus_arch" ]; then - >&2 echo "[error] duplicate option: -$opt" - exit 1 - fi - if [ -z "$OPTARG" ]; then - >&2 echo "[error] incorrect value of -$opt: $OPTARG" - exit 1 - fi - gitstatus_arch="$OPTARG" - ;; - c) - if [ -n "$gitstatus_cpu" ]; then - >&2 echo "[error] duplicate option: -$opt" - exit 1 - fi - if [ -z "$OPTARG" ]; then - >&2 echo "[error] incorrect value of -$opt: $OPTARG" - exit 1 - fi - gitstatus_cpu="$OPTARG" - ;; - i) - if [ -n "$docker_image" ]; then - >&2 echo "[error] duplicate option: -$opt" - exit 1 - fi - if [ -z "$OPTARG" ]; then - >&2 echo "[error] incorrect value of -$opt: $OPTARG" - exit 1 - fi - docker_image="$OPTARG" - ;; - d) - if [ -n "$docker_cmd" ]; then - >&2 echo "[error] duplicate option: -$opt" - exit 1 - fi - if [ -z "$OPTARG" ]; then - >&2 echo "[error] incorrect value of -$opt: $OPTARG" - exit 1 - fi - docker_cmd="$OPTARG" - ;; - s) - if [ -n "$gitstatus_install_tools" ]; then - >&2 echo "[error] duplicate option: -$opt" - exit 1 - fi - gitstatus_install_tools=1 - ;; - w) - if [ -n "$gitstatus_download_deps" ]; then - >&2 echo "[error] duplicate option: -$opt" - exit 1 - fi - gitstatus_download_deps=1 - ;; - \?) >&2 echo "[error] invalid option: -$OPTARG" ; exit 1;; - :) >&2 echo "[error] missing required argument: -$OPTARG"; exit 1;; - *) >&2 echo "[internal error] unhandled option: -$opt" ; exit 1;; - esac -done - -if [ "$OPTIND" -le $# ]; then - >&2 echo "[error] unexpected positional argument" - exit 1 -fi - -if [ -n "$docker_image" -a -z "$docker_cmd" ]; then - >&2 echo "[error] cannot use -i without -d" - exit 1 -fi - -if [ -z "$gitstatus_arch" ]; then - gitstatus_arch="$(uname -m)" - gitstatus_arch="$(printf '%s' "$gitstatus_arch" | tr '[A-Z]' '[a-z]')" -fi - -if [ -z "$gitstatus_cpu" ]; then - case "$gitstatus_arch" in - armel) gitstatus_cpu=armv5;; - armv6l|armhf) gitstatus_cpu=armv6;; - armv7l) gitstatus_cpu=armv7;; - arm64|aarch64) gitstatus_cpu=armv8-a;; - ppc64|ppc64le) gitstatus_cpu=powerpc64le;; - riscv64) gitstatus_cpu=rv64imafdc;; - loongarch64) gitstatus_cpu=loongarch64;; - x86_64|amd64) gitstatus_cpu=x86-64;; - x86) gitstatus_cpu=i586;; - s390x) gitstatus_cpu=z900;; - i386|i586|i686) gitstatus_cpu="$gitstatus_arch";; - *) - >&2 echo '[error] unable to infer target CPU architecture' - >&2 echo 'Please specify explicitly with `-c CPU`.' - exit 1 - ;; - esac -fi - -gitstatus_kernel="$(uname -s)" -gitstatus_kernel="$(printf '%s' "$gitstatus_kernel" | tr '[A-Z]' '[a-z]')" - -case "$gitstatus_kernel" in - linux) - if [ -n "$docker_cmd" ]; then - if [ -z "${docker_cmd##*/*}" ]; then - if [ ! -x "$docker_cmd" ]; then - >&2 echo "[error] not an executable file: $docker_cmd" - exit 1 - fi - else - if ! command -v "$docker_cmd" >/dev/null 2>&1; then - >&2 echo "[error] command not found: $docker_cmd" - exit 1 - fi - fi - if [ -z "$docker_image" ]; then - case "$gitstatus_arch" in - x86_64) docker_image=alpine:3.11.6;; - x86|i386|i586|i686) docker_image=i386/alpine:3.11.6;; - armv6l|armhf) docker_image=arm32v6/alpine:3.11.6;; - armv7l) docker_image=arm32v7/alpine:3.11.6;; - aarch64) docker_image=arm64v8/alpine:3.11.6;; - ppc64|ppc64le) docker_image=ppc64le/alpine:3.11.6;; - s390x) docker_image=s390x/alpine:3.11.6;; - *) - >&2 echo '[error] unable to infer docker image' - >&2 echo 'Please specify explicitly with `-i IMAGE`.' - exit 1 - ;; - esac - fi - fi - ;; - freebsd|openbsd|netbsd|darwin|dragonfly) - if [ -n "$docker_cmd" ]; then - >&2 echo "[error] docker (-d) is not supported on $gitstatus_kernel" - exit 1 - fi - ;; - msys_nt-*|mingw32_nt-*|mingw64_nt-*|cygwin_nt-*) - if ! printf '%s' "$gitstatus_kernel" | grep -Eqx '[^-]+-[0-9]+\.[0-9]+(-.*)?'; then - >&2 echo '[error] unsupported kernel, sorry!' - exit 1 - fi - gitstatus_kernel="$(printf '%s' "$gitstatus_kernel" | sed 's/^\([^-]*-[0-9]*\.[0-9]*\).*/\1/')" - if [ -n "$docker_cmd" ]; then - >&2 echo '[error] docker (-d) is not supported on windows' - exit 1 - fi - if [ -n "$gitstatus_install_tools" -a -z "${gitstatus_kernel##cygwin_nt-*}" ]; then - >&2 echo '[error] -s is not supported on cygwin' - exit 1 - fi - ;; - *) - >&2 echo '[error] unsupported kernel, sorry!' - exit 1 - ;; -esac - -dir="$(dirname -- "$0")" -cd -- "$dir" -dir="$(pwd)" - ->&2 echo "Building gitstatusd..." ->&2 echo "" ->&2 echo " kernel := $gitstatus_kernel" ->&2 echo " arch := $gitstatus_arch" ->&2 echo " cpu := $gitstatus_cpu" -[ -z "$docker_cmd" ] || >&2 echo " docker command := $docker_cmd" -[ -z "$docker_image" ] || >&2 echo " docker image := $docker_image" -if [ -n "$gitstatus_install_tools" ]; then - >&2 echo " install tools := yes" -else - >&2 echo " install tools := no" -fi -if [ -n "$gitstatus_download_deps" ]; then - >&2 echo " download deps := yes" -else - >&2 echo " download deps := no" -fi - -if [ -n "$docker_cmd" ]; then - "$docker_cmd" run \ - -e docker_cmd="$docker_cmd" \ - -e docker_image="$docker_image" \ - -e gitstatus_kernel="$gitstatus_kernel" \ - -e gitstatus_arch="$gitstatus_arch" \ - -e gitstatus_cpu="$gitstatus_cpu" \ - -e gitstatus_install_tools="$gitstatus_install_tools" \ - -e gitstatus_download_deps="$gitstatus_download_deps" \ - -v "$dir":/out \ - -w /out \ - --rm \ - -- "$docker_image" /bin/sh -uexc "$build" -else - eval "$build" -fi diff --git a/.zsh/themes/powerlevel10k/gitstatus/build.info b/.zsh/themes/powerlevel10k/gitstatus/build.info deleted file mode 100644 index baa30b0..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/build.info +++ /dev/null @@ -1,22 +0,0 @@ -# This value gets embedded in gitstatusd at build time. It is -# read by ./Makefile. `gitstatusd --version` reports it back. -# -# This value is also read by shell bindings (indirectly, through -# ./install) when using GITSTATUS_DAEMON or usrbin/gitstatusd. -gitstatus_version="v1.5.4" - -# libgit2 is a build time dependency of gitstatusd. The values of -# libgit2_version and libgit2_sha256 are read by ./build. -# -# If ./deps/libgit2-${libgit2_version}.tar.gz doesn't exist, build -# downloads it from the following location: -# -# https://github.com/romkatv/libgit2/archive/${libgit2_version}.tar.gz -# -# Once downloaded, the tarball is stored at the path indicated -# above so that repeated builds don't consume network bandwidth. -# -# If sha256 of ./deps/libgit2-${libgit2_version}.tar.gz doesn't match, -# build gets aborted. -libgit2_version="tag-0ad3d776aa86dd607dc86dcd7f77ad3ed7ebec61" -libgit2_sha256="c5d0117ae74d3ef244c26f10cce022019077dbc4563e6251fa9f56d36868ce74" diff --git a/.zsh/themes/powerlevel10k/gitstatus/deps/.gitkeep b/.zsh/themes/powerlevel10k/gitstatus/deps/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/.zsh/themes/powerlevel10k/gitstatus/docs/listdir.md b/.zsh/themes/powerlevel10k/gitstatus/docs/listdir.md deleted file mode 100644 index 0939cc1..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/docs/listdir.md +++ /dev/null @@ -1,330 +0,0 @@ -# Fast directory listing - -In order to find untracked files in a git repository, [gitstatusd](../README.md) needs to list the -contents of every directory. gitstatusd does it 27% faster than a reasonable implementation that a -seasoned C/C++ practitioner might write. This document explains the optimizations that went into it. -As directory listing is a common operation, many other projects can benefit from applying these -optimizations. - -## v1 - -Given a path to a directory, `ListDir()` must produce the list of files in that directory. Moreover, -the list must be sorted lexicographically to enable fast comparison with Git index. - -The following C++ implementation gets the job done. For simplicity, it returns an empty list on -error. - -```c++ -vector<string> ListDir(const char* dirname) { - vector<string> entries; - if (DIR* dir = opendir(dirname)) { - while (struct dirent* ent = (errno = 0, readdir(dir))) { - if (!Dots(ent->d_name)) entries.push_back(ent->d_name); - } - if (errno) entries.clear(); - sort(entries.begin(), entries.end()); - closedir(dir); - } - return entries; -} -``` - -Every directory has entries `"."` and `".."`, which we aren't interested in. We filter them out with -a helper function `Dots()`. - -```c++ -bool Dots(const char* s) { return s[0] == '.' && (!s[1] || (s[1] == '.' && !s[2])); } -``` - -To check how fast `ListDir()` performs, we can run it many times on a typical directory. One million -runs on a directory with 32 files with 16-character names takes 12.7 seconds. - -## v2 - -Experienced C++ practitioners will scoff at our implementation of `ListDir()`. If it's meant to be -efficient, returning `vector<string>` is an unaffordable convenience. To avoid heap allocations we -can use a simple arena that will allow us to reuse memory between different `ListDir()` calls. - -(Changed and added lines are marked with comments.) - -```c++ -void ListDir(const char* dirname, string& arena, vector<char*>& entries) { // + - entries.clear(); // + - if (DIR* dir = opendir(dirname)) { - arena.clear(); // + - while (struct dirent* ent = (errno = 0, readdir(dir))) { - if (!Dots(ent->d_name)) { - entries.push_back(reinterpret_cast<char*>(arena.size())); // + - arena.append(ent->d_name, strlen(ent->d_name) + 1); // + - } - } - if (errno) entries.clear(); - for (char*& p : entries) p = &arena[reinterpret_cast<size_t>(p)]; // + - sort(entries.begin(), entries.end(), // + - [](const char* a, const char* b) { return strcmp(a, b) < 0; }); // + - closedir(dir); - } -} -``` - -To make performance comparison easier, we can normalize them relative to the baseline. v1 will get -performance score of 100. A twice-as-fast alternative will be 200. - -| version | optimization | score | -|---------|----------------------------|----------:| -| v1 | baseline | 100.0 | -| **v2** | **avoid heap allocations** | **112.7** | - -Avoiding heap allocations makes `ListDir()` 12.7% faster. Not bad. As an added bonus, those casts -will fend off the occasional frontend developer who accidentally wanders into the codebase. - -## v3 - -`opendir()` is an expensive call whose performance is linear in the number of subdirectories in the -path because it needs to perform a lookup for every one of them. We can replace it with `openat()`, -which takes a file descriptor to the parent directory and a name of the subdirectory. Just a single -lookup, less CPU time. This optimization assumes that callers already have a descriptor to the -parent directory, which is indeed the case for gitstatusd, and is often the case in other -applications that traverse filesystem. - -```c++ -void ListDir(int parent_fd, const char* dirname, string& arena, vector<char*>& entries) { // + - entries.clear(); - int dir_fd = openat(parent_fd, dirname, O_NOATIME | O_RDONLY | O_DIRECTORY | O_CLOEXEC); // + - if (dir_fd < 0) return; // + - if (DIR* dir = fdopendir(dir_fd)) { - arena.clear(); - while (struct dirent* ent = (errno = 0, readdir(dir))) { - if (!Dots(ent->d_name)) { - entries.push_back(reinterpret_cast<char*>(arena.size())); - arena.append(ent->d_name, strlen(ent->d_name) + 1); - } - } - if (errno) entries.clear(); - for (char*& p : entries) p = &arena[reinterpret_cast<size_t>(p)]; - sort(entries.begin(), entries.end(), - [](const char* a, const char* b) { return strcmp(a, b) < 0; }); - closedir(dir); - } else { // + - close(dir_fd); // + - } // + -} -``` - -This is worth about 3.5% in speed. - -| version | optimization | score | -|---------|--------------------------------------|----------:| -| v1 | baseline | 100.0 | -| v2 | avoid heap allocations | 112.7 | -| **v3** | **open directories with `openat()`** | **116.2** | - -## v4 - -Copying file names to the arena isn't free but it doesn't seem like we can avoid it. Poking around -we can see that the POSIX API we are using is implemented on Linux on top of `getdents64` system -call. Its documentation isn't very encouraging: - -```text -These are not the interfaces you are interested in. Look at -readdir(3) for the POSIX-conforming C library interface. This page -documents the bare kernel system call interfaces. - -Note: There are no glibc wrappers for these system calls. -``` - -Hmm... The API looks like something we can take advantage of, so let's try it anyway. - -First, we'll need a simple `Arena` class that can allocate 8KB blocks of memory. - -```c++ -class Arena { - public: - enum { kBlockSize = 8 << 10 }; - - char* Alloc() { - if (cur_ == blocks_.size()) blocks_.emplace_back(kBlockSize, 0); - return blocks_[cur_++].data(); - } - - void Clear() { cur_ = 0; } - - private: - size_t cur_ = 0; - vector<string> blocks_; -}; -``` - -Next, we need to define `struct dirent64_t` ourselves because there is no wrapper for the system -call we are about to use. - -```c++ -struct dirent64_t { - ino64_t d_ino; - off64_t d_off; - unsigned short d_reclen; - unsigned char d_type; - char d_name[]; -}; -``` - -Finally we can get to the implementation of `ListDir()`. - -```c++ -void ListDir(int parent_fd, Arena& arena, vector<char*>& entries) { // + - entries.clear(); - int dir_fd = openat(parent_fd, dirname, O_NOATIME | O_RDONLY | O_DIRECTORY | O_CLOEXEC); - if (dir_fd < 0) return; - arena.Clear(); // + - while (true) { // + - char* buf = arena.Alloc(); // + - int n = syscall(SYS_getdents64, dir_fd, buf, Arena::kBlockSize); // + - if (n <= 0) { // + - if (n) entries.clear(); // + - break; // + - } // + - for (int pos = 0; pos < n;) { // + - auto* ent = reinterpret_cast<dirent64_t*>(buf + pos); // + - if (!Dots(ent->d_name)) entries.push_back(ent->d_name); // + - pos += ent->d_reclen; // + - } // + - } // + - sort(entries.begin(), entries.end(), - [](const char* a, const char* b) { return strcmp(a, b) < 0; }); - close(dir_fd); -} -``` - -How are we doing with this one? - -| version | optimization | score | -|---------|----------------------------------|----------:| -| v1 | baseline | 100.0 | -| v2 | avoid heap allocations | 112.7 | -| v3 | open directories with `openat()` | 116.2 | -| **v4** | **call `getdents64()` directly** | **137.8** | - -Solid 20% speedup. Worth the trouble. Unfortunately, we now have just one `reinterpret_cast` instead -of two, and it's not nearly as scary-looking. Hopefully with the next iteration we can get back some -of that evil vibe of low-level code. - -As a bonus, every element in `entries` has `d_type` at offset -1. This can be useful to the callers -that need to distinguish between regular files and directories (gitstatusd, in fact, needs this). -Note how `ListDir()` implements this feature at zero cost, as a lucky accident of `dirent64_t` -memory layout. - -## v5 - -The CPU profile of `ListDir()` reveals that almost all userspace CPU time is spent in `strcmp()`. -Digging into the source code of `std::sort()` we can see that it uses Insertion Sort for short -collections. Our 32-element vector falls under the threshold. Insertion Sort makes `O(N^2)` -comparisons, hence a lot of CPU time in `strcmp()`. Switching to `qsort()` or -[Timsort](https://en.wikipedia.org/wiki/Timsort) is of no use as all good sorting algorithms fall -back to Insertion Sort. - -If we cannot make fewer comparisons, perhaps we can make each of them faster? `strcmp()` compares -characters one at a time. It cannot read ahead as it can be illegal to touch memory past the first -null byte. But _we_ know that it's safe to read a few extra bytes past the end of `d_name` for every -entry except the last in the buffer. And since we own the buffer, we can overallocate it so that -reading past the end of the last entry is also safe. - -Combining these ideas with the fact that file names on Linux are at most 255 bytes long, we can -invoke `getdents64()` like this: - -```c++ -int n = syscall(SYS_getdents64, dir_fd, buf, Arena::kBlockSize - 256); -``` - -And then compare entries like this: - -```c++ -[](const char* a, const char* b) { return memcmp(a, b, 255) < 0; } -``` - -This version doesn't give any speedup compared to the previous but it opens an avenue for another -optimization. The pointers we pass to `memcmp()` aren't aligned. To be more specific, their -numerical values are `N * 8 + 3` for some `N`. When given such a pointer, `memcmp()` will check the -first 5 bytes one by one, and only then switch to comparing 8 bytes at a time. If we can handle the -first 5 bytes ourselves, we can pass aligned memory to `memcmp()` and take full advantage of its -vectorized loop. - -Here's the implementation: - -```c++ -uint64_t Read64(const void* p) { // + - uint64_t x; // + - memcpy(&x, p, sizeof(x)); // + - return x; // + -} // + - -void ByteSwap64(void* p) { // + - uint64_t x = __builtin_bswap64(Read64(p)); // + - memcpy(p, &x, sizeof(x)); // + -} // + - -void ListDir(int parent_fd, Arena& arena, vector<char*>& entries) { - entries.clear(); - int dir_fd = openat(parent_fd, dirname, O_NOATIME | O_RDONLY | O_DIRECTORY | O_CLOEXEC); - if (dir_fd < 0) return; - arena.Clear(); - while (true) { - char* buf = arena.Alloc(); - int n = syscall(SYS_getdents64, dir_fd, buf, Arena::kBlockSize - 256); // + - if (n <= 0) { - if (n) entries.clear(); - break; - } - for (int pos = 0; pos < n;) { - auto* ent = reinterpret_cast<dirent64_t*>(buf + pos); - if (!Dots(ent->d_name)) { - ByteSwap64(ent->d_name); // + - entries.push_back(ent->d_name); - } - pos += ent->d_reclen; - } - } - sort(entries.begin(), entries.end(), [](const char* a, const char* b) { - uint64_t x = Read64(a); // + - uint64_t y = Read64(b); // + - return x < y || (x == y && a != b && memcmp(a + 5, b + 5, 256) < 0); // + - }); - for (char* p : entries) ByteSwap64(p); // + - close(dir_fd); -} -``` - -This is for Little Endian architecture. Big Endian doesn't need `ByteSwap64()`, so it'll be a bit -faster. - -| version | optimization | score | -|---------|----------------------------------|----------:| -| v1 | baseline | 100.0 | -| v2 | avoid heap allocations | 112.7 | -| v3 | open directories with `openat()` | 116.2 | -| v4 | call `getdents64()` directly | 137.8 | -| **v5** | **hand-optimize `strcmp()`** | **143.3** | - -Fast and respectably arcane. - -## Conclusion - -Through a series of incremental improvements we've sped up directory listing by 43.3% compared to a -naive implementation (v1) and 27.2% compared to a reasonable implementation that a seasoned C/C++ -practitioner might write (v2). - -However, these numbers are based on an artificial benchmark while the real judge is always the real -code. Our goal was to speed up gitstatusd. Benchmark was just a tool. Thankfully, the different -versions of `ListDir()` have the same comparative performance within gitstatusd as in the benchmark. -In truth, the directory chosen for the benchmark wasn't arbitrary. It was picked by sampling -gitstatusd when it runs on [chromium](https://github.com/chromium/chromium) git repository. - -The final version of `ListDir()` spends 97% of its CPU time in the kernel. If we assume that it -makes the minimum possible number of system calls and these calls are optimal (true to the best -of my knowledge), it puts the upper bound on possible future performance improvements at just 3%. -There is almost nothing left in `ListDir()` to optimize. - -![ListDir() CPU profile]( - https://raw.githubusercontent.com/romkatv/gitstatus/1ac366952366d89980b3f3484f270b4fa5ae4293/cpu-profile-listdir.png) - -(The CPU profile was created with [gperftools](https://github.com/gperftools/gperftools) and -rendered with [pprof](https://github.com/google/pprof)). diff --git a/.zsh/themes/powerlevel10k/gitstatus/gitstatus.plugin.sh b/.zsh/themes/powerlevel10k/gitstatus/gitstatus.plugin.sh deleted file mode 100644 index 37b78f4..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/gitstatus.plugin.sh +++ /dev/null @@ -1,474 +0,0 @@ -# Bash bindings for gitstatus. - -[[ $- == *i* ]] || return # non-interactive shell - -# Starts gitstatusd in the background. Does nothing and succeeds if gitstatusd -# is already running. -# -# Usage: gitstatus_start [OPTION]... -# -# -t FLOAT Fail the self-check on initialization if not getting a response from -# gitstatusd for this this many seconds. Defaults to 5. -# -# -s INT Report at most this many staged changes; negative value means infinity. -# Defaults to 1. -# -# -u INT Report at most this many unstaged changes; negative value means infinity. -# Defaults to 1. -# -# -c INT Report at most this many conflicted changes; negative value means infinity. -# Defaults to 1. -# -# -d INT Report at most this many untracked files; negative value means infinity. -# Defaults to 1. -# -# -m INT Report -1 unstaged, untracked and conflicted if there are more than this many -# files in the index. Negative value means infinity. Defaults to -1. -# -# -e Count files within untracked directories like `git status --untracked-files`. -# -# -U Unless this option is specified, report zero untracked files for repositories -# with status.showUntrackedFiles = false. -# -# -W Unless this option is specified, report zero untracked files for repositories -# with bash.showUntrackedFiles = false. -# -# -D Unless this option is specified, report zero staged, unstaged and conflicted -# changes for repositories with bash.showDirtyState = false. -# -# -r INT Close git repositories that haven't been used for this many seconds. This is -# meant to release resources such as memory and file descriptors. The next request -# for a repo that's been closed is much slower than for a repo that hasn't been. -# Negative value means infinity. The default is 3600 (one hour). -function gitstatus_start() { - if [[ "$BASH_VERSION" < 4 ]]; then - >&2 printf 'gitstatus_start: need bash version >= 4.0, found %s\n' "$BASH_VERSION" - >&2 printf '\n' - >&2 printf 'To see the version of the current shell, type:\n' - >&2 printf '\n' - >&2 printf ' \033[32mecho\033[0m \033[33m"$BASH_VERSION"\033[0m\n' - >&2 printf '\n' - >&2 printf 'The output of `\033[32mbash\033[0m --version` may be different and is not relevant.\n' - return 1 - fi - - unset OPTIND - local opt timeout=5 max_dirty=-1 ttl=3600 extra_flags= - local max_num_staged=1 max_num_unstaged=1 max_num_conflicted=1 max_num_untracked=1 - while getopts "t:s:u:c:d:m:r:eUWD" opt; do - case "$opt" in - t) timeout=$OPTARG;; - s) max_num_staged=$OPTARG;; - u) max_num_unstaged=$OPTARG;; - c) max_num_conflicted=$OPTARG;; - d) max_num_untracked=$OPTARG;; - m) max_dirty=$OPTARG;; - r) ttl=$OPTARG;; - e) extra_flags+='--recurse-untracked-dirs ';; - U) extra_flags+='--ignore-status-show-untracked-files ';; - W) extra_flags+='--ignore-bash-show-untracked-files ';; - D) extra_flags+='--ignore-bash-show-dirty-state ';; - *) return 1;; - esac - done - - (( OPTIND == $# + 1 )) || { echo "usage: gitstatus_start [OPTION]..." >&2; return 1; } - - [[ -z "${GITSTATUS_DAEMON_PID:-}" ]] || return 0 # already started - - if [[ "${BASH_SOURCE[0]}" == */* ]]; then - local gitstatus_plugin_dir="${BASH_SOURCE[0]%/*}" - if [[ "$gitstatus_plugin_dir" != /* ]]; then - gitstatus_plugin_dir="$PWD"/"$gitstatus_plugin_dir" - fi - else - local gitstatus_plugin_dir="$PWD" - fi - - local tmpdir req_fifo resp_fifo culprit - - function gitstatus_start_impl() { - local log_level="${GITSTATUS_LOG_LEVEL:-}" - [[ -n "$log_level" || "${GITSTATUS_ENABLE_LOGGING:-0}" != 1 ]] || log_level=INFO - - local uname_sm - uname_sm="$(command uname -sm)" || return - uname_sm="${uname_sm,,}" - local uname_s="${uname_sm% *}" - local uname_m="${uname_sm#* }" - - if [[ "${GITSTATUS_NUM_THREADS:-0}" -gt 0 ]]; then - local threads="$GITSTATUS_NUM_THREADS" - else - local cpus - if ! command -v sysctl &>/dev/null || [[ "$uname_s" == linux ]] || - ! cpus="$(command sysctl -n hw.ncpu)"; then - if ! command -v getconf &>/dev/null || ! cpus="$(command getconf _NPROCESSORS_ONLN)"; then - cpus=8 - fi - fi - local threads=$((cpus > 16 ? 32 : cpus > 0 ? 2 * cpus : 16)) - fi - - local daemon_args=( - --parent-pid="$$" - --num-threads="$threads" - --max-num-staged="$max_num_staged" - --max-num-unstaged="$max_num_unstaged" - --max-num-conflicted="$max_num_conflicted" - --max-num-untracked="$max_num_untracked" - --dirty-max-index-size="$max_dirty" - --repo-ttl-seconds="$ttl" - $extra_flags) - - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - tmpdir="$(command mktemp -d "$tmpdir"/gitstatus.bash.$$.XXXXXXXXXX)" || return - - if [[ -n "$log_level" ]]; then - GITSTATUS_DAEMON_LOG="$tmpdir"/daemon.log - [[ "$log_level" == INFO ]] || daemon_args+=(--log-level="$log_level") - else - GITSTATUS_DAEMON_LOG=/dev/null - fi - - req_fifo="$tmpdir"/req.fifo - resp_fifo="$tmpdir"/resp.fifo - command mkfifo -- "$req_fifo" "$resp_fifo" || return - - { - ( - trap '' INT QUIT TSTP - [[ "$GITSTATUS_DAEMON_LOG" == /dev/null ]] || set -x - builtin cd / - - ( - local fd_in fd_out - exec {fd_in}<"$req_fifo" {fd_out}>>"$resp_fifo" || exit - echo "$BASHPID" >&"$fd_out" - - local _gitstatus_bash_daemon _gitstatus_bash_version _gitstatus_bash_downloaded - - function _gitstatus_set_daemon() { - _gitstatus_bash_daemon="$1" - _gitstatus_bash_version="$2" - _gitstatus_bash_downloaded="$3" - } - - set -- -d "$gitstatus_plugin_dir" -s "$uname_s" -m "$uname_m" \ - -p "printf '.\036' >&$fd_out" -e "$fd_out" -- _gitstatus_set_daemon - [[ "${GITSTATUS_AUTO_INSTALL:-1}" -ne 0 ]] || set -- -n "$@" - source "$gitstatus_plugin_dir"/install || return - [[ -n "$_gitstatus_bash_daemon" ]] || return - [[ -n "$_gitstatus_bash_version" ]] || return - [[ "$_gitstatus_bash_downloaded" == [01] ]] || return - - local sig=(TERM ILL PIPE) - - if (( UID == EUID )); then - local home=~ - else - local user - user="$(command id -un)" || return - [[ "$user" =~ ^[a-zA-Z0-9_,.-]+$ ]] || return - eval "local home=~$user" - [[ -n "$home" ]] || return - fi - - if [[ -x "$_gitstatus_bash_daemon" ]]; then - HOME="$home" "$_gitstatus_bash_daemon" \ - -G "$_gitstatus_bash_version" "${daemon_args[@]}" <&"$fd_in" >&"$fd_out" & - local pid=$! - trap "trap - ${sig[*]}; kill $pid &>/dev/null" ${sig[@]} - wait "$pid" - local ret=$? - trap - ${sig[@]} - case "$ret" in - 0|129|130|131|137|141|143|159) - echo -nE $'}bye\x1f0\x1e' >&"$fd_out" - exit "$ret" - ;; - esac - fi - - (( ! _gitstatus_bash_downloaded )) || return - [[ "${GITSTATUS_AUTO_INSTALL:-1}" -ne 0 ]] || return - [[ "$_gitstatus_bash_daemon" == \ - "${GITSTATUS_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/gitstatus}"/* ]] || return - - set -- -f "$@" - _gitstatus_bash_daemon= - _gitstatus_bash_version= - _gitstatus_bash_downloaded= - source "$gitstatus_plugin_dir"/install || return - [[ -n "$_gitstatus_bash_daemon" ]] || return - [[ -n "$_gitstatus_bash_version" ]] || return - [[ "$_gitstatus_bash_downloaded" == 1 ]] || return - - HOME="$home" "$_gitstatus_bash_daemon" \ - -G "$_gitstatus_bash_version" "${daemon_args[@]}" <&"$fd_in" >&"$fd_out" & - local pid=$! - trap "trap - ${sig[*]}; kill $pid &>/dev/null" ${sig[@]} - wait "$pid" - trap - ${sig[@]} - echo -nE $'}bye\x1f0\x1e' >&"$fd_out" - ) & disown - ) & disown - } 0</dev/null &>"$GITSTATUS_DAEMON_LOG" - - exec {_GITSTATUS_REQ_FD}>>"$req_fifo" {_GITSTATUS_RESP_FD}<"$resp_fifo" || return - command rm -f -- "$req_fifo" "$resp_fifo" || return - [[ "$GITSTATUS_DAEMON_LOG" != /dev/null ]] || command rmdir -- "$tmpdir" 2>/dev/null - - IFS='' read -r -u $_GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID || return - [[ "$GITSTATUS_DAEMON_PID" == [1-9]* ]] || return - - local reply - echo -nE $'}hello\x1f\x1e' >&$_GITSTATUS_REQ_FD || return - local dl= - while true; do - reply= - if ! IFS='' read -rd $'\x1e' -u $_GITSTATUS_RESP_FD -t "$timeout" reply; then - culprit="$reply" - return 1 - fi - [[ "$reply" == $'}hello\x1f0' ]] && break - if [[ -z "$dl" ]]; then - dl=1 - if [[ -t 2 ]]; then - local spinner=('\b\033[33m-\033[0m' '\b\033[33m\\\033[0m' '\b\033[33m|\033[0m' '\b\033[33m/\033[0m') - >&2 printf '[\033[33mgitstatus\033[0m] fetching \033[32mgitstatusd\033[0m .. ' - else - local spinner=('.') - >&2 printf '[gitstatus] fetching gitstatusd ..' - fi - fi - >&2 printf "${spinner[0]}" - spinner=("${spinner[@]:1}" "${spinner[0]}") - done - - if [[ -n "$dl" ]]; then - if [[ -t 2 ]]; then - >&2 printf '\b[\033[32mok\033[0m]\n' - else - >&2 echo ' [ok]' - fi - fi - - _GITSTATUS_DIRTY_MAX_INDEX_SIZE=$max_dirty - _GITSTATUS_CLIENT_PID="$BASHPID" - } - - if ! gitstatus_start_impl; then - >&2 printf '\n' - >&2 printf '[\033[31mERROR\033[0m]: gitstatus failed to initialize.\n' - if [[ -n "${culprit-}" ]]; then - >&2 printf '\n%s\n' "$culprit" - fi - [[ -z "${req_fifo:-}" ]] || command rm -f "$req_fifo" - [[ -z "${resp_fifo:-}" ]] || command rm -f "$resp_fifo" - unset -f gitstatus_start_impl - gitstatus_stop - return 1 - fi - - export _GITSTATUS_CLIENT_PID _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID - unset -f gitstatus_start_impl -} - -# Stops gitstatusd if it's running. -function gitstatus_stop() { - if [[ "${_GITSTATUS_CLIENT_PID:-$BASHPID}" == "$BASHPID" ]]; then - [[ -z "${_GITSTATUS_REQ_FD:-}" ]] || exec {_GITSTATUS_REQ_FD}>&- || true - [[ -z "${_GITSTATUS_RESP_FD:-}" ]] || exec {_GITSTATUS_RESP_FD}>&- || true - [[ -z "${GITSTATUS_DAEMON_PID:-}" ]] || kill "$GITSTATUS_DAEMON_PID" &>/dev/null || true - fi - unset _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID - unset _GITSTATUS_DIRTY_MAX_INDEX_SIZE _GITSTATUS_CLIENT_PID -} - -# Retrives status of a git repository from a directory under its working tree. -# -# Usage: gitstatus_query [OPTION]... -# -# -d STR Directory to query. Defaults to $PWD. Has no effect if GIT_DIR is set. -# -t FLOAT Timeout in seconds. Will block for at most this long. If no results -# are available by then, will return error. -# -p Don't compute anything that requires reading Git index. If this option is used, -# the following parameters will be 0: VCS_STATUS_INDEX_SIZE, -# VCS_STATUS_{NUM,HAS}_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED}. -# -# On success sets VCS_STATUS_RESULT to one of the following values: -# -# norepo-sync The directory doesn't belong to a git repository. -# ok-sync The directory belongs to a git repository. -# -# If VCS_STATUS_RESULT is ok-sync, additional variables are set: -# -# VCS_STATUS_WORKDIR Git repo working directory. Not empty. -# VCS_STATUS_COMMIT Commit hash that HEAD is pointing to. Either 40 hex digits or -# empty if there is no HEAD (empty repo). -# VCS_STATUS_COMMIT_ENCODING Encoding of the HEAD's commit message. Empty value means UTF-8. -# VCS_STATUS_COMMIT_SUMMARY The first paragraph of the HEAD's commit message as one line. -# VCS_STATUS_LOCAL_BRANCH Local branch name or empty if not on a branch. -# VCS_STATUS_REMOTE_NAME The remote name, e.g. "upstream" or "origin". -# VCS_STATUS_REMOTE_BRANCH Upstream branch name. Can be empty. -# VCS_STATUS_REMOTE_URL Remote URL. Can be empty. -# VCS_STATUS_ACTION Repository state, A.K.A. action. Can be empty. -# VCS_STATUS_INDEX_SIZE The number of files in the index. -# VCS_STATUS_NUM_STAGED The number of staged changes. -# VCS_STATUS_NUM_CONFLICTED The number of conflicted changes. -# VCS_STATUS_NUM_UNSTAGED The number of unstaged changes. -# VCS_STATUS_NUM_UNTRACKED The number of untracked files. -# VCS_STATUS_HAS_STAGED 1 if there are staged changes, 0 otherwise. -# VCS_STATUS_HAS_CONFLICTED 1 if there are conflicted changes, 0 otherwise. -# VCS_STATUS_HAS_UNSTAGED 1 if there are unstaged changes, 0 if there aren't, -1 if -# unknown. -# VCS_STATUS_NUM_STAGED_NEW The number of staged new files. Note that renamed files -# are reported as deleted plus new. -# VCS_STATUS_NUM_STAGED_DELETED The number of staged deleted files. Note that renamed files -# are reported as deleted plus new. -# VCS_STATUS_NUM_UNSTAGED_DELETED The number of unstaged deleted files. Note that renamed files -# are reported as deleted plus new. -# VCS_STATUS_HAS_UNTRACKED 1 if there are untracked files, 0 if there aren't, -1 if -# unknown. -# VCS_STATUS_COMMITS_AHEAD Number of commits the current branch is ahead of upstream. -# Non-negative integer. -# VCS_STATUS_COMMITS_BEHIND Number of commits the current branch is behind upstream. -# Non-negative integer. -# VCS_STATUS_STASHES Number of stashes. Non-negative integer. -# VCS_STATUS_TAG The last tag (in lexicographical order) that points to the same -# commit as HEAD. -# VCS_STATUS_PUSH_REMOTE_NAME The push remote name, e.g. "upstream" or "origin". -# VCS_STATUS_PUSH_REMOTE_URL Push remote URL. Can be empty. -# VCS_STATUS_PUSH_COMMITS_AHEAD Number of commits the current branch is ahead of push remote. -# Non-negative integer. -# VCS_STATUS_PUSH_COMMITS_BEHIND Number of commits the current branch is behind push remote. -# Non-negative integer. -# VCS_STATUS_NUM_SKIP_WORKTREE The number of files in the index with skip-worktree bit set. -# Non-negative integer. -# VCS_STATUS_NUM_ASSUME_UNCHANGED The number of files in the index with assume-unchanged bit set. -# Non-negative integer. -# -# The point of reporting -1 via VCS_STATUS_HAS_* is to allow the command to skip scanning files in -# large repos. See -m flag of gitstatus_start. -# -# gitstatus_query returns an error if gitstatus_start hasn't been called in the same -# shell or the call had failed. -function gitstatus_query() { - unset OPTIND - local opt dir= timeout=() no_diff=0 - while getopts "d:c:t:p" opt "$@"; do - case "$opt" in - d) dir=$OPTARG;; - t) timeout=(-t "$OPTARG");; - p) no_diff=1;; - *) return 1;; - esac - done - (( OPTIND == $# + 1 )) || { echo "usage: gitstatus_query [OPTION]..." >&2; return 1; } - - [[ -n "${GITSTATUS_DAEMON_PID-}" ]] || return # not started - - local req_id="$RANDOM.$RANDOM.$RANDOM.$RANDOM" - if [[ -z "${GIT_DIR:-}" ]]; then - [[ "$dir" == /* ]] || dir="$(pwd -P)/$dir" || return - elif [[ "$GIT_DIR" == /* ]]; then - dir=:"$GIT_DIR" - else - dir=:"$(pwd -P)/$GIT_DIR" || return - fi - echo -nE "$req_id"$'\x1f'"$dir"$'\x1f'"$no_diff"$'\x1e' >&$_GITSTATUS_REQ_FD || return - - local -a resp - while true; do - IFS=$'\x1f' read -rd $'\x1e' -a resp -u $_GITSTATUS_RESP_FD "${timeout[@]}" || return - [[ "${resp[0]}" == "$req_id" ]] && break - done - - if [[ "${resp[1]}" == 1 ]]; then - VCS_STATUS_RESULT=ok-sync - VCS_STATUS_WORKDIR="${resp[2]}" - VCS_STATUS_COMMIT="${resp[3]}" - VCS_STATUS_LOCAL_BRANCH="${resp[4]}" - VCS_STATUS_REMOTE_BRANCH="${resp[5]}" - VCS_STATUS_REMOTE_NAME="${resp[6]}" - VCS_STATUS_REMOTE_URL="${resp[7]}" - VCS_STATUS_ACTION="${resp[8]}" - VCS_STATUS_INDEX_SIZE="${resp[9]}" - VCS_STATUS_NUM_STAGED="${resp[10]}" - VCS_STATUS_NUM_UNSTAGED="${resp[11]}" - VCS_STATUS_NUM_CONFLICTED="${resp[12]}" - VCS_STATUS_NUM_UNTRACKED="${resp[13]}" - VCS_STATUS_COMMITS_AHEAD="${resp[14]}" - VCS_STATUS_COMMITS_BEHIND="${resp[15]}" - VCS_STATUS_STASHES="${resp[16]}" - VCS_STATUS_TAG="${resp[17]}" - VCS_STATUS_NUM_UNSTAGED_DELETED="${resp[18]}" - VCS_STATUS_NUM_STAGED_NEW="${resp[19]:-0}" - VCS_STATUS_NUM_STAGED_DELETED="${resp[20]:-0}" - VCS_STATUS_PUSH_REMOTE_NAME="${resp[21]:-}" - VCS_STATUS_PUSH_REMOTE_URL="${resp[22]:-}" - VCS_STATUS_PUSH_COMMITS_AHEAD="${resp[23]:-0}" - VCS_STATUS_PUSH_COMMITS_BEHIND="${resp[24]:-0}" - VCS_STATUS_NUM_SKIP_WORKTREE="${resp[25]:-0}" - VCS_STATUS_NUM_ASSUME_UNCHANGED="${resp[26]:-0}" - VCS_STATUS_COMMIT_ENCODING="${resp[27]-}" - VCS_STATUS_COMMIT_SUMMARY="${resp[28]-}" - VCS_STATUS_HAS_STAGED=$((VCS_STATUS_NUM_STAGED > 0)) - if (( _GITSTATUS_DIRTY_MAX_INDEX_SIZE >= 0 && - VCS_STATUS_INDEX_SIZE > _GITSTATUS_DIRTY_MAX_INDEX_SIZE_ )); then - VCS_STATUS_HAS_UNSTAGED=-1 - VCS_STATUS_HAS_CONFLICTED=-1 - VCS_STATUS_HAS_UNTRACKED=-1 - else - VCS_STATUS_HAS_UNSTAGED=$((VCS_STATUS_NUM_UNSTAGED > 0)) - VCS_STATUS_HAS_CONFLICTED=$((VCS_STATUS_NUM_CONFLICTED > 0)) - VCS_STATUS_HAS_UNTRACKED=$((VCS_STATUS_NUM_UNTRACKED > 0)) - fi - else - VCS_STATUS_RESULT=norepo-sync - unset VCS_STATUS_WORKDIR - unset VCS_STATUS_COMMIT - unset VCS_STATUS_LOCAL_BRANCH - unset VCS_STATUS_REMOTE_BRANCH - unset VCS_STATUS_REMOTE_NAME - unset VCS_STATUS_REMOTE_URL - unset VCS_STATUS_ACTION - unset VCS_STATUS_INDEX_SIZE - unset VCS_STATUS_NUM_STAGED - unset VCS_STATUS_NUM_UNSTAGED - unset VCS_STATUS_NUM_CONFLICTED - unset VCS_STATUS_NUM_UNTRACKED - unset VCS_STATUS_HAS_STAGED - unset VCS_STATUS_HAS_UNSTAGED - unset VCS_STATUS_HAS_CONFLICTED - unset VCS_STATUS_HAS_UNTRACKED - unset VCS_STATUS_COMMITS_AHEAD - unset VCS_STATUS_COMMITS_BEHIND - unset VCS_STATUS_STASHES - unset VCS_STATUS_TAG - unset VCS_STATUS_NUM_UNSTAGED_DELETED - unset VCS_STATUS_NUM_STAGED_NEW - unset VCS_STATUS_NUM_STAGED_DELETED - unset VCS_STATUS_PUSH_REMOTE_NAME - unset VCS_STATUS_PUSH_REMOTE_URL - unset VCS_STATUS_PUSH_COMMITS_AHEAD - unset VCS_STATUS_PUSH_COMMITS_BEHIND - unset VCS_STATUS_NUM_SKIP_WORKTREE - unset VCS_STATUS_NUM_ASSUME_UNCHANGED - unset VCS_STATUS_COMMIT_ENCODING - unset VCS_STATUS_COMMIT_SUMMARY - fi -} - -# Usage: gitstatus_check. -# -# Returns 0 if and only if gitstatus_start has succeeded previously. -# If it returns non-zero, gitstatus_query is guaranteed to return non-zero. -function gitstatus_check() { - [[ -n "$GITSTATUS_DAEMON_PID" ]] -} diff --git a/.zsh/themes/powerlevel10k/gitstatus/gitstatus.plugin.zsh b/.zsh/themes/powerlevel10k/gitstatus/gitstatus.plugin.zsh deleted file mode 100644 index 228fea7..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/gitstatus.plugin.zsh +++ /dev/null @@ -1,908 +0,0 @@ -# Zsh bindings for gitstatus. -# -# ------------------------------------------------------------------ -# -# Example: Start gitstatusd, send it a request, wait for response and print it. -# -# source ~/gitstatus/gitstatus.plugin.zsh -# gitstatus_start MY -# gitstatus_query -d $PWD MY -# typeset -m 'VCS_STATUS_*' -# -# Output: -# -# VCS_STATUS_ACTION='' -# VCS_STATUS_COMMIT=c000eddcff0fb38df2d0137efe24d9d2d900f209 -# VCS_STATUS_COMMITS_AHEAD=0 -# VCS_STATUS_COMMITS_BEHIND=0 -# VCS_STATUS_COMMIT_ENCODING='' -# VCS_STATUS_COMMIT_SUMMARY='pull upstream changes from gitstatus' -# VCS_STATUS_HAS_CONFLICTED=0 -# VCS_STATUS_HAS_STAGED=0 -# VCS_STATUS_HAS_UNSTAGED=1 -# VCS_STATUS_HAS_UNTRACKED=1 -# VCS_STATUS_INDEX_SIZE=33 -# VCS_STATUS_LOCAL_BRANCH=master -# VCS_STATUS_NUM_ASSUME_UNCHANGED=0 -# VCS_STATUS_NUM_CONFLICTED=0 -# VCS_STATUS_NUM_STAGED=0 -# VCS_STATUS_NUM_UNSTAGED=1 -# VCS_STATUS_NUM_SKIP_WORKTREE=0 -# VCS_STATUS_NUM_STAGED_NEW=0 -# VCS_STATUS_NUM_STAGED_DELETED=0 -# VCS_STATUS_NUM_UNSTAGED_DELETED=0 -# VCS_STATUS_NUM_UNTRACKED=1 -# VCS_STATUS_PUSH_COMMITS_AHEAD=0 -# VCS_STATUS_PUSH_COMMITS_BEHIND=0 -# VCS_STATUS_PUSH_REMOTE_NAME='' -# VCS_STATUS_PUSH_REMOTE_URL='' -# VCS_STATUS_REMOTE_BRANCH=master -# VCS_STATUS_REMOTE_NAME=origin -# VCS_STATUS_REMOTE_URL=git@github.com:romkatv/powerlevel10k.git -# VCS_STATUS_RESULT=ok-sync -# VCS_STATUS_STASHES=0 -# VCS_STATUS_TAG='' -# VCS_STATUS_WORKDIR=/home/romka/powerlevel10k - -[[ -o 'interactive' ]] || 'return' - -# Temporarily change options. -'builtin' 'local' '-a' '_gitstatus_opts' -[[ ! -o 'aliases' ]] || _gitstatus_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || _gitstatus_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || _gitstatus_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -autoload -Uz add-zsh-hook || return -zmodload zsh/datetime zsh/system || return -zmodload -F zsh/files b:zf_rm || return - -typeset -g _gitstatus_plugin_dir"${1:-}"="${${(%):-%x}:A:h}" - -# Retrives status of a git repo from a directory under its working tree. -# -## Usage: gitstatus_query [OPTION]... NAME -# -# -d STR Directory to query. Defaults to the current directory. Has no effect if GIT_DIR -# is set. -# -c STR Callback function to call once the results are available. Called only after -# gitstatus_query returns 0 with VCS_STATUS_RESULT=tout. -# -t FLOAT Timeout in seconds. Negative value means infinity. Will block for at most this long. -# If no results are available by then: if -c isn't specified, will return 1; otherwise -# will set VCS_STATUS_RESULT=tout and return 0. -# -p Don't compute anything that requires reading Git index. If this option is used, -# the following parameters will be 0: VCS_STATUS_INDEX_SIZE, -# VCS_STATUS_{NUM,HAS}_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED}. -# -# On success sets VCS_STATUS_RESULT to one of the following values: -# -# tout Timed out waiting for data; will call the user-specified callback later. -# norepo-sync The directory isn't a git repo. -# ok-sync The directory is a git repo. -# -# When the callback is called, VCS_STATUS_RESULT is set to one of the following values: -# -# norepo-async The directory isn't a git repo. -# ok-async The directory is a git repo. -# -# If VCS_STATUS_RESULT is ok-sync or ok-async, additional variables are set: -# -# VCS_STATUS_WORKDIR Git repo working directory. Not empty. -# VCS_STATUS_COMMIT Commit hash that HEAD is pointing to. Either 40 hex digits or -# empty if there is no HEAD (empty repo). -# VCS_STATUS_COMMIT_ENCODING Encoding of the HEAD's commit message. Empty value means UTF-8. -# VCS_STATUS_COMMIT_SUMMARY The first paragraph of the HEAD's commit message as one line. -# VCS_STATUS_LOCAL_BRANCH Local branch name or empty if not on a branch. -# VCS_STATUS_REMOTE_NAME The remote name, e.g. "upstream" or "origin". -# VCS_STATUS_REMOTE_BRANCH Upstream branch name. Can be empty. -# VCS_STATUS_REMOTE_URL Remote URL. Can be empty. -# VCS_STATUS_ACTION Repository state, A.K.A. action. Can be empty. -# VCS_STATUS_INDEX_SIZE The number of files in the index. -# VCS_STATUS_NUM_STAGED The number of staged changes. -# VCS_STATUS_NUM_CONFLICTED The number of conflicted changes. -# VCS_STATUS_NUM_UNSTAGED The number of unstaged changes. -# VCS_STATUS_NUM_UNTRACKED The number of untracked files. -# VCS_STATUS_HAS_STAGED 1 if there are staged changes, 0 otherwise. -# VCS_STATUS_HAS_CONFLICTED 1 if there are conflicted changes, 0 otherwise. -# VCS_STATUS_HAS_UNSTAGED 1 if there are unstaged changes, 0 if there aren't, -1 if -# unknown. -# VCS_STATUS_NUM_STAGED_NEW The number of staged new files. Note that renamed files -# are reported as deleted plus new. -# VCS_STATUS_NUM_STAGED_DELETED The number of staged deleted files. Note that renamed files -# are reported as deleted plus new. -# VCS_STATUS_NUM_UNSTAGED_DELETED The number of unstaged deleted files. Note that renamed files -# are reported as deleted plus new. -# VCS_STATUS_HAS_UNTRACKED 1 if there are untracked files, 0 if there aren't, -1 if -# unknown. -# VCS_STATUS_COMMITS_AHEAD Number of commits the current branch is ahead of upstream. -# Non-negative integer. -# VCS_STATUS_COMMITS_BEHIND Number of commits the current branch is behind upstream. -# Non-negative integer. -# VCS_STATUS_STASHES Number of stashes. Non-negative integer. -# VCS_STATUS_TAG The last tag (in lexicographical order) that points to the same -# commit as HEAD. -# VCS_STATUS_PUSH_REMOTE_NAME The push remote name, e.g. "upstream" or "origin". -# VCS_STATUS_PUSH_REMOTE_URL Push remote URL. Can be empty. -# VCS_STATUS_PUSH_COMMITS_AHEAD Number of commits the current branch is ahead of push remote. -# Non-negative integer. -# VCS_STATUS_PUSH_COMMITS_BEHIND Number of commits the current branch is behind push remote. -# Non-negative integer. -# VCS_STATUS_NUM_SKIP_WORKTREE The number of files in the index with skip-worktree bit set. -# Non-negative integer. -# VCS_STATUS_NUM_ASSUME_UNCHANGED The number of files in the index with assume-unchanged bit set. -# Non-negative integer. -# -# The point of reporting -1 via VCS_STATUS_HAS_* is to allow the command to skip scanning files in -# large repos. See -m flag of gitstatus_start. -# -# gitstatus_query returns an error if gitstatus_start hasn't been called in the same shell or -# the call had failed. -# -# !!!!! WARNING: CONCURRENT CALLS WITH THE SAME NAME ARE NOT ALLOWED !!!!! -# -# It's illegal to call gitstatus_query if the last asynchronous call with the same NAME hasn't -# completed yet. If you need to issue concurrent requests, use different NAME arguments. -function gitstatus_query"${1:-}"() { - emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent - - local fsuf=${${(%):-%N}#gitstatus_query} - - unset VCS_STATUS_RESULT - - local opt dir callback OPTARG - local -i no_diff OPTIND - local -F timeout=-1 - while getopts ":d:c:t:p" opt; do - case $opt in - +p) no_diff=0;; - p) no_diff=1;; - d) dir=$OPTARG;; - c) callback=$OPTARG;; - t) - if [[ $OPTARG != (|+|-)<->(|.<->)(|[eE](|-|+)<->) ]]; then - print -ru2 -- "gitstatus_query: invalid -t argument: $OPTARG" - return 1 - fi - timeout=OPTARG - ;; - \?) print -ru2 -- "gitstatus_query: invalid option: $OPTARG" ; return 1;; - :) print -ru2 -- "gitstatus_query: missing required argument: $OPTARG"; return 1;; - *) print -ru2 -- "gitstatus_query: invalid option: $opt" ; return 1;; - esac - done - - if (( OPTIND != ARGC )); then - print -ru2 -- "gitstatus_query: exactly one positional argument is required" - return 1 - fi - - local name=$*[OPTIND] - if [[ $name != [[:IDENT:]]## ]]; then - print -ru2 -- "gitstatus_query: invalid positional argument: $name" - return 1 - fi - - (( _GITSTATUS_STATE_$name == 2 )) || return - - if [[ -z $GIT_DIR ]]; then - if [[ $dir != /* ]]; then - if [[ $PWD == /* && $PWD -ef . ]]; then - dir=$PWD/$dir - else - dir=${dir:a} - fi - fi - else - if [[ $GIT_DIR == /* ]]; then - dir=:$GIT_DIR - elif [[ $PWD == /* && $PWD -ef . ]]; then - dir=:$PWD/$GIT_DIR - else - dir=:${GIT_DIR:a} - fi - fi - - if [[ $dir != (|:)/* ]]; then - typeset -g VCS_STATUS_RESULT=norepo-sync - _gitstatus_clear$fsuf - return 0 - fi - - local -i req_fd=${(P)${:-_GITSTATUS_REQ_FD_$name}} - local req_id=$EPOCHREALTIME - print -rnu $req_fd -- $req_id' '$callback$'\x1f'$dir$'\x1f'$no_diff$'\x1e' || return - - (( ++_GITSTATUS_NUM_INFLIGHT_$name )) - - if (( timeout == 0 )); then - typeset -g VCS_STATUS_RESULT=tout - _gitstatus_clear$fsuf - else - while true; do - _gitstatus_process_response$fsuf $name $timeout $req_id || return - [[ $VCS_STATUS_RESULT == *-async ]] || break - done - fi - - [[ $VCS_STATUS_RESULT != tout || -n $callback ]] -} - -# If the last call to gitstatus_query timed out (VCS_STATUS_RESULT=tout), wait for the callback -# to be called. Otherwise do nothing. -# -# Usage: gitstatus_process_results [OPTION]... NAME -# -# -t FLOAT Timeout in seconds. Negative value means infinity. Will block for at most this long. -# -# Returns an error only when invoked with incorrect arguments and when gitstatusd isn't running or -# broken. -# -# If a callback gets called, VCS_STATUS_* parameters are set as in gitstatus_query. -# VCS_STATUS_RESULT is either norepo-async or ok-async. -function gitstatus_process_results"${1:-}"() { - emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent - - local fsuf=${${(%):-%N}#gitstatus_process_results} - - local opt OPTARG - local -i OPTIND - local -F timeout=-1 - while getopts ":t:" opt; do - case $opt in - t) - if [[ $OPTARG != (|+|-)<->(|.<->)(|[eE](|-|+)<->) ]]; then - print -ru2 -- "gitstatus_process_results: invalid -t argument: $OPTARG" - return 1 - fi - timeout=OPTARG - ;; - \?) print -ru2 -- "gitstatus_process_results: invalid option: $OPTARG" ; return 1;; - :) print -ru2 -- "gitstatus_process_results: missing required argument: $OPTARG"; return 1;; - *) print -ru2 -- "gitstatus_process_results: invalid option: $opt" ; return 1;; - esac - done - - if (( OPTIND != ARGC )); then - print -ru2 -- "gitstatus_process_results: exactly one positional argument is required" - return 1 - fi - - local name=$*[OPTIND] - if [[ $name != [[:IDENT:]]## ]]; then - print -ru2 -- "gitstatus_process_results: invalid positional argument: $name" - return 1 - fi - - (( _GITSTATUS_STATE_$name == 2 )) || return - - while (( _GITSTATUS_NUM_INFLIGHT_$name )); do - _gitstatus_process_response$fsuf $name $timeout '' || return - [[ $VCS_STATUS_RESULT == *-async ]] || break - done - - return 0 -} - -function _gitstatus_clear"${1:-}"() { - unset VCS_STATUS_{WORKDIR,COMMIT,LOCAL_BRANCH,REMOTE_BRANCH,REMOTE_NAME,REMOTE_URL,ACTION,INDEX_SIZE,NUM_STAGED,NUM_UNSTAGED,NUM_CONFLICTED,NUM_UNTRACKED,HAS_STAGED,HAS_UNSTAGED,HAS_CONFLICTED,HAS_UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND,STASHES,TAG,NUM_UNSTAGED_DELETED,NUM_STAGED_NEW,NUM_STAGED_DELETED,PUSH_REMOTE_NAME,PUSH_REMOTE_URL,PUSH_COMMITS_AHEAD,PUSH_COMMITS_BEHIND,NUM_SKIP_WORKTREE,NUM_ASSUME_UNCHANGED} -} - -function _gitstatus_process_response"${1:-}"() { - local name=$1 timeout req_id=$3 buf - local -i resp_fd=_GITSTATUS_RESP_FD_$name - local -i dirty_max_index_size=_GITSTATUS_DIRTY_MAX_INDEX_SIZE_$name - - (( $2 >= 0 )) && timeout=-t$2 && [[ -t $resp_fd ]] - sysread $timeout -i $resp_fd 'buf[$#buf+1]' || { - if (( $? == 4 )); then - if [[ -n $req_id ]]; then - typeset -g VCS_STATUS_RESULT=tout - _gitstatus_clear$fsuf - fi - return 0 - else - gitstatus_stop$fsuf $name - return 1 - fi - } - while [[ $buf != *$'\x1e' ]]; do - if ! sysread -i $resp_fd 'buf[$#buf+1]'; then - gitstatus_stop$fsuf $name - return 1 - fi - done - - local s - for s in ${(ps:\x1e:)buf}; do - local -a resp=("${(@ps:\x1f:)s}") - if (( resp[2] )); then - if [[ $resp[1] == $req_id' '* ]]; then - typeset -g VCS_STATUS_RESULT=ok-sync - else - typeset -g VCS_STATUS_RESULT=ok-async - fi - for VCS_STATUS_WORKDIR \ - VCS_STATUS_COMMIT \ - VCS_STATUS_LOCAL_BRANCH \ - VCS_STATUS_REMOTE_BRANCH \ - VCS_STATUS_REMOTE_NAME \ - VCS_STATUS_REMOTE_URL \ - VCS_STATUS_ACTION \ - VCS_STATUS_INDEX_SIZE \ - VCS_STATUS_NUM_STAGED \ - VCS_STATUS_NUM_UNSTAGED \ - VCS_STATUS_NUM_CONFLICTED \ - VCS_STATUS_NUM_UNTRACKED \ - VCS_STATUS_COMMITS_AHEAD \ - VCS_STATUS_COMMITS_BEHIND \ - VCS_STATUS_STASHES \ - VCS_STATUS_TAG \ - VCS_STATUS_NUM_UNSTAGED_DELETED \ - VCS_STATUS_NUM_STAGED_NEW \ - VCS_STATUS_NUM_STAGED_DELETED \ - VCS_STATUS_PUSH_REMOTE_NAME \ - VCS_STATUS_PUSH_REMOTE_URL \ - VCS_STATUS_PUSH_COMMITS_AHEAD \ - VCS_STATUS_PUSH_COMMITS_BEHIND \ - VCS_STATUS_NUM_SKIP_WORKTREE \ - VCS_STATUS_NUM_ASSUME_UNCHANGED \ - VCS_STATUS_COMMIT_ENCODING \ - VCS_STATUS_COMMIT_SUMMARY in "${(@)resp[3,29]}"; do - done - typeset -gi VCS_STATUS_{INDEX_SIZE,NUM_STAGED,NUM_UNSTAGED,NUM_CONFLICTED,NUM_UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND,STASHES,NUM_UNSTAGED_DELETED,NUM_STAGED_NEW,NUM_STAGED_DELETED,PUSH_COMMITS_AHEAD,PUSH_COMMITS_BEHIND,NUM_SKIP_WORKTREE,NUM_ASSUME_UNCHANGED} - typeset -gi VCS_STATUS_HAS_STAGED=$((VCS_STATUS_NUM_STAGED > 0)) - if (( dirty_max_index_size >= 0 && VCS_STATUS_INDEX_SIZE > dirty_max_index_size )); then - typeset -gi \ - VCS_STATUS_HAS_UNSTAGED=-1 \ - VCS_STATUS_HAS_CONFLICTED=-1 \ - VCS_STATUS_HAS_UNTRACKED=-1 - else - typeset -gi \ - VCS_STATUS_HAS_UNSTAGED=$((VCS_STATUS_NUM_UNSTAGED > 0)) \ - VCS_STATUS_HAS_CONFLICTED=$((VCS_STATUS_NUM_CONFLICTED > 0)) \ - VCS_STATUS_HAS_UNTRACKED=$((VCS_STATUS_NUM_UNTRACKED > 0)) - fi - else - if [[ $resp[1] == $req_id' '* ]]; then - typeset -g VCS_STATUS_RESULT=norepo-sync - else - typeset -g VCS_STATUS_RESULT=norepo-async - fi - _gitstatus_clear$fsuf - fi - (( --_GITSTATUS_NUM_INFLIGHT_$name )) - [[ $VCS_STATUS_RESULT == *-async ]] && emulate zsh -c "${resp[1]#* }" - done - - return 0 -} - -function _gitstatus_daemon"${1:-}"() { - local -i pipe_fd - exec 0<&- {pipe_fd}>&1 1>>$daemon_log 2>&1 || return - local pgid=$sysparams[pid] - [[ $pgid == <1-> ]] || return - builtin cd -q / || return - - { - { - trap '' PIPE - - local uname_sm - uname_sm="${${(L)$(command uname -sm)}//ı/i}" || return - [[ $uname_sm == [^' ']##' '[^' ']## ]] || return - local uname_s=${uname_sm% *} - local uname_m=${uname_sm#* } - - if [[ $GITSTATUS_NUM_THREADS == <1-> ]]; then - args+=(-t $GITSTATUS_NUM_THREADS) - else - local cpus - if (( ! $+commands[sysctl] )) || [[ $uname_s == linux ]] || - ! cpus="$(command sysctl -n hw.ncpu)"; then - if (( ! $+commands[getconf] )) || ! cpus="$(command getconf _NPROCESSORS_ONLN)"; then - cpus=8 - fi - fi - args+=(-t $((cpus > 16 ? 32 : cpus > 0 ? 2 * cpus : 16))) - fi - - command mkfifo -- $file_prefix.fifo || return - print -rnu $pipe_fd -- ${(l:20:)pgid} || return - exec <$file_prefix.fifo || return - zf_rm -- $file_prefix.fifo || return - - local _gitstatus_zsh_daemon _gitstatus_zsh_version _gitstatus_zsh_downloaded - - function _gitstatus_set_daemon$fsuf() { - _gitstatus_zsh_daemon="$1" - _gitstatus_zsh_version="$2" - _gitstatus_zsh_downloaded="$3" - } - - local gitstatus_plugin_dir_var=_gitstatus_plugin_dir$fsuf - local gitstatus_plugin_dir=${(P)gitstatus_plugin_dir_var} - builtin set -- -d $gitstatus_plugin_dir -s $uname_s -m $uname_m \ - -p "printf '\\001' >&$pipe_fd" -e $pipe_fd -- _gitstatus_set_daemon$fsuf - [[ ${GITSTATUS_AUTO_INSTALL:-1} == (|-|+)<1-> ]] || builtin set -- -n "$@" - builtin source $gitstatus_plugin_dir/install || return - [[ -n $_gitstatus_zsh_daemon ]] || return - [[ -n $_gitstatus_zsh_version ]] || return - [[ $_gitstatus_zsh_downloaded == [01] ]] || return - - if (( UID == EUID )); then - local home=~ - else - local user - user="$(command id -un)" || return - local home=${userdirs[$user]} - [[ -n $home ]] || return - fi - - if [[ -x $_gitstatus_zsh_daemon ]]; then - HOME=$home $_gitstatus_zsh_daemon -G $_gitstatus_zsh_version "${(@)args}" >&$pipe_fd - local -i ret=$? - [[ $ret == (0|129|130|131|137|141|143|159) ]] && return ret - fi - - (( ! _gitstatus_zsh_downloaded )) || return - [[ ${GITSTATUS_AUTO_INSTALL:-1} == (|-|+)<1-> ]] || return - [[ $_gitstatus_zsh_daemon == \ - ${GITSTATUS_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/gitstatus}/* ]] || return - - builtin set -- -f "$@" - _gitstatus_zsh_daemon= - _gitstatus_zsh_version= - _gitstatus_zsh_downloaded= - builtin source $gitstatus_plugin_dir/install || return - [[ -n $_gitstatus_zsh_daemon ]] || return - [[ -n $_gitstatus_zsh_version ]] || return - [[ $_gitstatus_zsh_downloaded == 1 ]] || return - - HOME=$home $_gitstatus_zsh_daemon -G $_gitstatus_zsh_version "${(@)args}" >&$pipe_fd - } always { - local -i ret=$? - zf_rm -f -- $file_prefix.lock $file_prefix.fifo - kill -- -$pgid - } - } &! - - (( lock_fd == -1 )) && return - - { - if zsystem flock -- $file_prefix.lock && command sleep 5 && [[ -e $file_prefix.lock ]]; then - zf_rm -f -- $file_prefix.lock $file_prefix.fifo - kill -- -$pgid - fi - } &! -} - -# Starts gitstatusd in the background. Does nothing and succeeds if gitstatusd is already running. -# -# Usage: gitstatus_start [OPTION]... NAME -# -# -t FLOAT Fail the self-check on initialization if not getting a response from gitstatusd for -# this this many seconds. Defaults to 5. -# -# -s INT Report at most this many staged changes; negative value means infinity. -# Defaults to 1. -# -# -u INT Report at most this many unstaged changes; negative value means infinity. -# Defaults to 1. -# -# -c INT Report at most this many conflicted changes; negative value means infinity. -# Defaults to 1. -# -# -d INT Report at most this many untracked files; negative value means infinity. -# Defaults to 1. -# -# -m INT Report -1 unstaged, untracked and conflicted if there are more than this many -# files in the index. Negative value means infinity. Defaults to -1. -# -# -e Count files within untracked directories like `git status --untracked-files`. -# -# -U Unless this option is specified, report zero untracked files for repositories -# with status.showUntrackedFiles = false. -# -# -W Unless this option is specified, report zero untracked files for repositories -# with bash.showUntrackedFiles = false. -# -# -D Unless this option is specified, report zero staged, unstaged and conflicted -# changes for repositories with bash.showDirtyState = false. -function gitstatus_start"${1:-}"() { - emulate -L zsh -o no_aliases -o no_bg_nice -o extended_glob -o typeset_silent || return - print -rnu2 || return - - local fsuf=${${(%):-%N}#gitstatus_start} - - local opt OPTARG - local -i OPTIND - local -F timeout=5 - local -i async=0 - local -a args=() - local -i dirty_max_index_size=-1 - - while getopts ":t:s:u:c:d:m:eaUWD" opt; do - case $opt in - a) async=1;; - +a) async=0;; - t) - if [[ $OPTARG != (|+)<->(|.<->)(|[eE](|-|+)<->) ]] || (( ${timeout::=OPTARG} <= 0 )); then - print -ru2 -- "gitstatus_start: invalid -t argument: $OPTARG" - return 1 - fi - ;; - s|u|c|d|m) - if [[ $OPTARG != (|-|+)<-> ]]; then - print -ru2 -- "gitstatus_start: invalid -$opt argument: $OPTARG" - return 1 - fi - args+=(-$opt $OPTARG) - [[ $opt == m ]] && dirty_max_index_size=OPTARG - ;; - e|U|W|D) args+=-$opt;; - +(e|U|W|D)) args=(${(@)args:#-$opt});; - \?) print -ru2 -- "gitstatus_start: invalid option: $OPTARG" ; return 1;; - :) print -ru2 -- "gitstatus_start: missing required argument: $OPTARG"; return 1;; - *) print -ru2 -- "gitstatus_start: invalid option: $opt" ; return 1;; - esac - done - - if (( OPTIND != ARGC )); then - print -ru2 -- "gitstatus_start: exactly one positional argument is required" - return 1 - fi - - local name=$*[OPTIND] - if [[ $name != [[:IDENT:]]## ]]; then - print -ru2 -- "gitstatus_start: invalid positional argument: $name" - return 1 - fi - - local -i lock_fd resp_fd stderr_fd - local file_prefix xtrace=/dev/null daemon_log=/dev/null culprit - - { - if (( _GITSTATUS_STATE_$name )); then - (( async )) && return - (( _GITSTATUS_STATE_$name == 2 )) && return - lock_fd=_GITSTATUS_LOCK_FD_$name - resp_fd=_GITSTATUS_RESP_FD_$name - xtrace=${(P)${:-GITSTATUS_XTRACE_$name}} - daemon_log=${(P)${:-GITSTATUS_DAEMON_LOG_$name}} - file_prefix=${(P)${:-_GITSTATUS_FILE_PREFIX_$name}} - else - typeset -gi _GITSTATUS_START_COUNTER - local log_level=$GITSTATUS_LOG_LEVEL - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - local file_prefix=${tmpdir:A}/gitstatus.$name.$EUID - file_prefix+=.$sysparams[pid].$EPOCHSECONDS.$((++_GITSTATUS_START_COUNTER)) - (( GITSTATUS_ENABLE_LOGGING )) && : ${log_level:=INFO} - if [[ -n $log_level ]]; then - xtrace=$file_prefix.xtrace.log - daemon_log=$file_prefix.daemon.log - fi - args+=(-v ${log_level:-FATAL}) - typeset -g GITSTATUS_XTRACE_$name=$xtrace - typeset -g GITSTATUS_DAEMON_LOG_$name=$daemon_log - typeset -g _GITSTATUS_FILE_PREFIX_$name=$file_prefix - typeset -gi _GITSTATUS_CLIENT_PID_$name="sysparams[pid]" - typeset -gi _GITSTATUS_DIRTY_MAX_INDEX_SIZE_$name=dirty_max_index_size - fi - - () { - if [[ $xtrace != /dev/null && -o no_xtrace ]]; then - exec {stderr_fd}>&2 || return - exec 2>>$xtrace || return - setopt xtrace - fi - - setopt monitor || return - - if (( ! _GITSTATUS_STATE_$name )); then - if [[ -r /proc/version && "$(</proc/version)" == *Microsoft* ]]; then - lock_fd=-1 - else - print -rn >$file_prefix.lock || return - zsystem flock -f lock_fd $file_prefix.lock || return - [[ $lock_fd == <1-> ]] || return - fi - - typeset -gi _GITSTATUS_LOCK_FD_$name=lock_fd - - if [[ $OSTYPE == cygwin* && -d /proc/self/fd ]]; then - # Work around bugs in Cygwin 32-bit. - # - # This hangs: - # - # emulate -L zsh - # () { exec {fd}< $1 } <(:) - # =true # hangs here - # - # This hangs: - # - # sysopen -r -u fd <(:) - local -i fd - exec {fd}< <(_gitstatus_daemon$fsuf) || return - { - [[ -r /proc/self/fd/$fd ]] || return - sysopen -r -o cloexec -u resp_fd /proc/self/fd/$fd || return - } always { - exec {fd} >&- || return - } - else - sysopen -r -o cloexec -u resp_fd <(_gitstatus_daemon$fsuf) || return - fi - - typeset -gi GITSTATUS_DAEMON_PID_$name="${sysparams[procsubstpid]:--1}" - - [[ $resp_fd == <1-> ]] || return - typeset -gi _GITSTATUS_RESP_FD_$name=resp_fd - typeset -gi _GITSTATUS_STATE_$name=1 - fi - - if (( ! async )); then - (( _GITSTATUS_CLIENT_PID_$name == sysparams[pid] )) || return - - local pgid - while (( $#pgid < 20 )); do - [[ -t $resp_fd ]] - sysread -s $((20 - $#pgid)) -t $timeout -i $resp_fd 'pgid[$#pgid+1]' || return - done - [[ $pgid == ' '#<1-> ]] || return - typeset -gi GITSTATUS_DAEMON_PID_$name=pgid - - sysopen -w -o cloexec -u req_fd -- $file_prefix.fifo || return - [[ $req_fd == <1-> ]] || return - typeset -gi _GITSTATUS_REQ_FD_$name=req_fd - - print -nru $req_fd -- $'}hello\x1f\x1e' || return - local expected=$'}hello\x1f0\x1e' actual - if (( $+functions[p10k] )) && [[ ! -t 1 && ! -t 0 ]]; then - local -F deadline='EPOCHREALTIME + 4' - else - local -F deadline='1' - fi - while true; do - [[ -t $resp_fd ]] - sysread -s 1 -t $timeout -i $resp_fd actual || return - [[ $expected == $actual* ]] && break - if [[ $actual != $'\1' ]]; then - [[ -t $resp_fd ]] - while sysread -t $timeout -i $resp_fd 'actual[$#actual+1]'; do - [[ -t $resp_fd ]] - done - culprit=$actual - return 1 - fi - (( EPOCHREALTIME < deadline )) && continue - if (( deadline > 0 )); then - deadline=0 - if (( stderr_fd )); then - unsetopt xtrace - exec 2>&$stderr_fd {stderr_fd}>&- - stderr_fd=0 - fi - if (( $+functions[p10k] )); then - p10k clear-instant-prompt || return - fi - if [[ $name == POWERLEVEL9K ]]; then - local label=powerlevel10k - else - local label=gitstatus - fi - if [[ -t 2 ]]; then - local spinner=($'\b%3F-%f' $'\b%3F\\%f' $'\b%3F|%f' $'\b%3F/%f') - print -Prnu2 -- "[%3F$label%f] fetching %2Fgitstatusd%f .. " - else - local spinner=('.') - print -rnu2 -- "[$label] fetching gitstatusd .." - fi - fi - print -Prnu2 -- $spinner[1] - spinner=($spinner[2,-1] $spinner[1]) - done - - if (( deadline == 0 )); then - if [[ -t 2 ]]; then - print -Pru2 -- $'\b[%2Fok%f]' - else - print -ru2 -- ' [ok]' - fi - if [[ $xtrace != /dev/null && -o no_xtrace ]]; then - exec {stderr_fd}>&2 || return - exec 2>>$xtrace || return - setopt xtrace - fi - fi - - while (( $#actual < $#expected )); do - [[ -t $resp_fd ]] - sysread -s $(($#expected - $#actual)) -t $timeout -i $resp_fd 'actual[$#actual+1]' || return - done - [[ $actual == $expected ]] || return - - function _gitstatus_process_response_$name-$fsuf() { - emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent - local pair=${${(%):-%N}#_gitstatus_process_response_} - local name=${pair%%-*} - local fsuf=${pair#*-} - [[ $name == POWERLEVEL9K && $fsuf == _p9k_ ]] && eval $__p9k_intro_base - if (( ARGC == 1 )); then - _gitstatus_process_response$fsuf $name 0 '' - else - gitstatus_stop$fsuf $name - fi - } - if ! zle -F $resp_fd _gitstatus_process_response_$name-$fsuf; then - unfunction _gitstatus_process_response_$name-$fsuf - return 1 - fi - - function _gitstatus_cleanup_$name-$fsuf() { - emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent - local pair=${${(%):-%N}#_gitstatus_cleanup_} - local name=${pair%%-*} - local fsuf=${pair#*-} - (( _GITSTATUS_CLIENT_PID_$name == sysparams[pid] )) || return - gitstatus_stop$fsuf $name - } - if ! add-zsh-hook zshexit _gitstatus_cleanup_$name-$fsuf; then - unfunction _gitstatus_cleanup_$name-$fsuf - return 1 - fi - - if (( lock_fd != -1 )); then - zf_rm -- $file_prefix.lock || return - zsystem flock -u $lock_fd || return - fi - unset _GITSTATUS_LOCK_FD_$name - - typeset -gi _GITSTATUS_STATE_$name=2 - fi - } - } always { - local -i err=$? - (( stderr_fd )) && exec 2>&$stderr_fd {stderr_fd}>&- - (( err == 0 )) && return - - gitstatus_stop$fsuf $name - - setopt prompt_percent no_prompt_subst no_prompt_bang - (( $+functions[p10k] )) && p10k clear-instant-prompt - print -ru2 -- '' - print -Pru2 -- '[%F{red}ERROR%f]: gitstatus failed to initialize.' - print -ru2 -- '' - if [[ -n $culprit ]]; then - print -ru2 -- $culprit - return err - fi - if [[ -s $xtrace ]]; then - print -ru2 -- '' - print -Pru2 -- " Zsh log (%U${xtrace//\%/%%}%u):" - print -Pru2 -- '%F{yellow}' - print -lru2 -- "${(@)${(@f)$(<$xtrace)}/#/ }" - print -Pnru2 -- '%f' - fi - if [[ -s $daemon_log ]]; then - print -ru2 -- '' - print -Pru2 -- " Daemon log (%U${daemon_log//\%/%%}%u):" - print -Pru2 -- '%F{yellow}' - print -lru2 -- "${(@)${(@f)$(<$daemon_log)}/#/ }" - print -Pnru2 -- '%f' - fi - if [[ $GITSTATUS_LOG_LEVEL == DEBUG ]]; then - print -ru2 -- '' - print -ru2 -- ' System information:' - print -Pru2 -- '%F{yellow}' - print -ru2 -- " zsh: $ZSH_VERSION" - print -ru2 -- " uname -a: $(command uname -a)" - print -Pru2 -- '%f' - print -ru2 -- ' If you need help, open an issue and attach this whole error message to it:' - print -ru2 -- '' - print -Pru2 -- ' %Uhttps://github.com/romkatv/gitstatus/issues/new%u' - else - print -ru2 -- '' - local home=~ - local zshrc=${${${(q)${ZDOTDIR:-~}}/#${(q)home}/'~'}//\%/%%}/.zshrc - print -Pru2 -- " Add the following parameter to %U$zshrc%u for extra diagnostics on error:" - print -ru2 -- '' - print -Pru2 -- ' %BGITSTATUS_LOG_LEVEL=DEBUG%b' - print -ru2 -- '' - print -ru2 -- ' Restart Zsh to retry gitstatus initialization:' - print -ru2 -- '' - print -Pru2 -- ' %F{green}%Uexec%u zsh%f' - fi - } -} - -# Stops gitstatusd if it's running. -# -# Usage: gitstatus_stop NAME. -function gitstatus_stop"${1:-}"() { - emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent - - local fsuf=${${(%):-%N}#gitstatus_stop} - - if (( ARGC != 1 )); then - print -ru2 -- "gitstatus_stop: exactly one positional argument is required" - return 1 - fi - - local name=$1 - if [[ $name != [[:IDENT:]]## ]]; then - print -ru2 -- "gitstatus_stop: invalid positional argument: $name" - return 1 - fi - - local state_var=_GITSTATUS_STATE_$name - local req_fd_var=_GITSTATUS_REQ_FD_$name - local resp_fd_var=_GITSTATUS_RESP_FD_$name - local lock_fd_var=_GITSTATUS_LOCK_FD_$name - local client_pid_var=_GITSTATUS_CLIENT_PID_$name - local daemon_pid_var=GITSTATUS_DAEMON_PID_$name - local inflight_var=_GITSTATUS_NUM_INFLIGHT_$name - local file_prefix_var=_GITSTATUS_FILE_PREFIX_$name - local dirty_max_index_size_var=_GITSTATUS_DIRTY_MAX_INDEX_SIZE_$name - - local req_fd=${(P)req_fd_var} - local resp_fd=${(P)resp_fd_var} - local lock_fd=${(P)lock_fd_var} - local daemon_pid=${(P)daemon_pid_var} - local file_prefix=${(P)file_prefix_var} - - local cleanup=_gitstatus_cleanup_$name-$fsuf - local process=_gitstatus_process_response_$name-$fsuf - - if (( $+functions[$cleanup] )); then - add-zsh-hook -d zshexit $cleanup - unfunction -- $cleanup - fi - - if (( $+functions[$process] )); then - [[ -n $resp_fd ]] && zle -F $resp_fd - unfunction -- $process - fi - - [[ $daemon_pid == <1-> ]] && kill -- -$daemon_pid 2>/dev/null - [[ $file_prefix == /* ]] && zf_rm -f -- $file_prefix.lock $file_prefix.fifo - [[ $lock_fd == <1-> ]] && zsystem flock -u $lock_fd - [[ $req_fd == <1-> ]] && exec {req_fd}>&- - [[ $resp_fd == <1-> ]] && exec {resp_fd}>&- - - unset $state_var $req_fd_var $lock_fd_var $resp_fd_var $client_pid_var $daemon_pid_var - unset $inflight_var $file_prefix_var $dirty_max_index_size_var - - unset VCS_STATUS_RESULT - _gitstatus_clear$fsuf -} - -# Usage: gitstatus_check NAME. -# -# Returns 0 if and only if `gitstatus_start NAME` has succeeded previously. -# If it returns non-zero, gitstatus_query NAME is guaranteed to return non-zero. -function gitstatus_check"${1:-}"() { - emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent - - local fsuf=${${(%):-%N}#gitstatus_check} - - if (( ARGC != 1 )); then - print -ru2 -- "gitstatus_check: exactly one positional argument is required" - return 1 - fi - - local name=$1 - if [[ $name != [[:IDENT:]]## ]]; then - print -ru2 -- "gitstatus_check: invalid positional argument: $name" - return 1 - fi - - (( _GITSTATUS_STATE_$name == 2 )) -} - -(( ${#_gitstatus_opts} )) && setopt ${_gitstatus_opts[@]} -'builtin' 'unset' '_gitstatus_opts' diff --git a/.zsh/themes/powerlevel10k/gitstatus/gitstatus.prompt.sh b/.zsh/themes/powerlevel10k/gitstatus/gitstatus.prompt.sh deleted file mode 100644 index 8ee28de..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/gitstatus.prompt.sh +++ /dev/null @@ -1,104 +0,0 @@ -# Simple Bash prompt with Git status. - -# Source gitstatus.plugin.sh from $GITSTATUS_DIR or from the same directory -# in which the current script resides if the variable isn't set. -if [[ -n "${GITSTATUS_DIR:-}" ]]; then - source "$GITSTATUS_DIR" || return -elif [[ "${BASH_SOURCE[0]}" == */* ]]; then - source "${BASH_SOURCE[0]%/*}/gitstatus.plugin.sh" || return -else - source gitstatus.plugin.sh || return -fi - -# Sets GITSTATUS_PROMPT to reflect the state of the current git repository. -# The value is empty if not in a git repository. Forwards all arguments to -# gitstatus_query. -# -# Example value of GITSTATUS_PROMPT: master ⇣42⇡42 ⇠42⇢42 *42 merge ~42 +42 !42 ?42 -# -# master current branch -# ⇣42 local branch is 42 commits behind the remote -# ⇡42 local branch is 42 commits ahead of the remote -# ⇠42 local branch is 42 commits behind the push remote -# ⇢42 local branch is 42 commits ahead of the push remote -# *42 42 stashes -# merge merge in progress -# ~42 42 merge conflicts -# +42 42 staged changes -# !42 42 unstaged changes -# ?42 42 untracked files -function gitstatus_prompt_update() { - GITSTATUS_PROMPT="" - - gitstatus_query "$@" || return 1 # error - [[ "$VCS_STATUS_RESULT" == ok-sync ]] || return 0 # not a git repo - - local reset=$'\001\e[0m\002' # no color - local clean=$'\001\e[38;5;076m\002' # green foreground - local untracked=$'\001\e[38;5;014m\002' # teal foreground - local modified=$'\001\e[38;5;011m\002' # yellow foreground - local conflicted=$'\001\e[38;5;196m\002' # red foreground - - local p - - local where # branch name, tag or commit - if [[ -n "$VCS_STATUS_LOCAL_BRANCH" ]]; then - where="$VCS_STATUS_LOCAL_BRANCH" - elif [[ -n "$VCS_STATUS_TAG" ]]; then - p+="${reset}#" - where="$VCS_STATUS_TAG" - else - p+="${reset}@" - where="${VCS_STATUS_COMMIT:0:8}" - fi - - (( ${#where} > 32 )) && where="${where:0:12}…${where: -12}" # truncate long branch names and tags - p+="${clean}${where}" - - # ⇣42 if behind the remote. - (( VCS_STATUS_COMMITS_BEHIND )) && p+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" - # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. - (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && p+=" " - (( VCS_STATUS_COMMITS_AHEAD )) && p+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" - # ⇠42 if behind the push remote. - (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" - (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" " - # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. - (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && p+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" - # *42 if have stashes. - (( VCS_STATUS_STASHES )) && p+=" ${clean}*${VCS_STATUS_STASHES}" - # 'merge' if the repo is in an unusual state. - [[ -n "$VCS_STATUS_ACTION" ]] && p+=" ${conflicted}${VCS_STATUS_ACTION}" - # ~42 if have merge conflicts. - (( VCS_STATUS_NUM_CONFLICTED )) && p+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" - # +42 if have staged changes. - (( VCS_STATUS_NUM_STAGED )) && p+=" ${modified}+${VCS_STATUS_NUM_STAGED}" - # !42 if have unstaged changes. - (( VCS_STATUS_NUM_UNSTAGED )) && p+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" - # ?42 if have untracked files. It's really a question mark, your font isn't broken. - (( VCS_STATUS_NUM_UNTRACKED )) && p+=" ${untracked}?${VCS_STATUS_NUM_UNTRACKED}" - - GITSTATUS_PROMPT="${p}${reset}" -} - -# Start gitstatusd in the background. -gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1 - -# On every prompt, fetch git status and set GITSTATUS_PROMPT. -PROMPT_COMMAND=gitstatus_prompt_update -PROMPT_DIRTRIM=3 - -# Enable promptvars so that ${GITSTATUS_PROMPT} in PS1 is expanded. -shopt -s promptvars - -# Customize prompt. Put $GITSTATUS_PROMPT in it reflect git status. -# -# Example: -# -# user@host ~/projects/skynet master ⇡42 -# $ █ -PS1='\[\033[01;32m\]\u@\h\[\033[00m\] ' # green user@host -PS1+='\[\033[01;34m\]\w\[\033[00m\]' # blue current working directory -PS1+='${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT}' # git status (requires promptvars option) -PS1+='\n\[\033[01;$((31+!$?))m\]\$\[\033[00m\] ' # green/red (success/error) $/# (normal/root) -PS1+='\[\e]0;\u@\h: \w\a\]' # terminal title: user@host: dir diff --git a/.zsh/themes/powerlevel10k/gitstatus/gitstatus.prompt.zsh b/.zsh/themes/powerlevel10k/gitstatus/gitstatus.prompt.zsh deleted file mode 100644 index 6ad6485..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/gitstatus.prompt.zsh +++ /dev/null @@ -1,111 +0,0 @@ -# Simple Zsh prompt with Git status. - -# Source gitstatus.plugin.zsh from $GITSTATUS_DIR or from the same directory -# in which the current script resides if the variable isn't set. -source "${GITSTATUS_DIR:-${${(%):-%x}:h}}/gitstatus.plugin.zsh" || return - -# Sets GITSTATUS_PROMPT to reflect the state of the current git repository. Empty if not -# in a git repository. In addition, sets GITSTATUS_PROMPT_LEN to the number of columns -# $GITSTATUS_PROMPT will occupy when printed. -# -# Example: -# -# GITSTATUS_PROMPT='master ⇣42⇡42 ⇠42⇢42 *42 merge ~42 +42 !42 ?42' -# GITSTATUS_PROMPT_LEN=39 -# -# master current branch -# ⇣42 local branch is 42 commits behind the remote -# ⇡42 local branch is 42 commits ahead of the remote -# ⇠42 local branch is 42 commits behind the push remote -# ⇢42 local branch is 42 commits ahead of the push remote -# *42 42 stashes -# merge merge in progress -# ~42 42 merge conflicts -# +42 42 staged changes -# !42 42 unstaged changes -# ?42 42 untracked files -function gitstatus_prompt_update() { - emulate -L zsh - typeset -g GITSTATUS_PROMPT='' - typeset -gi GITSTATUS_PROMPT_LEN=0 - - # Call gitstatus_query synchronously. Note that gitstatus_query can also be called - # asynchronously; see documentation in gitstatus.plugin.zsh. - gitstatus_query 'MY' || return 1 # error - [[ $VCS_STATUS_RESULT == 'ok-sync' ]] || return 0 # not a git repo - - local clean='%76F' # green foreground - local modified='%178F' # yellow foreground - local untracked='%39F' # blue foreground - local conflicted='%196F' # red foreground - - local p - - local where # branch name, tag or commit - if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - where=$VCS_STATUS_LOCAL_BRANCH - elif [[ -n $VCS_STATUS_TAG ]]; then - p+='%f#' - where=$VCS_STATUS_TAG - else - p+='%f@' - where=${VCS_STATUS_COMMIT[1,8]} - fi - - (( $#where > 32 )) && where[13,-13]="…" # truncate long branch names and tags - p+="${clean}${where//\%/%%}" # escape % - - # ⇣42 if behind the remote. - (( VCS_STATUS_COMMITS_BEHIND )) && p+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" - # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. - (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && p+=" " - (( VCS_STATUS_COMMITS_AHEAD )) && p+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" - # ⇠42 if behind the push remote. - (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" - (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" " - # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. - (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && p+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" - # *42 if have stashes. - (( VCS_STATUS_STASHES )) && p+=" ${clean}*${VCS_STATUS_STASHES}" - # 'merge' if the repo is in an unusual state. - [[ -n $VCS_STATUS_ACTION ]] && p+=" ${conflicted}${VCS_STATUS_ACTION}" - # ~42 if have merge conflicts. - (( VCS_STATUS_NUM_CONFLICTED )) && p+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" - # +42 if have staged changes. - (( VCS_STATUS_NUM_STAGED )) && p+=" ${modified}+${VCS_STATUS_NUM_STAGED}" - # !42 if have unstaged changes. - (( VCS_STATUS_NUM_UNSTAGED )) && p+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" - # ?42 if have untracked files. It's really a question mark, your font isn't broken. - (( VCS_STATUS_NUM_UNTRACKED )) && p+=" ${untracked}?${VCS_STATUS_NUM_UNTRACKED}" - - GITSTATUS_PROMPT="${p}%f" - - # The length of GITSTATUS_PROMPT after removing %f and %F. - GITSTATUS_PROMPT_LEN="${(m)#${${GITSTATUS_PROMPT//\%\%/x}//\%(f|<->F)}}" -} - -# Start gitstatusd instance with name "MY". The same name is passed to -# gitstatus_query in gitstatus_prompt_update. The flags with -1 as values -# enable staged, unstaged, conflicted and untracked counters. -gitstatus_stop 'MY' && gitstatus_start -s -1 -u -1 -c -1 -d -1 'MY' - -# On every prompt, fetch git status and set GITSTATUS_PROMPT. -autoload -Uz add-zsh-hook -add-zsh-hook precmd gitstatus_prompt_update - -# Enable/disable the right prompt options. -setopt no_prompt_bang prompt_percent prompt_subst - -# Customize prompt. Put $GITSTATUS_PROMPT in it to reflect git status. -# -# Example: -# -# user@host ~/projects/skynet master ⇡42 -# % █ -# -# The current directory gets truncated from the left if the whole prompt doesn't fit on the line. -PROMPT='%70F%n@%m%f ' # green user@host -PROMPT+='%39F%$((-GITSTATUS_PROMPT_LEN-1))<…<%~%<<%f' # blue current working directory -PROMPT+='${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT}' # git status -PROMPT+=$'\n' # new line -PROMPT+='%F{%(?.76.196)}%#%f ' # %/# (normal/root); green/red (ok/error) diff --git a/.zsh/themes/powerlevel10k/gitstatus/install b/.zsh/themes/powerlevel10k/gitstatus/install deleted file mode 100644 index 76f339e..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/install +++ /dev/null @@ -1,476 +0,0 @@ -#!/bin/sh -# -# This script does not have a stable API. - -_gitstatus_install_daemon_found() { - local installed="$1" - shift - [ $# = 0 ] || "$@" "$daemon" "$version" "$installed" -} - -_gitstatus_install_main() { - if [ -n "${ZSH_VERSION:-}" ]; then - emulate -L sh -o no_unset - else - set -u - fi - - local argv1="$1" - shift - - local no_check= no_install= uname_s= uname_m= gitstatus_dir= dl_status= e= - local opt= OPTARG= OPTIND=1 - - while getopts ':s:m:d:p:e:fnh' opt "$@"; do - case "$opt" in - h) - command cat <<\END -Usage: install [-s KERNEL] [-m ARCH] [-d DIR] [-p CMD] [-e ERRFD] [-f|-n] [-- CMD [ARG]...] - -If positional arguments are specified, call this on success: - - CMD [ARG]... DAEMON VERSION INSTALLED - -DAEMON is path to gitstatusd. VERSION is a glob pattern for the -version this daemon should support; it's supposed to be passed as --G to gitstatusd. INSTALLED is 1 if gitstatusd has just been -downloaded and 0 otherwise. - -Options: - - -s KERNEL use this instead of lowercase `uname -s` - -m ARCH use this instead of lowercase `uname -m` - -d DIR use this instead of `dirname "$0"` - -p CMD eval this every second while downloading gitstatusd - -e ERRFD write error messages to this file descriptor - -f download gitstatusd even if there is one locally - -n do not download gitstatusd (fail instead) -END - return - ;; - n) - if [ -n "$no_install" ]; then - >&2 echo "[gitstatus] error: duplicate option: -$opt" - return 1 - fi - no_install=1 - ;; - f) - if [ -n "$no_check" ]; then - >&2 echo "[gitstatus] error: duplicate option: -$opt" - return 1 - fi - no_check=1 - ;; - d) - if [ -n "$gitstatus_dir" ]; then - >&2 echo "[gitstatus] error: duplicate option: -$opt" - return 1 - fi - if [ -z "$OPTARG" ]; then - >&2 echo "[error] incorrect value of -$opt: $OPTARG" - return 1 - fi - gitstatus_dir="$OPTARG" - ;; - p) - if [ -n "$dl_status" ]; then - >&2 echo "[gitstatus] error: duplicate option: -$opt" - return 1 - fi - if [ -z "$OPTARG" ]; then - >&2 echo "[error] incorrect value of -$opt: $OPTARG" - return 1 - fi - dl_status="$OPTARG" - ;; - e) - if [ -n "$e" ]; then - >&2 echo "[gitstatus] error: duplicate option: -$opt" - return 1 - fi - if [ -z "$OPTARG" ]; then - >&2 echo "[error] incorrect value of -$opt: $OPTARG" - return 1 - fi - e="$OPTARG" - ;; - m) - if [ -n "$uname_m" ]; then - >&2 echo "[gitstatus] error: duplicate option: -$opt" - return 1 - fi - if [ -z "$OPTARG" ]; then - >&2 echo "[error] incorrect value of -$opt: $OPTARG" - return 1 - fi - uname_m="$OPTARG" - ;; - s) - if [ -n "$uname_s" ]; then - >&2 echo "[gitstatus] error: duplicate option: -$opt" - return 1 - fi - if [ -z "$OPTARG" ]; then - >&2 echo "[error] incorrect value of -$opt: $OPTARG" - return 1 - fi - uname_s="$OPTARG" - ;; - \?) >&2 echo "[gitstatus] error: invalid option: -$OPTARG" ; return 1;; - :) >&2 echo "[gitstatus] error: missing required argument: -$OPTARG"; return 1;; - *) >&2 echo "[gitstatus] internal error: unhandled option: -$opt" ; return 1;; - esac - done - - shift "$((OPTIND - 1))" - - : "${e:=2}" - : "${gitstatus_dir:=$argv1}" - - if [ -n "$no_check" -a -n "$no_install" ]; then - >&2 echo "[gitstatus] error: incompatible options: -f, -n" - return 1 - fi - - if [ -z "$uname_s" ]; then - uname_s="$(command uname -s)" || return - uname_s="$(printf '%s' "$uname_s" | command tr '[A-Z]' '[a-z]')" || return - fi - if [ -z "$uname_m" ]; then - uname_m="$(command uname -m)" || return - uname_m="$(printf '%s' "$uname_m" | command tr '[A-Z]' '[a-z]')" || return - fi - - local daemon="${GITSTATUS_DAEMON:-}" - local cache_dir="${GITSTATUS_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/gitstatus}" - - if [ -z "$no_check" ]; then - if [ -n "${daemon##/*}" ]; then - >&2 echo "[gitstatus] error: GITSTATUS_DAEMON is not absolute path: $daemon" - return 1 - fi - if [ -z "$daemon" -a -e "$gitstatus_dir"/usrbin/gitstatusd ]; then - daemon="$gitstatus_dir"/usrbin/gitstatusd - fi - if [ -n "$daemon" ]; then - local gitstatus_version= libgit2_version= - if ! . "$gitstatus_dir"/build.info; then - >&2 echo "[gitstatus] internal error: failed to source build.info" - return 1 - fi - if [ -z "$gitstatus_version" ]; then - >&2 echo "[gitstatus] internal error: empty gitstatus_version in build.info" - return 1 - fi - local version="$gitstatus_version" - _gitstatus_install_daemon_found 0 "$@" - return - fi - fi - - while IFS= read -r line; do - line="${line###*}" - [ -n "$line" ] || continue - - local uname_s_glob= uname_m_glob= file= version= sha256= - eval "$line" || return - - if [ -z "$uname_s_glob" -o \ - -z "$uname_m_glob" -o \ - -z "$file" -o \ - -z "$version" -o \ - -z "$sha256" ]; then - >&2 echo "[gitstatus] internal error: invalid install.info line: $line" - return 1 - fi - - case "$uname_s" in - $uname_s_glob) ;; - *) continue;; - esac - case "$uname_m" in - $uname_m_glob) ;; - *) continue;; - esac - - # Found a match. The while loop will terminate during this iteration. - - if [ -z "$no_check" ]; then - # Check if a suitable gitstatusd already exists. - local daemon="$gitstatus_dir"/usrbin/"$file" - if [ ! -e "$daemon" ]; then - daemon="$cache_dir"/"$file" - [ -e "$daemon" ] || daemon= - fi - if [ -n "$daemon" ]; then - _gitstatus_install_daemon_found 0 "$@" - return - fi - fi - - # No suitable gitstatusd exists. Need to download. - - if [ -n "$no_install" ]; then - >&2 echo "[gitstatus] error: no gitstatusd found and installation is disabled" - return 1 - fi - - local daemon="$cache_dir"/"$file" - - if [ -n "${cache_dir##/*}" ]; then - >&2 echo "[gitstatus] error: GITSTATUS_CACHE_DIR is not absolute: $cache_dir" - return 1 - fi - if [ ! -d "$cache_dir" ] && ! mkdir -p -- "$cache_dir" || [ ! -w "$cache_dir" ]; then - local dir="$cache_dir" - while true; do - if [ -e "$dir" ]; then - if [ ! -d "$dir" ]; then - >&"$e" printf 'Not a directory: \033[4;31m%s\033[0m\n' "$dir" - >&"$e" printf '\n' - >&"$e" printf 'Delete it, then restart your shell.\n' - elif [ ! -w "$dir" ]; then - >&"$e" printf 'Directory is not writable: \033[4;31m%s\033[0m\n' "$dir" - >&"$e" printf '\n' - >&"$e" printf 'Make it writable, then restart your shell.\n' - fi - break - fi - if [ "$dir" = / ] || [ "$dir" = . ]; then - break - fi - dir="$(dirname -- "$dir")" - done - return 1 - fi - - if [ -n "${TMPDIR-}" -a '(' '(' -d "${TMPDIR-}" -a -w "${TMPDIR-}" ')' -o '!' '(' -d /tmp -a -w /tmp ')' ')' ]; then - local tmp="$TMPDIR" - else - local tmp=/tmp - fi - if ! command -v mktemp >/dev/null 2>&1 || - ! tmpdir="$(command mktemp -d "$tmp"/gitstatus-install.XXXXXXXXXX)"; then - tmpdir="$tmp/gitstatus-install.tmp.$$" - if ! mkdir -p -- "$tmpdir"; then - if [ "$tmp" = /tmp ]; then - local label='directory' - else - local label='directory (\033[1mTMPDIR\033[m)' - fi - if [ ! -e "$tmp" ]; then - >&"$e" printf 'Temporary '"$label"' does not exist: \033[4;31m%s\033[0m\n' "$tmp" - >&"$e" printf '\n' - >&"$e" printf 'Create it, then restart your shell.\n' - elif [ ! -d "$tmp" ]; then - >&"$e" printf 'Not a '"$label"': \033[4;31m%s\033[0m\n' "$tmp" - >&"$e" printf '\n' - >&"$e" printf 'Make it a directory, then restart your shell.\n' - elif [ ! -w "$tmp" ]; then - >&"$e" printf 'Temporary '"$label"' is not writable: \033[4;31m%s\033[0m\n' "$tmp" - >&"$e" printf '\n' - >&"$e" printf 'Make it writable, then restart your shell.\n' - fi - return 1 - fi - fi - - if ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1; then - >&"$e" printf 'Please install \033[32mcurl\033[0m or \033[32mwget\033[0m, then restart your shell.\n' - return 1 - fi - - ( - run_cmd() { - command -v "$1" >/dev/null 2>/dev/null || return 127 - local trapped= pid die ret - trap 'trapped=1' $sig - # The only reason for suppressing stderr is that `curl -f` cannot be silenced: - # `-s` doesn't work despite what the docs say. - command "$@" 2>/dev/null & - ret="$?" - if [ "$ret" = 0 ]; then - pid="$!" - die="trap - $sig; kill -- $pid 2>/dev/null; wait -- $pid 2>/dev/null; exit 1" - trap "$die" $sig - [ -z "$trapped" ] || eval "$die" - wait -- "$pid" 2>/dev/null - ret="$?" - fi - trap - $sig - [ -z "$trapped" ] || exit - return "$ret" - } - - check_sha256() { - local data_file="$tmpdir"/"$1".tar.gz - local hash_file="$tmpdir"/"$1".tar.gz.sha256 - local hash= - { - command -v shasum >/dev/null 2>/dev/null && - run_cmd shasum -b -a 256 -- "$data_file" >"$hash_file" </dev/null && - IFS= read -r hash <"$hash_file" && - hash="${hash%% *}" && - [ ${#hash} -eq 64 ] - } || { - command -v sha256sum >/dev/null 2>/dev/null && - run_cmd sha256sum -b -- "$data_file" >"$hash_file" </dev/null && - IFS= read -r hash <"$hash_file" && - hash="${hash%% *}" && - [ ${#hash} -eq 64 ] - } || { - # Note: sha256 can be from hashalot. It's incompatible. - # Thankfully, it produces shorter output. - command -v sha256 >/dev/null 2>/dev/null && - run_cmd sha256 -- "$data_file" >"$hash_file" </dev/null && - IFS= read -r hash <"$hash_file" && - hash="${hash##* }" && - [ ${#hash} -eq 64 ] - } || { - hash= - } - [ "$1" = 1 -a -z "$hash" -o "$hash" = "$sha256" ] - } - - local url1="https://github.com/romkatv/gitstatus/releases/download/$version/$file.tar.gz" - local url2="https://gitee.com/romkatv/gitstatus/raw/release-$version/release/$file.tar.gz" - local sig='INT QUIT TERM ILL PIPE' - - fetch() { - if [ "$1" != 1 ] && command -v sleep >/dev/null 2>/dev/null; then - if ! run_cmd sleep "$1"; then - echo -n >"$tmpdir"/"$1".status - return 1 - fi - fi - local cmd part url ret - for cmd in 'curl -kfsSL' 'wget -qO-' 'curl -q -kfsSL' 'wget --no-config -qO-'; do - part=0 - while true; do - if [ "$part" = 2 ]; then - ret=1 - break - elif [ "$part" = 0 ]; then - url="$2" - else - url="$2"."$part" - fi - run_cmd $cmd -- "$url" >>"$tmpdir"/"$1".tar.gz - ret="$?" - [ "$ret" = 0 ] || break - check_sha256 "$1" && break - part=$((part+1)) - done - [ "$ret" = 0 ] && break - run_cmd rm -f -- "$tmpdir"/"$1".tar.gz && continue - ret="$?" - break - done - echo -n >"$tmpdir"/"$1".status - return "$ret" - } - - local trapped= - trap 'trapped=1' $sig - fetch 1 "$url1" & - local pid1="$!" - fetch 2 "$url2" & - local pid2="$!" - - local die="trap - $sig; kill -- $pid1 $pid2 2>/dev/null; wait -- $pid1 $pid2 2>/dev/null; exit 1" - trap "$die" $sig - [ -z "$trapped" ] || eval "$die" - - local n= - while true; do - [ -z "$dl_status" ] || eval "$dl_status" || eval "$die" - if command -v sleep >/dev/null 2>/dev/null; then - command sleep 1 - elif command -v true >/dev/null 2>/dev/null; then - command true - fi - if [ -n "$pid1" -a -e "$tmpdir"/1.status ]; then - wait -- "$pid1" 2>/dev/null - local ret="$?" - pid1= - if [ "$ret" = 0 ]; then - if [ -n "$pid2" ]; then - kill -- "$pid2" 2>/dev/null - wait -- "$pid2" 2>/dev/null - fi - n=1 - break - elif [ -z "$pid2" ]; then - break - else - die="trap - $sig; kill -- $pid2 2>/dev/null; wait -- $pid2 2>/dev/null; exit 1" - trap "$die" $sig - fi - elif [ -n "$pid2" -a -e "$tmpdir"/2.status ]; then - wait -- "$pid2" 2>/dev/null - local ret="$?" - pid2= - if [ "$ret" = 0 ]; then - if [ -n "$pid1" ]; then - kill -- "$pid1" 2>/dev/null - wait -- "$pid1" 2>/dev/null - fi - n=2 - break - elif [ -z "$pid1" ]; then - break - else - die="trap - $sig; kill -- $pid1 2>/dev/null; wait -- $pid1 2>/dev/null; exit 1" - trap "$die" $sig - fi - fi - done - - trap - $sig - - if [ -z "$n" ]; then - >&"$e" printf 'Failed to download \033[32m%s\033[0m from any mirror:\n' "$file" - >&"$e" printf '\n' - >&"$e" printf ' 1. \033[4m%s\033[0m\n' "$url1" - >&"$e" printf ' 2. \033[4m%s\033[0m\n' "$url2" - >&"$e" printf '\n' - >&"$e" printf 'Check your internet connection, then restart your shell.\n' - exit 1 - fi - - command tar -C "$tmpdir" -xzf "$tmpdir"/"$n".tar.gz || exit - - local tmpfile - if ! command -v mktemp >/dev/null 2>&1 || - ! tmpfile="$(command mktemp "$cache_dir"/gitstatusd.XXXXXXXXXX)"; then - tmpfile="$cache_dir"/gitstatusd.tmp.$$ - fi - - command mv -f -- "$tmpdir"/"$file" "$tmpfile" || exit - command mv -f -- "$tmpfile" "$cache_dir"/"$file" && exit - command rm -f -- "$cache_dir"/"$file" - command mv -f -- "$tmpfile" "$cache_dir"/"$file" && exit - command rm -f -- "$tmpfile" - exit 1 - ) - - local ret="$?" - command rm -rf -- "$tmpdir" - [ "$ret" = 0 ] || return - - _gitstatus_install_daemon_found 1 "$@" - return - done <"$gitstatus_dir"/install.info - - >&"$e" printf 'There is no prebuilt \033[32mgitstatusd\033[0m for \033[1m%s\033[0m.\n' "$uname_s $uname_m" - >&"$e" printf '\n' - >&"$e" printf 'See: \033[4mhttps://github.com/romkatv/gitstatus#compiling\033[0m\n' - return 1 -} - -if [ -z "${0##*/*}" ]; then - _gitstatus_install_main "${0%/*}" "$@" -else - _gitstatus_install_main . "$@" -fi diff --git a/.zsh/themes/powerlevel10k/gitstatus/install.info b/.zsh/themes/powerlevel10k/gitstatus/install.info deleted file mode 100644 index 45807be..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/install.info +++ /dev/null @@ -1,34 +0,0 @@ -# 3 -# -# This file is used by ./install and indirectly by shell bindings. -# -# The first line is read by powerlevel10k instant prompt. It must -# be updated whenever the content of this file changes. The actual -# value doesn't matter as long as it's unique. Consecutive integers -# work fine. - -# Official gitstatusd binaries. -uname_s_glob="cygwin_nt-10.0"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="5a8a809dcebdb6aa9b47d37e086c0485424a9d9c136770eec3c26cedf5bb75e3"; -uname_s_glob="cygwin_nt-10.0"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="c84cade0d6b86e04c27a6055f45851f6b46d6b88ba58772f7ca8ef4d295c800f"; -uname_s_glob="darwin"; uname_m_glob="arm64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="eae979e990ca37c56ee39fadd0c3f392cbbd0c6bdfb9a603010be60d9e48910a"; -uname_s_glob="darwin"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="9fd3913ec1b6b856ab6e08a99a2343f0e8e809eb6b62ca4b0963163656c668e6"; -uname_s_glob="freebsd"; uname_m_glob="amd64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="8e57ad642251e5acfa430aed82cd4ffe103db0bfadae4a15ccaf462c455d0442"; -uname_s_glob="linux"; uname_m_glob="aarch64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="32b57eb28bf6d80b280e4020a0045184f8ca897b20b570c12948aa6838673225"; -uname_s_glob="linux"; uname_m_glob="armv6l"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="4bf5a0d0a082f544a48536ad3675930d5d2cc6a8cf906710045e0788f51192b3"; -uname_s_glob="linux"; uname_m_glob="armv7l"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="2b9deb29f86c8209114b71b94fc2e1ed936a1658808a1bee46f4a82fd6a1f8cc"; -uname_s_glob="linux"; uname_m_glob="armv8l"; file="gitstatusd-${uname_s}-aarch64"; version="v1.5.4"; sha256="32b57eb28bf6d80b280e4020a0045184f8ca897b20b570c12948aa6838673225"; -uname_s_glob="linux"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="56d55e2e9a202d3072fa612d8fa1faa61243ffc86418a7fa64c2c9d9a82e0f64"; -uname_s_glob="linux"; uname_m_glob="ppc64le"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="1afd072c8c26ef6ec2d9ac11cef96c84cd6f10e859665a6ffcfb6112c758547e"; -uname_s_glob="linux"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="9633816e7832109e530c9e2532b11a1edae08136d63aa7e40246c0339b7db304"; -uname_s_glob="msys_nt-10.0"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="7f9b849fc52e7a95b9b933e25121ad5ae990a1871aad6616922ad7bcf1eebf20"; -uname_s_glob="msys_nt-10.0"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="5d3c626b5ee564dbc13ddba89752dc58b0efe925b26dbd8b2304849d9ba01732"; - -# Fallbacks to official gitstatusd binaries. -uname_s_glob="cygwin_nt-*"; uname_m_glob="i686"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.5.2"; sha256="5a8a809dcebdb6aa9b47d37e086c0485424a9d9c136770eec3c26cedf5bb75e3"; -uname_s_glob="cygwin_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="c84cade0d6b86e04c27a6055f45851f6b46d6b88ba58772f7ca8ef4d295c800f"; -uname_s_glob="mingw32_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="7f9b849fc52e7a95b9b933e25121ad5ae990a1871aad6616922ad7bcf1eebf20"; -uname_s_glob="mingw32_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="5d3c626b5ee564dbc13ddba89752dc58b0efe925b26dbd8b2304849d9ba01732"; -uname_s_glob="mingw64_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="7f9b849fc52e7a95b9b933e25121ad5ae990a1871aad6616922ad7bcf1eebf20"; -uname_s_glob="mingw64_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="5d3c626b5ee564dbc13ddba89752dc58b0efe925b26dbd8b2304849d9ba01732"; -uname_s_glob="msys_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="7f9b849fc52e7a95b9b933e25121ad5ae990a1871aad6616922ad7bcf1eebf20"; -uname_s_glob="msys_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="5d3c626b5ee564dbc13ddba89752dc58b0efe925b26dbd8b2304849d9ba01732"; diff --git a/.zsh/themes/powerlevel10k/gitstatus/mbuild b/.zsh/themes/powerlevel10k/gitstatus/mbuild deleted file mode 100644 index 40316fd..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/mbuild +++ /dev/null @@ -1,406 +0,0 @@ -#!/usr/bin/env zsh -# -# This script does not have a stable API. -# -# Usage: mbuild [-b git-ref] [kernel-arch]... -# -# Builds a bunch of gitstatusd-* binaries. Without arguments builds binaries -# for all platforms. git-ref defaults to master. -# -# Before using this script you need to set up build servers and list them -# in ~/.ssh/config. There should be a Host entry for every value of `assets` -# association defined below. VMs and cloud instances work as well as physical -# machines, including localhost. As long as the machine has been set up as -# described below and you can SSH to it without password, it should work. -# -# ===[ Build Server Setup ]=== -# -# Linux -# -# - Install docker. -# $ apt install docker.io # adjust appropriately if there is no `apt` -# $ usermod -aG docker $USER # not needed if going to build as root -# - Install git. -# $ apt install git # adjust appropriately if there is no `apt` -# -# macOS -# -# - Install compiler tools: -# $ xcode-select --install -# - Install homebrew: https://brew.sh/. -# $ bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" -# -# FreeBSD -# -# - Install git. -# $ pkg install git -# -# Windows -# -# - Disable Windows Defender (optional). -# ps> Set-MpPreference -DisableRealtimeMonitoring $true -# - Install 64-bit and 32-bit msys2: https://www.msys2.org/wiki/MSYS2-installation/. -# - Open each of them after installation, type `pacman -Syu --noconfirm` and close the window. -# - Then run in powershell while having no msys2 or cygwin windows open: -# ps> C:\msys32\autorebase.bat -# ps> C:\msys64\autorebase.bat -# - Install 64-bit and 32-bit cygwin: https://cygwin.com/install.html. -# - Choose to install 32-bit to c:/cygwin32 instead of the default c:/cygwin. -# - Select these packages: binutils, cmake, gcc-core, gcc-g++, git, make, perl, wget. -# -# IMPORTANT: Install msys2 and cygwin one at a time. -# -# IMPORTANT: msys2 builder can reboot the build machine. -# -# Option 1: OpenSSH for Windows -# -# - Install OpenSSH: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse. -# ps> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 -# ps> Start-Service sshd -# ps> Set-Service -Name sshd -StartupType 'Automatic' -# - Enable publickey authentication: https://stackoverflow.com/a/50502015/1095235. -# ps> cd $env:USERPROFILE -# ps> mkdir .ssh -# ps> notepad.exe .ssh/authorized_keys -# - Paste your public key, save, close. -# ps> icacls .ssh/authorized_keys /inheritance:r -# ps> notepad.exe C:\ProgramData\ssh\sshd_config -# - Comment out these two lines, save, close: -# # Match Group administrators -# # AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys -# ps> Restart-Service sshd -# -# Option 2: OpenSSH from WSL -# -# - Install WSL. -# - Install Ubuntu. -# - Install sshd. -# $ apt install openssh-server -# $ dpkg-reconfigure openssh-server -# $ cat >/etc/ssh/sshd_config <<\END -# ClientAliveInterval 60 -# AcceptEnv TERM LANG LC_* -# PermitRootLogin no -# AllowTcpForwarding no -# AllowAgentForwarding no -# AllowStreamLocalForwarding no -# AuthenticationMethods publickey -# END -# service ssh --full-restart -# - Add your public ssh key to ~/.ssh/authorized_keys. -# - Make `sshd` start when Windows boots. - -'emulate' '-L' 'zsh' '-o' 'no_aliases' '-o' 'err_return' -setopt no_unset extended_glob pipe_fail prompt_percent typeset_silent \ - no_prompt_subst no_prompt_bang pushd_silent warn_create_global - -if [[ $ZSH_VERSION != (5.<1->*|<6->.*) || $ZSH_VERSION == 5.4(|.*) ]]; then - print -ru2 -- "[error] unsupported zsh version: $ZSH_VERSION" - return 1 -fi - -zmodload zsh/system - -local -r git_url='https://github.com/romkatv/gitstatus.git' - -local -rA assets=( - # target kernel-arch hostname of the build machine - cygwin_nt-10.0-i686 build-windows-x86_64 - cygwin_nt-10.0-x86_64 build-windows-x86_64 - msys_nt-10.0-i686 build-windows-x86_64 - msys_nt-10.0-x86_64 build-windows-x86_64 - darwin-arm64 build-macos-arm64 - darwin-x86_64 build-macos-x86_64 - freebsd-amd64 build-freebsd-amd64 - linux-aarch64 build-linux-aarch64 - linux-armv6l build-linux-armv7l - linux-armv7l build-linux-armv7l - linux-i686 build-linux-x86_64 - linux-ppc64le build-linux-ppc64le - linux-x86_64 build-linux-x86_64 -) - -local -rA protocol=( - 'cygwin_nt-10.0-*' windows - 'msys_nt-10.0-*' windows - 'darwin-*' unix - 'freebsd-*' unix - 'linux-*' unix -) - -local -r rootdir=${ZSH_SCRIPT:h} -local -r logs=$rootdir/logs -local -r locks=$rootdir/locks -local -r binaries=$rootdir/usrbin - -function usage() { - print -r -- 'usage: mbuild [-b REF] [KERNEL-ARCH]...' -} - -local OPTARG opt git_ref=master -local -i OPTIND -while getopts ":b:h" opt; do - case $opt in - h) usage; return 0;; - b) [[ -n $OPTARG ]]; git_ref=$OPTARG;; - \?) print -ru2 -- "mbuild: invalid option: -$OPTARG" ; return 1;; - :) print -ru2 -- "mbuild: missing required argument: -$OPTARG"; return 1;; - *) print -ru2 -- "mbuild: invalid option: -$opt" ; return 1;; - esac -done - -shift $((OPTIND - 1)) - -(( $# )) || set -- ${(ko)assets} -set -- ${(u)@} - -local platform -for platform; do - if (( ! $+assets[$platform] )); then - print -ru2 -- "mbuild: invalid platform: $platform" - return 1 - fi -done - -local build=' - rm -rf gitstatus - git clone --recursive --shallow-submodules --depth=1 -b '$git_ref' '$git_url' - cd gitstatus - if command -v zsh >/dev/null 2>&1; then - sh=zsh - elif command -v dash >/dev/null 2>&1; then - sh=dash - elif command -v ash >/dev/null 2>&1; then - sh=ash - else - sh=sh - fi - $sh -x ./build -m ' - -function build-unix() { - local intro flags=(-sw) - case $2 in - linux-ppc64le) ;; - linux-*) flags+=(-d docker);; - darwin-arm64) intro='PATH="/opt/homebrew/bin:$PATH"';; - darwin-*) intro='PATH="/usr/local/bin:$PATH"';; - esac - ssh $1 -- /bin/sh -uex <<<" - $intro - cd /tmp - $build ${2##*-} ${(j: :)${(@q)flags}}" - scp $1:/tmp/gitstatus/usrbin/gitstatusd $binaries/gitstatusd-$2 -} - -function build-windows() { - local shell=$(ssh $1 'echo $0') - if [[ $shell == '$0'* ]]; then - local c='c:' - else - local c='/mnt/c' - fi - - local tmp env bin intro flags=(-w) - case $2 in - cygwin_nt-10.0-i686) bin='cygwin32/bin' ;| - cygwin_nt-10.0-x86_64) bin='cygwin64/bin' ;| - msys_nt-10.0-i686) bin='msys32/usr/bin';| - msys_nt-10.0-x86_64) bin='msys64/usr/bin';| - cygwin_nt-10.0-*) - tmp='/cygdrive/c/tmp' - ;| - msys_nt-10.0-*) - tmp='/c/tmp' - env='MSYSTEM=MSYS' - # TODO: fix this (some errors about PGP keys). - # flags+=(-s) - # intro='pacman -S --needed --noconfirm git; ' - intro+='PATH="$PATH:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl"' - while true; do - # TODO: run autorebase only when getting an error that can be fixed by autorebasing. - break - local out - out="$(ssh $1 cmd.exe "$c/${bin%%/*}/autorebase.bat" 2>&1)" - [[ $out == *"The following DLLs couldn't be rebased"* ]] || break - # Reboot to get rid of whatever is using those DLLs. - ssh $1 powershell.exe <<<'Restart-Computer -Force' || true - sleep 30 - while ! ssh $1 <<<''; do sleep 5; done - done - () { - while true; do - # TODO: fix this (some errors about PGP keys). - break - local -i fd - exec {fd}< <( - ssh $1 $c/$bin/env.exe $env c:/$bin/bash.exe -l 2>&1 <<<" - pacman -Syu --noconfirm - exit") - { - local line - while true; do - IFS= read -u $fd -r line || return 0 - if [[ $line == *"warning: terminate MSYS2"* ]]; then - # At this point the machine is hosed. A rogue process with a corrupted name - # is eating all CPU. The top SSH connection won't terminate on its own. - ssh $1 powershell.exe <<<'Restart-Computer -Force' || true - sleep 30 - while ! ssh $1 <<<''; do sleep 5; done - break - fi - done - } always { - exec {fd}<&- - kill -- -$sysparams[procsubstpid] 2>/dev/null || true - } - done - } "$@" - ;| - esac - - ssh $1 $c/$bin/env.exe $env c:/$bin/bash.exe -l <<<" - set -uex - $intro - mkdir -p -- $tmp - cd -- $tmp - $build ${2##*-} ${(j: :)${(@q)flags}} - exit" - scp $1:$c/tmp/gitstatus/usrbin/gitstatusd $binaries/gitstatusd-$2 - chmod +x $binaries/gitstatusd-$2 -} - -if [[ -r /proc/version && "$(</proc/version)" == *Microsoft* ]]; then - () { - (( $# )) || return 0 - print -ru2 -- "WARNING: lock files exist: $@" - (( $# )) && rm -- $@ - } $locks/*(N) - - function flock() { - local fd - sysopen -ro cloexec -u fd <( - exec </dev/null 2>/dev/null - ( - trap '' TERM PIPE - local fd - while true; do - sysopen -wo create,excl -u fd -- $1 && break - sleep 1 - done - exec {fd}>&- - while true; do - print || break - done - rm -- $1 - ) &! - ) - local REPLY - IFS= read -ru $fd - } -else - function flock() { - : >>$1 - zsystem flock $1 - } -fi - -function build() ( - setopt xtrace - local platform=$1 - local machine=$assets[$platform] - flock $locks/$machine - build-${protocol[(k)$platform]} $machine $platform - local tmp=gitstatusd-$platform.tmp.$$.tar.gz - ( cd -q -- $binaries; tar --owner=0 --group=0 -I 'gzip -9' -cf $tmp gitstatusd-$platform ) - mv -f -- $binaries/$tmp $binaries/gitstatusd-$platform.tar.gz - # Make sure the last command is a built-in (important for flock). - : -) - -function mbuild() { - local platform pid pids=() - for platform; do - build $platform &>$logs/$platform & - print -r -- "starting build for $platform on $assets[$platform] (pid $!)" - pids+=($platform $!) - done - local failed=() - for platform pid in $pids; do - print -rn -- "$platform => " - if wait $pid; then - print -r -- "ok" - else - print -r -- "error" - failed+=$platform - fi - done - (( $#failed )) || return 0 - print - print -r -- "Error logs:" - print - for platform in $failed; do - print -r -- " $platform => $logs/$platform" - done - return 1 -} - -# Copied from https://github.com/romkatv/run-process-tree. -function run-process-tree() { - zmodload zsh/parameter zsh/param/private || return - local -P opt=(${(kv)options[@]}) || return - local -P pat=(${patchars[@]}) || return - local -P dis_pat=(${dis_patchars[@]}) || return - emulate -L zsh -o err_return || return - setopt monitor traps_async pipe_fail no_unset - zmodload zsh/system - - if (( $# == 0 )); then - print -ru2 -- 'usage: run-process-tree command [arg]...' - return 1 - fi - - local -P stdout REPLY - exec {stdout}>&1 - { - { - local -Pi pipe - local -P gid=$sysparams[pid] - local -P sig=(ABRT EXIT HUP ILL INT PIPE QUIT TERM ZERR) - local -P trap=(trap "trap - $sig; kill -- -$sysparams[pid]" $sig) - - exec {pipe}>&1 1>&$stdout - $trap - - { - $trap - while sleep 1 && print -u $pipe .; do; done - } 2>/dev/null & - local -Pi watchdog=$! - - { - trap - ZERR - exec {pipe}>&- - enable -p -- $pat - disable -p -- $dis_pat - options=($opt zle off monitor off) - "$@" - } & - local -Pi ret - wait $! || ret=$? - - trap "exit $ret" TERM - kill $watchdog - wait $watchdog - return ret - } | while read; do; done || return - } always { - exec {stdout}>&- - } -} - -mkdir -p -- $logs $locks $binaries - -() { - run-process-tree mbuild $@ - exit -} "$@" diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/algorithm.h b/.zsh/themes/powerlevel10k/gitstatus/src/algorithm.h deleted file mode 100644 index b87b13f..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/algorithm.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_ALGORITHM_H_ -#define ROMKATV_GITSTATUS_ALGORITHM_H_ - -#include <algorithm> - -namespace gitstatus { - -// Requires: Iter is a BidirectionalIterator. -// -// Returns iterator pointing to the last value in [begin, end) that compares equal to the value, or -// begin if none compare equal. -template <class Iter, class T> -Iter FindLast(Iter begin, Iter end, const T& val) { - while (begin != end && !(*--end == val)) {} - return end; -} - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_ALGORITHM_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/arena.cc b/.zsh/themes/powerlevel10k/gitstatus/src/arena.cc deleted file mode 100644 index 4c13763..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/arena.cc +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "arena.h" - -#include <algorithm> -#include <type_traits> - -#include "bits.h" -#include "check.h" - -namespace gitstatus { - -namespace { - -size_t Clamp(size_t min, size_t val, size_t max) { return std::min(max, std::max(min, val)); } - -static const uintptr_t kSingularity = reinterpret_cast<uintptr_t>(&kSingularity); - -} // namespace - -// Triple singularity. We are all fucked. -Arena::Block Arena::g_empty_block = {kSingularity, kSingularity, kSingularity}; - -Arena::Arena(Arena::Options opt) : opt_(std::move(opt)), top_(&g_empty_block) { - CHECK(opt_.min_block_size <= opt_.max_block_size); -} - -Arena::Arena(Arena&& other) : Arena() { *this = std::move(other); } - -Arena::~Arena() { - // See comments in Makefile for the reason sized deallocation is not used. - for (const Block& b : blocks_) ::operator delete(reinterpret_cast<void*>(b.start)); -} - -Arena& Arena::operator=(Arena&& other) { - if (this != &other) { - // In case std::vector ever gets small object optimization. - size_t idx = other.reusable_ ? other.top_ - other.blocks_.data() : 0; - opt_ = other.opt_; - blocks_ = std::move(other.blocks_); - reusable_ = other.reusable_; - top_ = reusable_ ? blocks_.data() + idx : &g_empty_block; - other.blocks_.clear(); - other.reusable_ = 0; - other.top_ = &g_empty_block; - } - return *this; -} - -void Arena::Reuse(size_t num_blocks) { - reusable_ = std::min(reusable_, num_blocks); - for (size_t i = reusable_; i != blocks_.size(); ++i) { - const Block& b = blocks_[i]; - // See comments in Makefile for the reason sized deallocation is not used. - ::operator delete(reinterpret_cast<void*>(b.start)); - } - blocks_.resize(reusable_); - if (reusable_) { - top_ = blocks_.data(); - top_->tip = top_->start; - } else { - top_ = &g_empty_block; - } -} - -void Arena::AddBlock(size_t size, size_t alignment) { - if (alignment > alignof(std::max_align_t)) { - size += alignment - 1; - } else { - size = std::max(size, alignment); - } - if (size <= top_->size() && top_ < blocks_.data() + reusable_ - 1) { - assert(blocks_.front().size() == top_->size()); - ++top_; - top_->tip = top_->start; - return; - } - if (size <= opt_.max_alloc_threshold) { - size = - std::max(size, Clamp(opt_.min_block_size, NextPow2(top_->size() + 1), opt_.max_block_size)); - } - - auto p = reinterpret_cast<uintptr_t>(::operator new(size)); - blocks_.push_back(Block{p, p, p + size}); - if (reusable_) { - if (size < blocks_.front().size()) { - top_ = &blocks_.back(); - return; - } - if (size > blocks_.front().size()) reusable_ = 0; - } - std::swap(blocks_.back(), blocks_[reusable_]); - top_ = &blocks_[reusable_++]; -} - -void* Arena::AllocateSlow(size_t size, size_t alignment) { - assert(alignment && !(alignment & (alignment - 1))); - AddBlock(size, alignment); - assert(Align(top_->tip, alignment) + size <= top_->end); - return Allocate(size, alignment); -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/arena.h b/.zsh/themes/powerlevel10k/gitstatus/src/arena.h deleted file mode 100644 index 569833c..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/arena.h +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_ARENA_H_ -#define ROMKATV_GITSTATUS_ARENA_H_ - -#include <cassert> -#include <cstddef> -#include <cstdint> -#include <cstring> -#include <limits> -#include <new> -#include <type_traits> -#include <vector> - -#include "string_view.h" - -namespace gitstatus { - -// Thread-compatible. Very fast and very flexible w.r.t. allocation size and alignment. -// -// Natural API extensions: -// -// // Donates a block to the arena. When the time comes, it'll be freed with -// // free(p, size, userdata). -// void Donate(void* p, size_t size, void* userdata, void(*free)(void*, size_t, void*)); -class Arena { - public: - struct Options { - // The first call to Allocate() will allocate a block of this size. There is one exception when - // the first requested allocation size is larger than this limit. Subsequent blocks will be - // twice as large as the last until they saturate at max_block_size. - size_t min_block_size = 64; - - // Allocate blocks at most this large. There is one exception when the requested allocation - // size is larger than this limit. - size_t max_block_size = 8 << 10; - - // When the size of the first allocation in a block is larger than this threshold, the block - // size will be equal to the allocation size. This is meant to reduce memory waste when making - // many allocations with sizes slightly over max_block_size / 2. With max_alloc_threshold equal - // to max_block_size / N, the upper bound on wasted memory when making many equally-sized - // allocations is 100.0 / (N + 1) percent. When making allocations of different sizes, the upper - // bound on wasted memory is 50%. - size_t max_alloc_threshold = 1 << 10; - - // Natural extensions: - // - // void* userdata; - // void (*alloc)(size_t size, size_t alignment, void* userdata); - // void (*free)(void* p, size_t size, void* userdata); - }; - - // Requires: opt.min_block_size <= opt.max_block_size. - // - // Doesn't allocate any memory. - Arena(Options opt); - Arena() : Arena(Options()) {} - Arena(Arena&&); - ~Arena(); - - Arena& operator=(Arena&& other); - - // Requires: alignment is a power of 2. - // - // Result is never null and always aligned. If size is zero, the result may be equal to the last. - // Alignment above alignof(std::max_align_t) is supported. There is no requirement for alignment - // to be less than size or to divide it. - inline void* Allocate(size_t size, size_t alignment) { - assert(alignment && !(alignment & (alignment - 1))); - uintptr_t p = Align(top_->tip, alignment); - uintptr_t e = p + size; - if (e <= top_->end) { - top_->tip = e; - return reinterpret_cast<void*>(p); - } - return AllocateSlow(size, alignment); - } - - template <class T> - inline T* Allocate(size_t n) { - static_assert(!std::is_reference<T>(), ""); - return static_cast<T*>(Allocate(n * sizeof(T), alignof(T))); - } - - template <class T> - inline T* Allocate() { - return Allocate<T>(1); - } - - inline char* MemDup(const char* p, size_t len) { - char* res = Allocate<char>(len); - std::memcpy(res, p, len); - return res; - } - - // Copies the null-terminated string (including the trailing null character) to the arena and - // returns a pointer to the copy. - inline char* StrDup(const char* s) { - size_t len = std::strlen(s); - return MemDup(s, len + 1); - } - - // Guarantees: !StrDup(p, len)[len]. - inline char* StrDup(const char* p, size_t len) { - char* res = Allocate<char>(len + 1); - std::memcpy(res, p, len); - res[len] = 0; - return res; - } - - // Guarantees: !StrDup(s)[s.len]. - inline char* StrDup(StringView s) { - return StrDup(s.ptr, s.len); - } - - template <class... Ts> - inline char* StrCat(const Ts&... ts) { - return [&](std::initializer_list<StringView> ss) { - size_t len = 0; - for (StringView s : ss) len += s.len; - char* p = Allocate<char>(len + 1); - for (StringView s : ss) { - std::memcpy(p, s.ptr, s.len); - p += s.len; - } - *p = 0; - return p - len; - }({ts...}); - } - - // Copies/moves `val` to the arena and returns a pointer to it. - template <class T> - inline std::remove_const_t<std::remove_reference_t<T>>* Dup(T&& val) { - return DirectInit<std::remove_const_t<std::remove_reference_t<T>>>(std::forward<T>(val)); - } - - // The same as `new T{args...}` but on the arena. - template <class T, class... Args> - inline T* DirectInit(Args&&... args) { - T* res = Allocate<T>(); - ::new (const_cast<void*>(static_cast<const void*>(res))) T(std::forward<Args>(args)...); - return res; - } - - // The same as `new T(args...)` but on the arena. - template <class T, class... Args> - inline T* BraceInit(Args&&... args) { - T* res = Allocate<T>(); - ::new (const_cast<void*>(static_cast<const void*>(res))) T{std::forward<Args>(args)...}; - return res; - } - - // Tip() and TipSize() allow you to allocate the remainder of the current block. They can be - // useful if you are flexible w.r.t. the allocation size. - // - // Invariant: - // - // const void* tip = Tip(); - // void* p = Allocate(TipSize(), 1); // grab the remainder of the current block - // assert(p == tip); - const void* Tip() const { return reinterpret_cast<const void*>(top_->tip); } - size_t TipSize() const { return top_->end - top_->tip; } - - // Invalidates all allocations (without running destructors of allocated objects) and frees all - // blocks except at most the specified number of blocks. The retained blocks will be used to - // fulfil future allocation requests. - void Reuse(size_t num_blocks = std::numeric_limits<size_t>::max()); - - private: - struct Block { - size_t size() const { return end - start; } - uintptr_t start; - uintptr_t tip; - uintptr_t end; - }; - - inline static size_t Align(size_t n, size_t m) { return (n + m - 1) & ~(m - 1); }; - - void AddBlock(size_t size, size_t alignment); - bool ReuseBlock(size_t size, size_t alignment); - - __attribute__((noinline)) void* AllocateSlow(size_t size, size_t alignment); - - Options opt_; - std::vector<Block> blocks_; - // Invariant: !blocks_.empty() <= reusable_ && reusable_ <= blocks_.size(). - size_t reusable_ = 0; - // Invariant: (top_ == &g_empty_block) == blocks_.empty(). - // Invariant: blocks_.empty() || top_ == &blocks_.back() || top_ < blocks_.data() + reusable_. - Block* top_; - - static Block g_empty_block; -}; - -// Copies of ArenaAllocator use the same thread-compatible Arena without synchronization. -template <class T> -class ArenaAllocator { - public: - using value_type = T; - using pointer = T*; - using const_pointer = const T*; - using reference = T&; - using const_reference = const T&; - using size_type = size_t; - using difference_type = ptrdiff_t; - using propagate_on_container_move_assignment = std::true_type; - template <class U> - struct rebind { - using other = ArenaAllocator<U>; - }; - using is_always_equal = std::false_type; - - ArenaAllocator(Arena* arena = nullptr) : arena_(*arena) {} - - Arena& arena() const { return arena_; } - - pointer address(reference x) const { return &x; } - const_pointer address(const_reference x) const { return &x; } - pointer allocate(size_type n, const void* hint = nullptr) { return arena_.Allocate<T>(n); } - void deallocate(T* p, std::size_t n) {} - size_type max_size() const { return std::numeric_limits<size_type>::max() / sizeof(value_type); } - - template <class U, class... Args> - void construct(U* p, Args&&... args) { - ::new (const_cast<void*>(static_cast<const void*>(p))) U(std::forward<Args>(args)...); - } - - template <class U> - void destroy(U* p) { - p->~U(); - } - - bool operator==(const ArenaAllocator& other) const { return &arena_ == &other.arena_; } - bool operator!=(const ArenaAllocator& other) const { return &arena_ != &other.arena_; } - - private: - Arena& arena_; -}; - -template <class C> -struct LazyWithArena; - -template <template <class, class> class C, class T1, class A> -struct LazyWithArena<C<T1, A>> { - using type = C<T1, ArenaAllocator<typename C<T1, A>::value_type>>; -}; - -template <template <class, class, class> class C, class T1, class T2, class A> -struct LazyWithArena<C<T1, T2, A>> { - using type = C<T1, T2, ArenaAllocator<typename C<T1, T2, A>::value_type>>; -}; - -template <class C> -using WithArena = typename LazyWithArena<C>::type; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_DIR_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/bits.h b/.zsh/themes/powerlevel10k/gitstatus/src/bits.h deleted file mode 100644 index c1a7dcb..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/bits.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_BITS_H_ -#define ROMKATV_GITSTATUS_BITS_H_ - -#include <cstddef> - -namespace gitstatus { - -inline size_t NextPow2(size_t n) { return n < 2 ? 1 : (~size_t{0} >> __builtin_clzll(n - 1)) + 1; } - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_BITS_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/check.h b/.zsh/themes/powerlevel10k/gitstatus/src/check.h deleted file mode 100644 index 82dceae..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/check.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_CHECK_H_ -#define ROMKATV_GITSTATUS_CHECK_H_ - -#include "logging.h" - -#include <stdexcept> - -// The argument must be an expression convertible to bool. -// Does nothing if the expression evalutes to true. Otherwise -// it's equivalent to LOG(FATAL). -#define CHECK(cond...) \ - static_cast<void>(0), (!!(cond)) ? static_cast<void>(0) : LOG(FATAL) << #cond << ": " - -#define VERIFY(cond...) \ - static_cast<void>(0), ::gitstatus::internal_check::Thrower(!(cond)) \ - ? static_cast<void>(0) \ - : LOG(ERROR) << #cond << ": " - -namespace gitstatus { - -struct Exception : std::exception { - const char* what() const noexcept override { return "Exception"; } -}; - -namespace internal_check { - -class Thrower { - public: - Thrower(bool should_throw) : throw_(should_throw) {} - Thrower(Thrower&&) = delete; - explicit operator bool() const { return !throw_; } - ~Thrower() noexcept(false) { - if (throw_) throw Exception(); - } - - private: - bool throw_; -}; - -} // namespace internal_check - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_CHECK_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/check_dir_mtime.cc b/.zsh/themes/powerlevel10k/gitstatus/src/check_dir_mtime.cc deleted file mode 100644 index bb60ffe..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/check_dir_mtime.cc +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "check_dir_mtime.h" - -#include <fcntl.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <time.h> -#include <unistd.h> - -#include <cerrno> -#include <cstring> -#include <ctime> -#include <string> -#include <vector> - -#include "check.h" -#include "dir.h" -#include "logging.h" -#include "print.h" -#include "scope_guard.h" -#include "stat.h" - -namespace gitstatus { - -namespace { - -constexpr char kDirPrefix[] = ".gitstatus."; - -void Touch(const char* path) { - int fd = creat(path, 0444); - VERIFY(fd >= 0) << Errno(); - CHECK(!close(fd)) << Errno(); -} - -bool StatChanged(const char* path, const struct stat& prev) { - struct stat cur; - VERIFY(!lstat(path, &cur)) << Errno(); - return !StatEq(prev, cur); -} - -void RemoveStaleDirs(const char* root_dir) { - int dir_fd = open(root_dir, O_DIRECTORY | O_CLOEXEC); - if (dir_fd < 0) return; - ON_SCOPE_EXIT(&) { CHECK(!close(dir_fd)) << Errno(); }; - - Arena arena; - std::vector<char*> entries; - const std::time_t now = std::time(nullptr); - if (!ListDir(dir_fd, arena, entries, - /* precompose_unicode = */ false, - /* case_sensitive = */ true)) { - return; - } - - std::string path = root_dir; - const size_t root_dir_len = path.size(); - - for (const char* entry : entries) { - if (std::strlen(entry) < std::strlen(kDirPrefix)) continue; - if (std::memcmp(entry, kDirPrefix, std::strlen(kDirPrefix))) continue; - - struct stat st; - if (fstatat(dir_fd, entry, &st, AT_SYMLINK_NOFOLLOW)) { - LOG(WARN) << "Cannot stat " << Print(entry) << " in " << Print(root_dir) << ": " << Errno(); - continue; - } - if (MTim(st).tv_sec + 10 > now) continue; - - path.resize(root_dir_len); - path += entry; - size_t dir_len = path.size(); - - path += "/b/1"; - if (unlink(path.c_str()) && errno != ENOENT) { - LOG(WARN) << "Cannot unlink " << Print(path) << ": " << Errno(); - continue; - } - - for (const char* d : {"/a/1", "/a", "/b", ""}) { - path.resize(dir_len); - path += d; - if (rmdir(path.c_str()) && errno != ENOENT) { - LOG(WARN) << "Cannot remove " << Print(path) << ": " << Errno(); - break; - } - } - } -} - -} // namespace - -bool CheckDirMtime(const char* root_dir) { - try { - RemoveStaleDirs(root_dir); - - std::string tmp = std::string() + root_dir + kDirPrefix + "XXXXXX"; - VERIFY(mkdtemp(&tmp[0])) << Errno(); - ON_SCOPE_EXIT(&) { rmdir(tmp.c_str()); }; - - std::string a_dir = tmp + "/a"; - VERIFY(!mkdir(a_dir.c_str(), 0755)) << Errno(); - ON_SCOPE_EXIT(&) { rmdir(a_dir.c_str()); }; - struct stat a_st; - VERIFY(!lstat(a_dir.c_str(), &a_st)) << Errno(); - - std::string b_dir = tmp + "/b"; - VERIFY(!mkdir(b_dir.c_str(), 0755)) << Errno(); - ON_SCOPE_EXIT(&) { rmdir(b_dir.c_str()); }; - struct stat b_st; - VERIFY(!lstat(b_dir.c_str(), &b_st)) << Errno(); - - while (sleep(1)) { - // zzzz - } - - std::string a1 = a_dir + "/1"; - VERIFY(!mkdir(a1.c_str(), 0755)) << Errno(); - ON_SCOPE_EXIT(&) { rmdir(a1.c_str()); }; - if (!StatChanged(a_dir.c_str(), a_st)) { - LOG(WARN) << "Creating a directory doesn't change mtime of the parent: " << Print(root_dir); - return false; - } - - std::string b1 = b_dir + "/1"; - Touch(b1.c_str()); - ON_SCOPE_EXIT(&) { unlink(b1.c_str()); }; - if (!StatChanged(b_dir.c_str(), b_st)) { - LOG(WARN) << "Creating a file doesn't change mtime of the parent: " << Print(root_dir); - return false; - } - - LOG(INFO) << "All mtime checks have passes. Enabling untracked cache: " << Print(root_dir); - return true; - } catch (const Exception&) { - LOG(WARN) << "Error while testing for mtime capability: " << Print(root_dir); - return false; - } -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/check_dir_mtime.h b/.zsh/themes/powerlevel10k/gitstatus/src/check_dir_mtime.h deleted file mode 100644 index c9204e9..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/check_dir_mtime.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_CHECK_DIR_MTIME_H_ -#define ROMKATV_GITSTATUS_CHECK_DIR_MTIME_H_ - -namespace gitstatus { - -// Similar to `git update-index --test-untracked-cache` but performs all tests -// in parallel, so the total testing time is one second regardless of the number -// of tests. It also performs fewer tests because gitstatus imposes fewer -// requirements on the filesystem in order to take advantage of untracked cache. -bool CheckDirMtime(const char* root_dir); - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_CHECK_DIR_MTIME_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/dir.cc b/.zsh/themes/powerlevel10k/gitstatus/src/dir.cc deleted file mode 100644 index 39cf1c2..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/dir.cc +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "dir.h" - -#include <algorithm> -#include <atomic> -#include <cerrno> -#include <cstring> - -#include <dirent.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <unistd.h> - -#ifdef __linux__ -#include <endian.h> -#include <sys/syscall.h> -#endif - -#ifdef __APPLE__ -#include <iconv.h> -#endif - -#include "bits.h" -#include "check.h" -#include "scope_guard.h" -#include "string_cmp.h" -#include "tribool.h" - -namespace gitstatus { - -namespace { - -bool Dots(const char* name) { - if (name[0] == '.') { - if (name[1] == 0) return true; - if (name[1] == '.' && name[2] == 0) return true; - } - return false; -} - -} // namespace - -// The linux-specific implementation is about 20% faster than the generic (posix) implementation. -#ifdef __linux__ - -uint64_t Read64(const void* p) { - uint64_t res; - std::memcpy(&res, p, 8); - return res; -} - -void Write64(uint64_t x, void* p) { std::memcpy(p, &x, 8); } - -void SwapBytes(char** begin, char** end) { -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - for (; begin != end; ++begin) Write64(__builtin_bswap64(Read64(*begin)), *begin); -#elif __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ -#error "sorry, not implemented" -#endif -} - -template <bool kCaseSensitive> -void SortEntries(char** begin, char** end) { - static_assert(kCaseSensitive, ""); - SwapBytes(begin, end); - std::sort(begin, end, [](const char* a, const char* b) { - uint64_t x = Read64(a); - uint64_t y = Read64(b); - // Add 5 for good luck. - return x < y || (x == y && std::memcmp(a + 5, b + 5, 256) < 0); - }); - SwapBytes(begin, end); -} - -template <> -void SortEntries<false>(char** begin, char** end) { - std::sort(begin, end, StrLt<false>()); -} - -bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precompose_unicode, - bool case_sensitive) { - struct linux_dirent64 { - ino64_t d_ino; - off64_t d_off; - unsigned short d_reclen; - unsigned char d_type; - char d_name[]; - }; - - constexpr size_t kBufSize = 8 << 10; - const size_t orig_size = entries.size(); - - while (true) { - char* buf = static_cast<char*>(arena.Allocate(kBufSize, alignof(linux_dirent64))); - // Save 256 bytes for the rainy day. - int n = syscall(SYS_getdents64, dir_fd, buf, kBufSize - 256); - if (n < 0) { - entries.resize(orig_size); - return false; - } - for (int pos = 0; pos < n;) { - auto* ent = reinterpret_cast<linux_dirent64*>(buf + pos); - if (!Dots(ent->d_name)) entries.push_back(ent->d_name); - pos += ent->d_reclen; - } - if (n == 0) break; - // The following optimization relies on SYS_getdents64 always returning as many - // entries as would fit. This is not guaranteed by the specification and I don't - // know if this is true in practice. The optimization has no measurable effect on - // gitstatus performance, so it's turned off. - // - // if (n + sizeof(linux_dirent64) + 512 <= kBufSize) break; - } - - if (case_sensitive) { - SortEntries<true>(entries.data() + orig_size, entries.data() + entries.size()); - } else { - SortEntries<false>(entries.data() + orig_size, entries.data() + entries.size()); - } - - return true; -} - -#else // __linux__ - -namespace { - -char* DirentDup(Arena& arena, const struct dirent& ent, size_t len) { - char* p = arena.Allocate<char>(len + 2); - *p++ = ent.d_type; - std::memcpy(p, ent.d_name, len + 1); - return p; -} - -#ifdef __APPLE__ - -std::atomic<bool> g_iconv_error(true); - -Tribool IConvTry(char* inp, size_t ins, char* outp, size_t outs) { - if (outs == 0) return Tribool::kUnknown; - iconv_t ic = iconv_open("UTF-8", "UTF-8-MAC"); - if (ic == (iconv_t)-1) { - if (g_iconv_error.load(std::memory_order_relaxed) && - g_iconv_error.exchange(false, std::memory_order_relaxed)) { - LOG(ERROR) << "iconv_open(\"UTF-8\", \"UTF-8-MAC\") failed"; - } - return Tribool::kFalse; - } - ON_SCOPE_EXIT(&) { CHECK(iconv_close(ic) == 0) << Errno(); }; - --outs; - if (iconv(ic, &inp, &ins, &outp, &outs) >= 0) { - *outp = 0; - return Tribool::kTrue; - } - return errno == E2BIG ? Tribool::kUnknown : Tribool::kFalse; -} - -char* DirenvConvert(Arena& arena, struct dirent& ent, bool do_convert) { - if (!do_convert) return DirentDup(arena, ent, std::strlen(ent.d_name)); - - size_t len = 0; - do_convert = false; - for (unsigned char c; (c = ent.d_name[len]); ++len) { - if (c & 0x80) do_convert = true; - } - if (!do_convert) return DirentDup(arena, ent, len); - - size_t n = NextPow2(len + 2); - while (true) { - char* p = arena.Allocate<char>(n); - switch (IConvTry(ent.d_name, len, p + 1, n - 1)) { - case Tribool::kFalse: - return DirentDup(arena, ent, len); - case Tribool::kTrue: - *p = ent.d_type; - return p + 1; - case Tribool::kUnknown: - break; - } - n *= 2; - } -} - -#else // __APPLE__ - -char* DirenvConvert(Arena& arena, struct dirent& ent, bool do_convert) { - return DirentDup(arena, ent, std::strlen(ent.d_name)); -} - -#endif // __APPLE__ - -} // namespace - -bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precompose_unicode, - bool case_sensitive) { - const size_t orig_size = entries.size(); - dir_fd = dup(dir_fd); - if (dir_fd < 0) return false; - DIR* dir = fdopendir(dir_fd); - if (!dir) { - CHECK(!close(dir_fd)) << Errno(); - return false; - } - ON_SCOPE_EXIT(&) { CHECK(!closedir(dir)) << Errno(); }; - while (struct dirent* ent = (errno = 0, readdir(dir))) { - if (Dots(ent->d_name)) continue; - entries.push_back(DirenvConvert(arena, *ent, precompose_unicode)); - } - if (errno) { - entries.resize(orig_size); - return false; - } - StrSort(entries.data() + orig_size, entries.data() + entries.size(), case_sensitive); - return true; -} - -#endif // __linux__ - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/dir.h b/.zsh/themes/powerlevel10k/gitstatus/src/dir.h deleted file mode 100644 index 4d4cf3d..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/dir.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_DIR_H_ -#define ROMKATV_GITSTATUS_DIR_H_ - -#include <cstddef> -#include <vector> - -#include "arena.h" - -namespace gitstatus { - -// On error, leaves entries unchaged and returns false. Does not throw. -// -// On success, appends names of files from the specified directory to entries and returns true. -// Every appended entry is a null-terminated string. At -1 offset is its d_type. All elements -// point into the arena. They are sorted either by strcmp or strcasecmp depending on case_sensitive. -// -// Does not close dir_fd. -// -// There are two distinct implementations of ListDir -- one for Linux and another for everything -// else. The linux-specific implementation is 20% faster. -// -// The reason sorting is bundled with directory listing is performance on Linux. The API of -// getdents64 allows for much faster sorting than what can be done with a plain vector<char*>. -// For the POSIX implementation there is no need to bundle sorting in this way. In fact, it's -// done at the end with a generic StrSort() call. -// -// For best results, reuse the arena and vector for multiple calls to avoid heap allocations. -bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precompose_unicode, - bool case_sensitive); - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_DIR_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/git.cc b/.zsh/themes/powerlevel10k/gitstatus/src/git.cc deleted file mode 100644 index 552100c..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/git.cc +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "git.h" - -#include <cstdlib> -#include <cstring> -#include <fstream> -#include <sstream> -#include <utility> - -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include "arena.h" -#include "check.h" -#include "print.h" -#include "scope_guard.h" - -namespace gitstatus { - -const char* GitError() { - const git_error* err = git_error_last(); - return err && err->message ? err->message : "unknown error"; -} - -std::string RepoState(git_repository* repo) { - Arena arena; - StringView gitdir(git_repository_path(repo)); - - // These names mostly match gitaction in vcs_info: - // https://github.com/zsh-users/zsh/blob/master/Functions/VCS_Info/Backends/VCS_INFO_get_data_git. - auto State = [&]() { - switch (git_repository_state(repo)) { - case GIT_REPOSITORY_STATE_NONE: - return ""; - case GIT_REPOSITORY_STATE_MERGE: - return "merge"; - case GIT_REPOSITORY_STATE_REVERT: - return "revert"; - case GIT_REPOSITORY_STATE_REVERT_SEQUENCE: - return "revert-seq"; - case GIT_REPOSITORY_STATE_CHERRYPICK: - return "cherry"; - case GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE: - return "cherry-seq"; - case GIT_REPOSITORY_STATE_BISECT: - return "bisect"; - case GIT_REPOSITORY_STATE_REBASE: - return "rebase"; - case GIT_REPOSITORY_STATE_REBASE_INTERACTIVE: - return "rebase-i"; - case GIT_REPOSITORY_STATE_REBASE_MERGE: - return "rebase-m"; - case GIT_REPOSITORY_STATE_APPLY_MAILBOX: - return "am"; - case GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE: - return "am/rebase"; - } - return "action"; - }; - - auto DirExists = [&](StringView name) { - int fd = open(arena.StrCat(gitdir, "/", name), O_DIRECTORY | O_CLOEXEC); - if (fd < 0) return false; - CHECK(!close(fd)) << Errno(); - return true; - }; - - auto ReadFile = [&](StringView name) { - std::ifstream strm(arena.StrCat(gitdir, "/", name)); - std::string res; - strm >> res; - return res; - }; - - std::string next; - std::string last; - - if (DirExists("rebase-merge")) { - next = ReadFile("rebase-merge/msgnum"); - last = ReadFile("rebase-merge/end"); - } else if (DirExists("rebase-apply")) { - next = ReadFile("rebase-apply/next"); - last = ReadFile("rebase-apply/last"); - } - - std::ostringstream res; - res << State(); - if (!next.empty() && !last.empty()) res << ' ' << next << '/' << last; - return res.str(); -} - -size_t CountRange(git_repository* repo, const std::string& range) { - git_revwalk* walk = nullptr; - VERIFY(!git_revwalk_new(&walk, repo)) << GitError(); - ON_SCOPE_EXIT(=) { git_revwalk_free(walk); }; - VERIFY(!git_revwalk_push_range(walk, range.c_str())) << GitError(); - size_t res = 0; - while (true) { - git_oid oid; - switch (git_revwalk_next(&oid, walk)) { - case 0: - ++res; - break; - case GIT_ITEROVER: - return res; - default: - LOG(ERROR) << "git_revwalk_next: " << range << ": " << GitError(); - throw Exception(); - } - } -} - -size_t NumStashes(git_repository* repo) { - size_t res = 0; - auto* cb = +[](size_t index, const char* message, const git_oid* stash_id, void* payload) { - ++*static_cast<size_t*>(payload); - return 0; - }; - if (!git_stash_foreach(repo, cb, &res)) return res; - // Example error: failed to parse signature - malformed e-mail. - // See https://github.com/romkatv/powerlevel10k/issues/216. - LOG(WARN) << "git_stash_foreach: " << GitError(); - return 0; -} - -git_reference* Head(git_repository* repo) { - git_reference* symbolic = nullptr; - switch (git_reference_lookup(&symbolic, repo, "HEAD")) { - case 0: - break; - case GIT_ENOTFOUND: - return nullptr; - default: - LOG(ERROR) << "git_reference_lookup: " << GitError(); - throw Exception(); - } - - git_reference* direct = nullptr; - if (git_reference_resolve(&direct, symbolic)) { - LOG(INFO) << "Empty git repo (no HEAD)"; - return symbolic; - } - git_reference_free(symbolic); - return direct; -} - -const char* LocalBranchName(const git_reference* ref) { - CHECK(ref); - git_reference_t type = git_reference_type(ref); - switch (type) { - case GIT_REFERENCE_DIRECT: { - return git_reference_is_branch(ref) ? git_reference_shorthand(ref) : ""; - } - case GIT_REFERENCE_SYMBOLIC: { - static constexpr char kHeadPrefix[] = "refs/heads/"; - const char* target = git_reference_symbolic_target(ref); - if (!target) return ""; - size_t len = std::strlen(target); - if (len < sizeof(kHeadPrefix)) return ""; - if (std::memcmp(target, kHeadPrefix, sizeof(kHeadPrefix) - 1)) return ""; - return target + (sizeof(kHeadPrefix) - 1); - } - case GIT_REFERENCE_INVALID: - case GIT_REFERENCE_ALL: - break; - } - LOG(ERROR) << "Invalid reference type: " << type; - throw Exception(); -} - -RemotePtr GetRemote(git_repository* repo, const git_reference* local) { - git_remote* remote; - git_buf symref = {}; - if (git_branch_remote(&remote, &symref, repo, git_reference_name(local))) return nullptr; - ON_SCOPE_EXIT(&) { - git_remote_free(remote); - git_buf_free(&symref); - }; - - git_reference* ref; - if (git_reference_lookup(&ref, repo, symref.ptr)) return nullptr; - ON_SCOPE_EXIT(&) { if (ref) git_reference_free(ref); }; - - const char* branch = nullptr; - std::string name = remote ? git_remote_name(remote) : "."; - if (git_branch_name(&branch, ref)) { - branch = ""; - } else if (remote) { - VERIFY(std::strstr(branch, name.c_str()) == branch); - VERIFY(branch[name.size()] == '/'); - branch += name.size() + 1; - } - - auto res = std::make_unique<Remote>(); - res->name = std::move(name); - res->branch = branch; - res->url = remote ? (git_remote_url(remote) ?: "") : ""; - res->ref = std::exchange(ref, nullptr); - return RemotePtr(res.release()); -} - -PushRemotePtr GetPushRemote(git_repository* repo, const git_reference* local) { - git_remote* remote; - git_buf symref = {}; - if (git_branch_push_remote(&remote, &symref, repo, git_reference_name(local))) return nullptr; - ON_SCOPE_EXIT(&) { - git_remote_free(remote); - git_buf_free(&symref); - }; - - git_reference* ref; - if (git_reference_lookup(&ref, repo, symref.ptr)) return nullptr; - ON_SCOPE_EXIT(&) { if (ref) git_reference_free(ref); }; - - std::string name = remote ? git_remote_name(remote) : "."; - - auto res = std::make_unique<PushRemote>(); - res->name = std::move(name); - res->url = remote ? (git_remote_url(remote) ?: "") : ""; - res->ref = std::exchange(ref, nullptr); - return PushRemotePtr(res.release()); -} - -CommitMessage GetCommitMessage(git_repository* repo, const git_oid& id) { - git_commit* commit; - VERIFY(!git_commit_lookup(&commit, repo, &id)) << GitError(); - ON_SCOPE_EXIT(=) { git_commit_free(commit); }; - return {.encoding = git_commit_message_encoding(commit) ?: "", - .summary = git_commit_summary(commit) ?: ""}; -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/git.h b/.zsh/themes/powerlevel10k/gitstatus/src/git.h deleted file mode 100644 index b85f09f..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/git.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_GIT_H_ -#define ROMKATV_GITSTATUS_GIT_H_ - -#include <git2.h> - -#include <cstddef> -#include <memory> -#include <string> - -namespace gitstatus { - -// Not null. -const char* GitError(); - -// Not null. -std::string RepoState(git_repository* repo); - -// Returns the number of commits in the range. -size_t CountRange(git_repository* repo, const std::string& range); - -// How many stashes are there? -size_t NumStashes(git_repository* repo); - -// Returns the origin URL or an empty string. Not null. -std::string RemoteUrl(git_repository* repo, const git_reference* ref); - -// Returns reference to HEAD or null if not found. The reference is symbolic if the repo is empty -// and direct otherwise. -git_reference* Head(git_repository* repo); - -// Returns the name of the local branch, or an empty string. -const char* LocalBranchName(const git_reference* ref); - -struct CommitMessage { - // Can be empty, meaning "UTF-8". - std::string encoding; - // The first paragraph of the commit's message as a one-liner. - std::string summary; -}; - -CommitMessage GetCommitMessage(git_repository* repo, const git_oid& id); - -struct Remote { - // Tip of the remote branch. - git_reference* ref; - - // Name of the tracking remote. For example, "origin". - std::string name; - - // Name of the tracking remote branch. For example, "master". - std::string branch; - - // URL of the tracking remote. For example, "https://foo.com/repo.git". - std::string url; - - // Note: pushurl is not exposed (but could be). - - struct Free { - void operator()(const Remote* p) const { - if (p) { - if (p->ref) git_reference_free(p->ref); - delete p; - } - } - }; -}; - -struct PushRemote { - // Tip of the remote branch. - git_reference* ref; - - // Name of the tracking remote. For example, "origin". - std::string name; - - // URL of the tracking remote. For example, "https://foo.com/repo.git". - std::string url; - - // Note: pushurl is not exposed (but could be). - - struct Free { - void operator()(const PushRemote* p) const { - if (p) { - if (p->ref) git_reference_free(p->ref); - delete p; - } - } - }; -}; - -using RemotePtr = std::unique_ptr<Remote, Remote::Free>; -using PushRemotePtr = std::unique_ptr<PushRemote, PushRemote::Free>; - -RemotePtr GetRemote(git_repository* repo, const git_reference* local); -PushRemotePtr GetPushRemote(git_repository* repo, const git_reference* local); - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_GIT_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/gitstatus.cc b/.zsh/themes/powerlevel10k/gitstatus/src/gitstatus.cc deleted file mode 100644 index 81399ea..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/gitstatus.cc +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include <time.h> - -#include <cstddef> -#include <future> -#include <string> - -#include <git2.h> - -#include "check.h" -#include "git.h" -#include "logging.h" -#include "options.h" -#include "print.h" -#include "repo.h" -#include "repo_cache.h" -#include "request.h" -#include "response.h" -#include "scope_guard.h" -#include "thread_pool.h" -#include "timer.h" - -namespace gitstatus { -namespace { - -using namespace std::string_literals; - -void Truncate(std::string& s, size_t max_len) { - if (s.size() > max_len) s.resize(max_len); -} - -void ProcessRequest(const Options& opts, RepoCache& cache, Request req) { - Timer timer; - ON_SCOPE_EXIT(&) { timer.Report("request"); }; - - ResponseWriter resp(req.id); - Repo* repo = cache.Open(req.dir, req.from_dotgit); - if (!repo) return; - - git_config* cfg; - VERIFY(!git_repository_config(&cfg, repo->repo())) << GitError(); - ON_SCOPE_EXIT(=) { git_config_free(cfg); }; - VERIFY(!git_config_refresh(cfg)) << GitError(); - - // Symbolic reference if and only if the repo is empty. - git_reference* head = Head(repo->repo()); - if (!head) return; - ON_SCOPE_EXIT(=) { git_reference_free(head); }; - - // Null if and only if the repo is empty. - const git_oid* head_target = git_reference_target(head); - - // Looking up tags may take some time. Do it in the background while we check for stuff. - // Note that GetTagName() doesn't access index, so it'll overlap with index reading and - // parsing. - std::future<std::string> tag = repo->GetTagName(head_target); - ON_SCOPE_EXIT(&) { - if (tag.valid()) { - try { - tag.wait(); - } catch (const Exception&) { - } - } - }; - - // Repository working directory. Absolute; no trailing slash. E.g., "/home/romka/gitstatus". - StringView workdir(git_repository_workdir(repo->repo())); - if (workdir.len == 0) return; - if (workdir.len > 1 && workdir.ptr[workdir.len - 1] == '/') --workdir.len; - resp.Print(workdir); - - // Revision. Either 40 hex digits or an empty string for empty repo. - resp.Print(head_target ? git_oid_tostr_s(head_target) : ""); - - // Local branch name (e.g., "master") or empty string if not on a branch. - resp.Print(LocalBranchName(head)); - - // Remote tracking branch or null. - RemotePtr remote = GetRemote(repo->repo(), head); - - // Tracking remote branch name (e.g., "master") or empty string if there is no tracking remote. - resp.Print(remote ? remote->branch : ""); - - // Tracking remote name (e.g., "origin") or empty string if there is no tracking remote. - resp.Print(remote ? remote->name : ""); - - // Tracking remote URL or empty string if there is no tracking remote. - resp.Print(remote ? remote->url : ""); - - // Repository state, A.K.A. action. For example, "merge". - resp.Print(RepoState(repo->repo())); - - IndexStats stats; - // Look for staged, unstaged and untracked. This is where most of the time is spent. - if (req.diff) stats = repo->GetIndexStats(head_target, cfg); - - // The number of files in the index. - resp.Print(stats.index_size); - // The number of staged changes. At most opts.max_num_staged. - resp.Print(stats.num_staged); - // The number of unstaged changes. At most opts.max_num_unstaged. 0 if index is too large. - resp.Print(stats.num_unstaged); - // The number of conflicted changes. At most opts.max_num_conflicted. 0 if index is too large. - resp.Print(stats.num_conflicted); - // The number of untracked changes. At most opts.max_num_untracked. 0 if index is too large. - resp.Print(stats.num_untracked); - - if (remote && remote->ref) { - const char* ref = git_reference_name(remote->ref); - // Number of commits we are ahead of upstream. Non-negative integer. - resp.Print(CountRange(repo->repo(), ref + "..HEAD"s)); - // Number of commits we are behind upstream. Non-negative integer. - resp.Print(CountRange(repo->repo(), "HEAD.."s + ref)); - } else { - resp.Print("0"); - resp.Print("0"); - } - - // Number of stashes. Non-negative integer. - resp.Print(NumStashes(repo->repo())); - - // Tag that points to HEAD (e.g., "v4.2") or empty string if there aren't any. The same as - // `git describe --tags --exact-match`. - resp.Print(tag.get()); - - // The number of unstaged deleted files. At most stats.num_unstaged. - resp.Print(stats.num_unstaged_deleted); - // The number of staged new files. At most stats.num_staged. - resp.Print(stats.num_staged_new); - // The number of staged deleted files. At most stats.num_staged. - resp.Print(stats.num_staged_deleted); - - // Push remote or null. - PushRemotePtr push_remote = GetPushRemote(repo->repo(), head); - - // Push remote name (e.g., "origin") or empty string if there is no push remote. - resp.Print(push_remote ? push_remote->name : ""); - - // Push remote URL or empty string if there is no push remote. - resp.Print(push_remote ? push_remote->url : ""); - - if (push_remote && push_remote->ref) { - const char* ref = git_reference_name(push_remote->ref); - // Number of commits we are ahead of push remote. Non-negative integer. - resp.Print(CountRange(repo->repo(), ref + "..HEAD"s)); - // Number of commits we are behind upstream. Non-negative integer. - resp.Print(CountRange(repo->repo(), "HEAD.."s + ref)); - } else { - resp.Print("0"); - resp.Print("0"); - } - - // The number of files in the index with skip-worktree bit set. - resp.Print(stats.num_skip_worktree); - // The number of files in the index with assume-unchanged bit set. - resp.Print(stats.num_assume_unchanged); - - CommitMessage msg = head_target ? GetCommitMessage(repo->repo(), *head_target) : CommitMessage(); - Truncate(msg.summary, opts.max_commit_summary_length); - resp.Print(msg.encoding); - resp.Print(msg.summary); - - resp.Dump("with git status"); -} - -int GitStatus(int argc, char** argv) { - tzset(); - Options opts = ParseOptions(argc, argv); - g_min_log_level = opts.log_level; - for (int i = 0; i != argc; ++i) LOG(INFO) << "argv[" << i << "]: " << Print(argv[i]); - RequestReader reader(fileno(stdin), opts.lock_fd, opts.parent_pid); - RepoCache cache(opts); - - InitGlobalThreadPool(opts.num_threads); - git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 0); - git_libgit2_opts(GIT_OPT_DISABLE_INDEX_CHECKSUM_VERIFICATION, 1); - git_libgit2_opts(GIT_OPT_DISABLE_INDEX_FILEPATH_VALIDATION, 1); - git_libgit2_opts(GIT_OPT_DISABLE_READNG_PACKED_TAGS, 1); - git_libgit2_init(); - - while (true) { - try { - Request req; - if (reader.ReadRequest(req)) { - LOG(INFO) << "Processing request: " << req; - try { - ProcessRequest(opts, cache, req); - LOG(INFO) << "Successfully processed request: " << req; - } catch (const Exception&) { - LOG(ERROR) << "Error processing request: " << req; - } - } else if (opts.repo_ttl >= Duration()) { - cache.Free(Clock::now() - opts.repo_ttl); - } - } catch (const Exception&) { - } - } -} - -} // namespace -} // namespace gitstatus - -int main(int argc, char** argv) { gitstatus::GitStatus(argc, argv); } diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/index.cc b/.zsh/themes/powerlevel10k/gitstatus/src/index.cc deleted file mode 100644 index 4d66876..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/index.cc +++ /dev/null @@ -1,456 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "index.h" - -#include <dirent.h> -#include <fcntl.h> -#include <unistd.h> - -#include <algorithm> -#include <condition_variable> -#include <cstdint> -#include <cstring> -#include <iomanip> -#include <iterator> -#include <mutex> -#include <stack> - -#include "algorithm.h" -#include "check.h" -#include "dir.h" -#include "git.h" -#include "index.h" -#include "print.h" -#include "scope_guard.h" -#include "stat.h" -#include "string_cmp.h" -#include "thread_pool.h" - -namespace gitstatus { - -namespace { - -void CommonDir(Str<> str, const char* a, const char* b, size_t* dir_len, size_t* dir_depth) { - *dir_len = 0; - *dir_depth = 0; - for (size_t i = 1; str.Eq(*a, *b) && *a; ++i, ++a, ++b) { - if (*a == '/') { - *dir_len = i; - ++*dir_depth; - } - } -} - -size_t Weight(const IndexDir& dir) { return 1 + dir.subdirs.size() + dir.files.size(); } - -bool MTimeEq(const git_index_time& index, const struct timespec& workdir) { - if (index.seconds != workdir.tv_sec) return false; - if (int64_t{index.nanoseconds} == workdir.tv_nsec) return true; -#ifdef GITSTATUS_ZERO_NSEC - return index.nanoseconds == 0; -#else - return false; -#endif -} - -bool IsModified(const git_index_entry* entry, const struct stat& st, const RepoCaps& caps) { - mode_t mode = st.st_mode; - if (S_ISREG(mode)) { - if (!caps.has_symlinks && S_ISLNK(entry->mode)) { - mode = entry->mode; - } else if (!caps.trust_filemode) { - mode = entry->mode; - } else { - mode = S_IFREG | (mode & 0100 ? 0755 : 0644); - } - } else { - mode &= S_IFMT; - } - - bool res = false; - -#define COND(field, cond...) \ - if (cond) { \ - } else \ - res = true, \ - LOG(DEBUG) << "Dirty candidate (modified): " << Print(entry->path) << ": " #field " " - - COND(ino, !entry->ino || entry->ino == static_cast<std::uint32_t>(st.st_ino)) - << entry->ino << " => " << static_cast<std::uint32_t>(st.st_ino); - - COND(stage, GIT_INDEX_ENTRY_STAGE(entry) == 0) << "=> " << GIT_INDEX_ENTRY_STAGE(entry); - COND(fsize, int64_t{entry->file_size} == st.st_size) << entry->file_size << " => " << st.st_size; - COND(mtime, MTimeEq(entry->mtime, MTim(st))) << Print(entry->mtime) << " => " << Print(MTim(st)); - COND(mode, entry->mode == mode) << std::oct << entry->mode << " => " << std::oct << mode; - -#undef COND - - return res; -} - -int OpenDir(int parent_fd, const char* name) { - return openat(parent_fd, name, O_RDONLY | O_DIRECTORY | O_CLOEXEC); -} - -void OpenTail(int* fds, size_t nfds, int root_fd, StringView dirname, Arena& arena) { - CHECK(fds && nfds && root_fd >= 0); - std::fill(fds, fds + nfds, -1); - if (!dirname.len) return; - CHECK(dirname.len > 1); - CHECK(dirname.ptr[0] != '/'); - CHECK(dirname.ptr[dirname.len - 1] == '/'); - - char* begin = arena.StrDup(dirname.ptr, dirname.len - 1); - WithArena<std::vector<const char*>> subdirs(&arena); - subdirs.reserve(nfds + 1); - - for (char* sep = begin + dirname.len - 1; subdirs.size() < nfds;) { - sep = FindLast(begin, sep, '/'); - if (sep == begin) break; - *sep = 0; - subdirs.push_back(sep + 1); - } - subdirs.push_back(begin); - if (subdirs.size() < nfds + 1) subdirs.push_back("."); - CHECK(subdirs.size() <= nfds + 1); - - for (size_t i = subdirs.size(); i != 1; --i) { - const char* path = subdirs[i - 1]; - if ((root_fd = OpenDir(root_fd, path)) < 0) { - for (; i != subdirs.size(); ++i) { - CHECK(!close(fds[i - 1])) << Errno(); - fds[i - 1] = -1; - } - return; - } - fds[i - 2] = root_fd; - } -} - -std::vector<const char*> ScanDirs(git_index* index, int root_fd, IndexDir* const* begin, - IndexDir* const* end, const RepoCaps& caps, - const ScanOpts& opts) { - const Str<> str(caps.case_sensitive); - - Arena arena; - std::vector<const char*> dirty_candidates; - std::vector<char*> entries; - entries.reserve(128); - - auto AddCandidate = [&](const char* kind, const char* path) { - if (kind) LOG(DEBUG) << "Dirty candidate (" << kind << "): " << Print(path); - dirty_candidates.push_back(path); - }; - - constexpr ssize_t kDirStackSize = 5; - int dir_fd[kDirStackSize]; - std::fill(std::begin(dir_fd), std::end(dir_fd), -1); - auto Close = [](int& fd) { - if (fd >= 0) { - CHECK(!close(fd)) << Errno(); - fd = -1; - } - }; - auto CloseAll = [&] { std::for_each(std::begin(dir_fd), std::end(dir_fd), Close); }; - ON_SCOPE_EXIT(&) { CloseAll(); }; - if (begin != end) OpenTail(dir_fd, kDirStackSize, root_fd, (*begin)->path, arena); - - for (IndexDir* const* it = begin; it != end; ++it) { - IndexDir& dir = **it; - - auto Basename = [&](const git_index_entry* e) { return e->path + dir.path.len; }; - - auto AddUnmached = [&](StringView basename) { - if (!basename.len) { - dir.st = {}; - dir.unmatched.clear(); - dir.arena.Reuse(); - } else if (str.Eq(basename, StringView(".git/"))) { - return; - } - char* path = dir.arena.StrCat(dir.path, basename); - dir.unmatched.push_back(path); - AddCandidate(basename.len ? "new" : "unreadable", path); - }; - - auto StatFiles = [&]() { - struct stat st; - for (const git_index_entry* file : dir.files) { - if (fstatat(*dir_fd, Basename(file), &st, AT_SYMLINK_NOFOLLOW)) { - AddCandidate(errno == ENOENT ? "deleted" : "unreadable", file->path); - } else if (IsModified(file, st, caps)) { - AddCandidate(nullptr, file->path); - } - } - }; - - ssize_t d = 0; - if ((it == begin || (d = it[-1]->depth + 1 - dir.depth) < kDirStackSize) && dir_fd[d] >= 0) { - CHECK(d >= 0); - int fd = OpenDir(dir_fd[d], arena.StrDup(dir.basename.ptr, dir.basename.len)); - for (ssize_t i = 0; i != d; ++i) Close(dir_fd[i]); - std::rotate(dir_fd, dir_fd + (d ? d : kDirStackSize) - 1, dir_fd + kDirStackSize); - Close(*dir_fd); - *dir_fd = fd; - } else { - CloseAll(); - if (dir.path.len) { - CHECK(dir.path.ptr[0] != '/'); - CHECK(dir.path.ptr[dir.path.len - 1] == '/'); - *dir_fd = OpenDir(root_fd, arena.StrDup(dir.path.ptr, dir.path.len - 1)); - } else { - VERIFY((*dir_fd = dup(root_fd)) >= 0) << Errno(); - } - } - if (*dir_fd < 0) { - CloseAll(); - AddUnmached(""); - continue; - } - - if (!opts.include_untracked) { - StatFiles(); - continue; - } - - if (opts.untracked_cache != Tribool::kFalse) { - struct stat st; - if (fstat(*dir_fd, &st)) { - AddUnmached(""); - continue; - } - if (opts.untracked_cache == Tribool::kTrue && StatEq(st, dir.st)) { - StatFiles(); - for (const char* path : dir.unmatched) AddCandidate("new", path); - continue; - } - dir.st = st; - } - - entries.clear(); - arena.Reuse(); - if (!ListDir(*dir_fd, arena, entries, caps.precompose_unicode, caps.case_sensitive)) { - AddUnmached(""); - continue; - } - dir.unmatched.clear(); - dir.arena.Reuse(); - - const git_index_entry* const* file = dir.files.data(); - const git_index_entry* const* file_end = file + dir.files.size(); - const StringView* subdir = dir.subdirs.data(); - const StringView* subdir_end = subdir + dir.subdirs.size(); - - for (char* entry : entries) { - bool matched = false; - - for (; file != file_end; ++file) { - int cmp = str.Cmp(Basename(*file), entry); - if (cmp < 0) { - AddCandidate("deleted", (*file)->path); - } else if (cmp == 0) { - struct stat st; - if (fstatat(*dir_fd, entry, &st, AT_SYMLINK_NOFOLLOW)) { - AddCandidate("unreadable", (*file)->path); - } else if (IsModified(*file, st, caps)) { - AddCandidate(nullptr, (*file)->path); - } - matched = true; - ++file; - break; - } else { - break; - } - } - - if (matched) continue; - - for (; subdir != subdir_end; ++subdir) { - int cmp = str.Cmp(*subdir, entry); - if (cmp > 0) break; - if (cmp == 0) { - matched = true; - ++subdir; - break; - } - } - - if (!matched) { - StringView basename(entry); - if (entry[-1] == DT_DIR) entry[basename.len++] = '/'; - AddUnmached(basename); - } - } - - for (; file != file_end; ++file) AddCandidate("deleted", (*file)->path); - } - - return dirty_candidates; -} - -} // namespace - -RepoCaps::RepoCaps(git_repository* repo, git_index* index) { - trust_filemode = git_index_is_filemode_trustworthy(index); - has_symlinks = git_index_supports_symlinks(index); - case_sensitive = git_index_is_case_sensitive(index); - precompose_unicode = git_index_precompose_unicode(index); - LOG(DEBUG) << "Repository capabilities for " << Print(git_repository_workdir(repo)) << ": " - << "is_filemode_trustworthy = " << std::boolalpha << trust_filemode << ", " - << "index_supports_symlinks = " << std::boolalpha << has_symlinks << ", " - << "index_is_case_sensitive = " << std::boolalpha << case_sensitive << ", " - << "precompose_unicode = " << std::boolalpha << precompose_unicode; -} - -Index::Index(git_repository* repo, git_index* index) - : dirs_(&arena_), - splits_(&arena_), - git_index_(index), - root_dir_(git_repository_workdir(repo)), - caps_(repo, index) { - size_t total_weight = InitDirs(index); - InitSplits(total_weight); -} - -size_t Index::InitDirs(git_index* index) { - const Str<> str(git_index_is_case_sensitive(index)); - const size_t index_size = git_index_entrycount(index); - dirs_.reserve(index_size / 8); - std::stack<IndexDir*> stack; - stack.push(arena_.DirectInit<IndexDir>(&arena_)); - - size_t total_weight = 0; - auto PopDir = [&] { - CHECK(!stack.empty()); - IndexDir* top = stack.top(); - CHECK(top->depth + 1 == stack.size()); - if (!std::is_sorted(top->subdirs.begin(), top->subdirs.end(), str.Lt)) { - StrSort(top->subdirs.begin(), top->subdirs.end(), str.case_sensitive); - } - total_weight += Weight(*top); - dirs_.push_back(top); - stack.pop(); - }; - - for (size_t i = 0; i != index_size; ++i) { - const git_index_entry* entry = git_index_get_byindex_no_sort(index, i); - IndexDir* prev = stack.top(); - size_t common_len, common_depth; - CommonDir(str, prev->path.ptr, entry->path, &common_len, &common_depth); - CHECK(common_depth <= prev->depth); - - for (size_t i = common_depth; i != prev->depth; ++i) PopDir(); - - for (const char* p = entry->path + common_len; (p = std::strchr(p, '/')); ++p) { - IndexDir* top = stack.top(); - StringView subdir(entry->path + top->path.len, p); - top->subdirs.push_back(subdir); - IndexDir* dir = arena_.DirectInit<IndexDir>(&arena_); - dir->path = StringView(entry->path, p - entry->path + 1); - dir->basename = subdir; - dir->depth = stack.size(); - CHECK(dir->path.ptr[dir->path.len - 1] == '/'); - stack.push(dir); - } - - CHECK(!stack.empty()); - IndexDir* dir = stack.top(); - dir->files.push_back(entry); - } - - CHECK(!stack.empty()); - do { - PopDir(); - } while (!stack.empty()); - std::reverse(dirs_.begin(), dirs_.end()); - - return total_weight; -} - -void Index::InitSplits(size_t total_weight) { - constexpr size_t kMinShardWeight = 512; - const size_t kNumShards = 16 * GlobalThreadPool()->num_threads(); - const size_t shard_weight = std::max(kMinShardWeight, total_weight / kNumShards); - - splits_.reserve(kNumShards + 1); - splits_.push_back(0); - - for (size_t i = 0, w = 0; i != dirs_.size(); ++i) { - w += Weight(*dirs_[i]); - if (w >= shard_weight) { - w = 0; - splits_.push_back(i + 1); - } - } - - if (splits_.back() != dirs_.size()) splits_.push_back(dirs_.size()); - CHECK(splits_.size() <= kNumShards + 1); - CHECK(std::is_sorted(splits_.begin(), splits_.end())); - CHECK(std::adjacent_find(splits_.begin(), splits_.end()) == splits_.end()); -} - -std::vector<const char*> Index::GetDirtyCandidates(const ScanOpts& opts) { - int root_fd = open(root_dir_, O_RDONLY | O_DIRECTORY | O_CLOEXEC); - VERIFY(root_fd >= 0); - ON_SCOPE_EXIT(&) { CHECK(!close(root_fd)) << Errno(); }; - - CHECK(!splits_.empty()); - - std::mutex mutex; - std::condition_variable cv; - size_t inflight = splits_.size() - 1; - bool error = false; - std::vector<const char*> res; - - for (size_t i = 0; i != splits_.size() - 1; ++i) { - size_t from = splits_[i]; - size_t to = splits_[i + 1]; - - GlobalThreadPool()->Schedule([&, from, to]() { - ON_SCOPE_EXIT(&) { - std::unique_lock<std::mutex> lock(mutex); - CHECK(inflight); - if (--inflight == 0) cv.notify_one(); - }; - try { - std::vector<const char*> candidates = - ScanDirs(git_index_, root_fd, dirs_.data() + from, dirs_.data() + to, caps_, opts); - if (!candidates.empty()) { - std::unique_lock<std::mutex> lock(mutex); - res.insert(res.end(), candidates.begin(), candidates.end()); - } - } catch (const Exception&) { - std::unique_lock<std::mutex> lock(mutex); - error = true; - } - }); - } - - { - std::unique_lock<std::mutex> lock(mutex); - while (inflight) cv.wait(lock); - } - - VERIFY(!error); - StrSort(res.begin(), res.end(), git_index_is_case_sensitive(git_index_)); - auto StrEq = [](const char* a, const char* b) { return !strcmp(a, b); }; - res.erase(std::unique(res.begin(), res.end(), StrEq), res.end()); - return res; -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/index.h b/.zsh/themes/powerlevel10k/gitstatus/src/index.h deleted file mode 100644 index bbf9567..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/index.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_INDEX_H_ -#define ROMKATV_GITSTATUS_INDEX_H_ - -#include <sys/stat.h> - -#include <git2.h> - -#include <cstddef> -#include <string> -#include <vector> - -#include "arena.h" -#include "options.h" -#include "string_view.h" -#include "tribool.h" - -namespace gitstatus { - -struct RepoCaps { - RepoCaps(git_repository* repo, git_index* index); - - bool trust_filemode; - bool has_symlinks; - bool case_sensitive; - bool precompose_unicode; -}; - -struct ScanOpts { - bool include_untracked; - Tribool untracked_cache; -}; - -struct IndexDir { - explicit IndexDir(Arena* arena) : files(arena), subdirs(arena) {} - - StringView path; - StringView basename; - size_t depth = 0; - struct stat st = {}; - WithArena<std::vector<const git_index_entry*>> files; - WithArena<std::vector<StringView>> subdirs; - - Arena arena; - std::vector<const char*> unmatched; -}; - -class Index { - public: - Index(git_repository* repo, git_index* index); - - std::vector<const char*> GetDirtyCandidates(const ScanOpts& opts); - - private: - size_t InitDirs(git_index* index); - void InitSplits(size_t total_weight); - - Arena arena_; - WithArena<std::vector<IndexDir*>> dirs_; - WithArena<std::vector<size_t>> splits_; - git_index* git_index_; - const char* root_dir_; - RepoCaps caps_; -}; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_GIT_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/logging.cc b/.zsh/themes/powerlevel10k/gitstatus/src/logging.cc deleted file mode 100644 index fb9ac9e..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/logging.cc +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "logging.h" - -#include <pthread.h> -#include <time.h> - -#include <cerrno> -#include <cstdio> -#include <cstring> -#include <ctime> -#include <mutex> -#include <string> - -namespace gitstatus { - -namespace internal_logging { - -namespace { - -std::mutex g_log_mutex; - -constexpr char kHexLower[] = {'0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - -void FormatThreadId(char (&out)[2 * sizeof(std::uintptr_t) + 1]) { - std::uintptr_t tid = (std::uintptr_t)pthread_self(); - char* p = out + sizeof(out) - 1; - *p = 0; - do { - --p; - *p = kHexLower[tid & 0xF]; - tid >>= 4; - } while (p != out); -} - -void FormatCurrentTime(char (&out)[64]) { - std::time_t time = std::time(nullptr); - struct tm tm; - if (localtime_r(&time, &tm) != &tm || std::strftime(out, sizeof(out), "%F %T", &tm) == 0) { - std::strcpy(out, "undef"); - } -} - -} // namespace - -LogStreamBase::LogStreamBase(const char* file, int line, LogLevel lvl) - : errno_(errno), file_(file), line_(line), lvl_(LogLevelStr(lvl)) { - strm_ = std::make_unique<std::ostringstream>(); -} - -void LogStreamBase::Flush() { - { - std::string msg = strm_->str(); - char tid[2 * sizeof(std::uintptr_t) + 1]; - FormatThreadId(tid); - char time[64]; - FormatCurrentTime(time); - - std::unique_lock<std::mutex> lock(g_log_mutex); - std::fprintf(stderr, "[%s %s %s %s:%d] %s\n", time, tid, lvl_, file_, line_, msg.c_str()); - } - strm_.reset(); - errno = errno_; -} - -std::ostream& operator<<(std::ostream& strm, Errno e) { - // GNU C Library uses a buffer of 1024 characters for strerror(). Mimic to avoid truncations. - char buf[1024]; - auto x = strerror_r(e.err, buf, sizeof(buf)); - // There are two versions of strerror_r with different semantics. We can figure out which - // one we've got by looking at the result type. - if (std::is_same<decltype(x), int>::value) { - // XSI-compliant version. - strm << (x ? "unknown error" : buf); - } else if (std::is_same<decltype(x), char*>::value) { - // GNU-specific version. - strm << x; - } else { - // Something else entirely. - strm << "unknown error"; - } - return strm; -} - -} // namespace internal_logging - -LogLevel g_min_log_level = INFO; - -const char* LogLevelStr(LogLevel lvl) { - switch (lvl) { - case DEBUG: - return "DEBUG"; - case INFO: - return "INFO"; - case WARN: - return "WARN"; - case ERROR: - return "ERROR"; - case FATAL: - return "FATAL"; - } - return "UNKNOWN"; -} - -bool ParseLogLevel(const char* s, LogLevel& lvl) { - if (!s) - return false; - else if (!std::strcmp(s, "DEBUG")) - lvl = DEBUG; - else if (!std::strcmp(s, "INFO")) - lvl = INFO; - else if (!std::strcmp(s, "WARN")) - lvl = WARN; - else if (!std::strcmp(s, "ERROR")) - lvl = ERROR; - else if (!std::strcmp(s, "FATAL")) - lvl = FATAL; - else - return false; - return true; -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/logging.h b/.zsh/themes/powerlevel10k/gitstatus/src/logging.h deleted file mode 100644 index 6ddb2e1..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/logging.h +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_LOGGING_H_ -#define ROMKATV_GITSTATUS_LOGGING_H_ - -#include <cstdlib> -#include <memory> -#include <ostream> -#include <sstream> - -#define LOG(severity) LOG_I(severity) - -#define LOG_I(severity) \ - (::gitstatus::severity < ::gitstatus::g_min_log_level) \ - ? static_cast<void>(0) \ - : ::gitstatus::internal_logging::Assignable() = \ - ::gitstatus::internal_logging::LogStream<::gitstatus::severity>(__FILE__, __LINE__, \ - ::gitstatus::severity) \ - .ref() - -namespace gitstatus { - -enum LogLevel { - DEBUG, - INFO, - WARN, - ERROR, - FATAL, -}; - -const char* LogLevelStr(LogLevel lvl); -bool ParseLogLevel(const char* s, LogLevel& lvl); - -extern LogLevel g_min_log_level; - -namespace internal_logging { - -struct Assignable { - template <class T> - void operator=(const T&) const {} -}; - -class LogStreamBase { - public: - LogStreamBase(const char* file, int line, LogLevel lvl); - - LogStreamBase& ref() { return *this; } - std::ostream& strm() { return *strm_; } - int stashed_errno() const { return errno_; } - - protected: - void Flush(); - - private: - int errno_; - const char* file_; - int line_; - const char* lvl_; - std::unique_ptr<std::ostringstream> strm_; -}; - -template <LogLevel> -class LogStream : public LogStreamBase { - public: - using LogStreamBase::LogStreamBase; - ~LogStream() { this->Flush(); } -}; - -template <> -class LogStream<FATAL> : public LogStreamBase { - public: - using LogStreamBase::LogStreamBase; - ~LogStream() __attribute__((noreturn)) { - this->Flush(); - std::abort(); - } -}; - -template <class T> -LogStreamBase& operator<<(LogStreamBase& strm, const T& val) { - strm.strm() << val; - return strm; -} - -inline LogStreamBase& operator<<(LogStreamBase& strm, std::ostream& (*manip)(std::ostream&)) { - strm.strm() << manip; - return strm; -} - -struct Errno { - int err; -}; - -std::ostream& operator<<(std::ostream& strm, Errno e); - -struct StashedErrno {}; - -inline LogStreamBase& operator<<(LogStreamBase& strm, StashedErrno) { - return strm << Errno{strm.stashed_errno()}; -} - -} // namespace internal_logging - -inline internal_logging::Errno Errno(int err) { return {err}; } -inline internal_logging::StashedErrno Errno() { return {}; } - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_LOGGING_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/options.cc b/.zsh/themes/powerlevel10k/gitstatus/src/options.cc deleted file mode 100644 index 46f3845..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/options.cc +++ /dev/null @@ -1,362 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "options.h" - -#include <fnmatch.h> -#include <getopt.h> -#include <unistd.h> - -#include <algorithm> -#include <climits> -#include <cstdlib> -#include <cstring> -#include <iostream> - -#include "print.h" - -namespace gitstatus { - -namespace { - -long ParseLong(const char* s) { - errno = 0; - char* end = nullptr; - long res = std::strtol(s, &end, 10); - if (*end || end == s || errno) { - std::cerr << "gitstatusd: not an integer: " << s << std::endl; - std::exit(10); - } - return res; -} - -long ParseInt(const char* s) { - long res = ParseLong(s); - if (res < INT_MIN || res > INT_MAX) { - std::cerr << "gitstatusd: integer out of bounds: " << s << std::endl; - std::exit(10); - } - return res; -} - -size_t ParseSizeT(const char* s) { - static_assert(sizeof(long) <= sizeof(size_t), ""); - long res = ParseLong(s); - return res >= 0 ? res : -1; -} - -void PrintUsage() { - std::cout << "Usage: gitstatusd [OPTION]...\n" - << "Print machine-readable status of the git repos for directores in stdin.\n" - << "\n" - << "OPTIONS\n" - << " -l, --lock-fd=NUM [default=-1]\n" - << " If non-negative, check whether the specified file descriptor is locked when\n" - << " not receiving any requests for one second; exit if it isn't locked.\n" - << "\n" - << " -p, --parent-pid=NUM [default=-1]\n" - << " If non-negative, send signal 0 to the specified PID when not receiving any\n" - << " requests for one second; exit if signal sending fails.\n" - << "\n" - << " -t, --num-threads=NUM [default=1]\n" - << " Use this many threads to scan git workdir for unstaged and untracked files.\n" - << " Empirically, setting this parameter to twice the number of virtual CPU yields\n" - << " maximum performance.\n" - << "\n" - << " -v, --log-level=STR [default=INFO]\n" - << " Don't write entires to log whose log level is below this. Log levels in\n" - << " increasing order: DEBUG, INFO, WARN, ERROR, FATAL.\n" - << "\n" - << " -r, --repo-ttl-seconds=NUM [default=3600]\n" - << " Close git repositories that haven't been used for this long. This is meant to\n" - << " release resources such as memory and file descriptors. The next request for a\n" - << " repo that's been closed is much slower than for a repo that hasn't been.\n" - << " Negative value means infinity.\n" - << "\n" - << " -z, --max-commit-summary-length=NUM [default=256]\n" - << " Truncate commit summary if it's longer than this many bytes.\n" - << "\n" - << " -s, --max-num-staged=NUM [default=1]\n" - << " Report at most this many staged changes; negative value means infinity.\n" - << "\n" - << " -u, --max-num-unstaged=NUM [default=1]\n" - << " Report at most this many unstaged changes; negative value means infinity.\n" - << "\n" - << " -c, --max-num-conflicted=NUM [default=1]\n" - << " Report at most this many conflicted changes; negative value means infinity.\n" - << "\n" - << " -d, --max-num-untracked=NUM [default=1]\n" - << " Report at most this many untracked files; negative value means infinity.\n" - << "\n" - << " -m, --dirty-max-index-size=NUM [default=-1]\n" - << " If a repo has more files in its index than this, override --max-num-unstaged\n" - << " and --max-num-untracked (but not --max-num-staged) with zeros; negative value\n" - << " means infinity.\n" - << "\n" - << " -e, --recurse-untracked-dirs\n" - << " Count files within untracked directories like `git status --untracked-files`.\n" - << "\n" - << " -U, --ignore-status-show-untracked-files\n" - << " Unless this option is specified, report zero untracked files for repositories\n" - << " with status.showUntrackedFiles = false.\n" - << "\n" - << " -W, --ignore-bash-show-untracked-files\n" - << " Unless this option is specified, report zero untracked files for repositories\n" - << " with bash.showUntrackedFiles = false.\n" - << "\n" - << " -D, --ignore-bash-show-dirty-state\n" - << " Unless this option is specified, report zero staged, unstaged and conflicted\n" - << " changes for repositories with bash.showDirtyState = false.\n" - << "\n" - << " -V, --version\n" - << " Print gitstatusd version and exit.\n" - << "\n" - << " -G, --version-glob=STR [default=*]\n" - << " Immediately exit with code 11 if gitstatusd version (see --version) doesn't\n" - << " does not match the specified pattern. Matching is done with fnmatch(3)\n" - << " without flags.\n" - << "\n" - << " -h, --help\n" - << " Display this help and exit.\n" - << "\n" - << "INPUT\n" - << "\n" - << " Requests are read from stdin, separated by ascii 30 (record separator). Each\n" - << " request is made of the following fields, in the specified order, separated by\n" - << " ascii 31 (unit separator):\n" - << "\n" - << " 1. Request ID. Any string. Can be empty.\n" - << " 2. Path to the directory for which git stats are being requested.\n" - << " If the first character is ':', it is removed and the remaning path\n" - << " is treated as GIT_DIR.\n" - << " 3. (Optional) '1' to disable computation of anything that requires reading\n" - << " git index; '0' for the default behavior of computing everything.\n" - << "\n" - << "OUTPUT\n" - << "\n" - << " For every request read from stdin there is response written to stdout.\n" - << " Responses are separated by ascii 30 (record separator). Each response is made\n" - << " of the following fields, in the specified order, separated by ascii 31\n" - << " (unit separator):\n" - << "\n" - << " 1. Request id. The same as the first field in the request.\n" - << " 2. 0 if the directory isn't a git repo, 1 otherwise. If 0, all the\n" - << " following fields are missing.\n" - << " 3. Absolute path to the git repository workdir.\n" - << " 4. Commit hash that HEAD is pointing to. 40 hex digits.\n" - << " 5. Local branch name or empty if not on a branch.\n" - << " 6. Upstream branch name. Can be empty.\n" - << " 7. The remote name, e.g. \"upstream\" or \"origin\".\n" - << " 8. Remote URL. Can be empty.\n" - << " 9. Repository state, A.K.A. action. Can be empty.\n" - << " 10. The number of files in the index.\n" - << " 11. The number of staged changes.\n" - << " 12. The number of unstaged changes.\n" - << " 13. The number of conflicted changes.\n" - << " 14. The number of untracked files.\n" - << " 15. Number of commits the current branch is ahead of upstream.\n" - << " 16. Number of commits the current branch is behind upstream.\n" - << " 17. The number of stashes.\n" - << " 18. The last tag (in lexicographical order) that points to the same\n" - << " commit as HEAD.\n" - << " 19. The number of unstaged deleted files.\n" - << " 20. The number of staged new files.\n" - << " 21. The number of staged deleted files.\n" - << " 22. The push remote name, e.g. \"upstream\" or \"origin\".\n" - << " 23. Push remote URL. Can be empty.\n" - << " 24. Number of commits the current branch is ahead of push remote.\n" - << " 25. Number of commits the current branch is behind push remote.\n" - << " 26. Number of files in the index with skip-worktree bit set.\n" - << " 27. Number of files in the index with assume-unchanged bit set.\n" - << " 28. Encoding of the HEAD's commit message. Empty value means UTF-8.\n" - << " 29. The first paragraph of the HEAD's commit message as one line.\n" - << "\n" - << "Note: Renamed files are reported as deleted plus new.\n" - << "\n" - << "EXAMPLE\n" - << "\n" - << " Send a single request and print response (zsh syntax):\n" - << "\n" - << " local req_id=id\n" - << " local dir=$PWD\n" - << " echo -nE $req_id$'\\x1f'$dir$'\\x1e' | ./gitstatusd | {\n" - << " local resp\n" - << " IFS=$'\\x1f' read -rd $'\\x1e' -A resp && print -lr -- \"${(@qq)resp}\"\n" - << " }\n" - << "\n" - << " Output:" - << "\n" - << " 'id'\n" - << " '1'\n" - << " '/home/romka/gitstatus'\n" - << " 'bf46bf03dbab7108801b53f8a720caee8464c9c3'\n" - << " 'master'\n" - << " 'master'\n" - << " 'origin'\n" - << " 'git@github.com:romkatv/gitstatus.git'\n" - << " ''\n" - << " '70'\n" - << " '1'\n" - << " '0'\n" - << " '0'\n" - << " '2'\n" - << " '0'\n" - << " '0'\n" - << " ''\n" - << " '0'\n" - << " '0'\n" - << " '0'\n" - << " ''\n" - << " ''\n" - << " '0'\n" - << " '0'\n" - << " '0'\n" - << " '0'\n" - << " ''\n" - << " 'add a build server for darwin-arm64'\n" - << "\n" - << "EXIT STATUS\n" - << "\n" - << " The command returns zero on success (when printing help or on EOF),\n" - << " non-zero on failure. In the latter case the output is unspecified.\n" - << "\n" - << "COPYRIGHT\n" - << "\n" - << " Copyright 2019 Roman Perepelitsa\n" - << " This is free software; see https://github.com/romkatv/gitstatus for copying\n" - << " conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR\n" - << " A PARTICULAR PURPOSE." << std::endl; -} - -const char* Version() { -#define _INTERNAL_GITSTATUS_STRINGIZE(x) _INTERNAL_GITSTATUS_STRINGIZE_I(x) -#define _INTERNAL_GITSTATUS_STRINGIZE_I(x) #x - return _INTERNAL_GITSTATUS_STRINGIZE(GITSTATUS_VERSION); -#undef _INTERNAL_GITSTATUS_STRINGIZE_I -#undef _INTERNAL_GITSTATUS_STRINGIZE -} - -} // namespace - -Options ParseOptions(int argc, char** argv) { - const struct option opts[] = {{"help", no_argument, nullptr, 'h'}, - {"version", no_argument, nullptr, 'V'}, - {"version-glob", required_argument, nullptr, 'G'}, - {"lock-fd", required_argument, nullptr, 'l'}, - {"parent-pid", required_argument, nullptr, 'p'}, - {"num-threads", required_argument, nullptr, 't'}, - {"log-level", required_argument, nullptr, 'v'}, - {"repo-ttl-seconds", required_argument, nullptr, 'r'}, - {"max-commit-summary-length", required_argument, nullptr, 'z'}, - {"max-num-staged", required_argument, nullptr, 's'}, - {"max-num-unstaged", required_argument, nullptr, 'u'}, - {"max-num-conflicted", required_argument, nullptr, 'c'}, - {"max-num-untracked", required_argument, nullptr, 'd'}, - {"dirty-max-index-size", required_argument, nullptr, 'm'}, - {"recurse-untracked-dirs", no_argument, nullptr, 'e'}, - {"ignore-status-show-untracked-files", no_argument, nullptr, 'U'}, - {"ignore-bash-show-untracked-files", no_argument, nullptr, 'W'}, - {"ignore-bash-show-dirty-state", no_argument, nullptr, 'D'}, - {}}; - Options res; - while (true) { - switch (getopt_long(argc, argv, "hVG:l:p:t:v:r:z:s:u:c:d:m:eUWD", opts, nullptr)) { - case -1: - if (optind != argc) { - std::cerr << "unexpected positional argument: " << argv[optind] << std::endl; - std::exit(10); - } - return res; - case 'h': - PrintUsage(); - std::exit(0); - case 'V': - std::cout << Version() << std::endl; - std::exit(0); - case 'G': - if (int err = fnmatch(optarg, Version(), 0)) { - if (err != FNM_NOMATCH) { - std::cerr << "Cannot match " << Print(Version()) << " against pattern " - << Print(optarg) << ": error " << err; - std::exit(10); - } - std::cerr << "Version mismatch. Wanted (pattern): " << Print(optarg) - << ". Actual: " << Print(Version()) << "." << std::endl; - std::exit(11); - } - break; - case 'l': - res.lock_fd = ParseInt(optarg); - break; - case 'p': - res.parent_pid = ParseInt(optarg); - break; - case 'v': - if (!ParseLogLevel(optarg, res.log_level)) { - std::cerr << "invalid log level: " << optarg << std::endl; - std::exit(10); - } - break; - case 'r': - res.repo_ttl = std::chrono::seconds(ParseLong(optarg)); - break; - case 't': { - long n = ParseLong(optarg); - if (n <= 0) { - std::cerr << "invalid number of threads: " << n << std::endl; - std::exit(10); - } - res.num_threads = n; - break; - } - case 'z': - res.max_commit_summary_length = ParseSizeT(optarg); - break; - case 's': - res.max_num_staged = ParseSizeT(optarg); - break; - case 'u': - res.max_num_unstaged = ParseSizeT(optarg); - break; - case 'c': - res.max_num_conflicted = ParseSizeT(optarg); - break; - case 'd': - res.max_num_untracked = ParseSizeT(optarg); - break; - case 'm': - res.dirty_max_index_size = ParseSizeT(optarg); - break; - case 'e': - res.recurse_untracked_dirs = true; - break; - case 'U': - res.ignore_status_show_untracked_files = true; - break; - case 'W': - res.ignore_bash_show_untracked_files = true; - break; - case 'D': - res.ignore_bash_show_dirty_state = true; - break; - default: - std::exit(10); - } - } -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/options.h b/.zsh/themes/powerlevel10k/gitstatus/src/options.h deleted file mode 100644 index fd561e1..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/options.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_OPTIONS_H_ -#define ROMKATV_GITSTATUS_OPTIONS_H_ - -#include <chrono> -#include <string> - -#include "logging.h" -#include "time.h" - -namespace gitstatus { - -struct Limits { - // Truncate commit summary if it's longer than this many bytes. - size_t max_commit_summary_length = 256; - // Report at most this many staged changes. - size_t max_num_staged = 1; - // Report at most this many unstaged changes. - size_t max_num_unstaged = 1; - // Report at most this many conflicted changes. - size_t max_num_conflicted = 1; - // Report at most this many untracked files. - size_t max_num_untracked = 1; - // If a repo has more files in its index than this, override max_num_unstaged and - // max_num_untracked (but not max_num_staged) with zeros. - size_t dirty_max_index_size = -1; - // If true, report untracked files like `git status --untracked-files`. - bool recurse_untracked_dirs = false; - // Unless true, report zero untracked files for repositories with - // status.showUntrackedFiles = false. - bool ignore_status_show_untracked_files = false; - // Unless true, report zero untracked files for repositories with - // bash.showUntrackedFiles = false. - bool ignore_bash_show_untracked_files = false; - // Unless true, report zero staged, unstaged and conflicted changes for repositories with - // bash.showDirtyState = false. - bool ignore_bash_show_dirty_state = false; -}; - -struct Options : Limits { - // Use this many threads to scan git workdir for unstaged and untracked files. Must be positive. - size_t num_threads = 1; - // If non-negative, check whether the specified file descriptor is locked when not receiving any - // requests for one second; exit if it isn't locked. - int lock_fd = -1; - // If non-negative, send signal 0 to the specified PID when not receiving any requests for one - // second; exit if signal sending fails. - int parent_pid = -1; - // Don't write entires to log whose log level is below this. Log levels in increasing order: - // DEBUG, INFO, WARN, ERROR, FATAL. - LogLevel log_level = INFO; - // Close git repositories that haven't been used for this long. This is meant to release resources - // such as memory and file descriptors. The next request for a repo that's been closed is much - // slower than for a repo that hasn't been. Negative value means infinity. - Duration repo_ttl = std::chrono::seconds(3600); -}; - -Options ParseOptions(int argc, char** argv); - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_OPTIONS_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/print.h b/.zsh/themes/powerlevel10k/gitstatus/src/print.h deleted file mode 100644 index 949f946..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/print.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_PRINT_H_ -#define ROMKATV_GITSTATUS_PRINT_H_ - -#include <sys/stat.h> - -#include <iomanip> -#include <ostream> -#include <string> -#include <type_traits> -#include <utility> -#include <vector> - -#include <git2.h> - -#include "string_view.h" -#include "strings.h" - -namespace gitstatus { - -template <class T> -struct Printable { - const T& value; -}; - -template <class T> -Printable<T> Print(const T& val) { - return {val}; -} - -template <class T> -std::ostream& operator<<(std::ostream& strm, const Printable<T>& p) { - static_assert(!std::is_pointer<std::decay_t<T>>(), ""); - return strm << p.value; -} - -inline std::ostream& operator<<(std::ostream& strm, const Printable<StringView>& p) { - Quote(strm, p.value.ptr, p.value.ptr + p.value.len); - return strm; -} - -inline std::ostream& operator<<(std::ostream& strm, const Printable<std::string>& p) { - Quote(strm, p.value.data(), p.value.data() + p.value.size()); - return strm; -} - -inline std::ostream& operator<<(std::ostream& strm, const Printable<const char*>& p) { - Quote(strm, p.value, p.value ? p.value + std::strlen(p.value) : nullptr); - return strm; -} - -inline std::ostream& operator<<(std::ostream& strm, const Printable<char*>& p) { - Quote(strm, p.value, p.value ? p.value + std::strlen(p.value) : nullptr); - return strm; -} - -template <class T, class U> -std::ostream& operator<<(std::ostream& strm, const Printable<std::pair<T, U>>& p) { - return strm << '{' << Print(p.value.first) << ", " << Print(p.value.second) << '}'; -} - -template <class T> -std::ostream& operator<<(std::ostream& strm, const Printable<std::vector<T>>& p) { - strm << '['; - for (size_t i = 0; i != p.value.size(); ++i) { - if (i) strm << ", "; - strm << Print(p.value[i]); - } - strm << ']'; - return strm; -} - -inline std::ostream& operator<<(std::ostream& strm, const Printable<struct timespec>& p) { - strm << p.value.tv_sec << '.' << std::setw(9) << std::setfill('0') << p.value.tv_nsec; - return strm; -} - -inline std::ostream& operator<<(std::ostream& strm, const Printable<git_index_time>& p) { - strm << p.value.seconds << '.' << std::setw(9) << std::setfill('0') << p.value.nanoseconds; - return strm; -} - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_PRINT_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/repo.cc b/.zsh/themes/powerlevel10k/gitstatus/src/repo.cc deleted file mode 100644 index d7ea7d3..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/repo.cc +++ /dev/null @@ -1,503 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "repo.h" - -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include <algorithm> -#include <atomic> -#include <cstdlib> -#include <cstring> -#include <exception> -#include <iterator> -#include <memory> -#include <type_traits> -#include <utility> - -#include "arena.h" -#include "check.h" -#include "check_dir_mtime.h" -#include "dir.h" -#include "git.h" -#include "print.h" -#include "scope_guard.h" -#include "stat.h" -#include "string_cmp.h" -#include "thread_pool.h" -#include "timer.h" - -namespace gitstatus { - -namespace { - -using namespace std::string_literals; - -template <class T> -T Load(const std::atomic<T>& x) { - return x.load(std::memory_order_relaxed); -} - -template <class T> -void Store(std::atomic<T>& x, T v) { - x.store(v, std::memory_order_relaxed); -} - -template <class T> -T Inc(std::atomic<T>& x, T by = 1) { - return x.fetch_add(by, std::memory_order_relaxed); -} - -template <class T> -T Dec(std::atomic<T>& x) { - return x.fetch_sub(1, std::memory_order_relaxed); -} - -template <class T> -T Exchange(std::atomic<T>& x, T v) { - return x.exchange(v, std::memory_order_relaxed); -} - -const char* DeltaStr(git_delta_t t) { - switch (t) { - case GIT_DELTA_UNMODIFIED: return "unmodified"; - case GIT_DELTA_ADDED: return "added"; - case GIT_DELTA_DELETED: return "deleted"; - case GIT_DELTA_MODIFIED: return "modified"; - case GIT_DELTA_RENAMED: return "renamed"; - case GIT_DELTA_COPIED: return "copied"; - case GIT_DELTA_IGNORED: return "ignored"; - case GIT_DELTA_UNTRACKED: return "untracked"; - case GIT_DELTA_TYPECHANGE: return "typechange"; - case GIT_DELTA_UNREADABLE: return "unreadable"; - case GIT_DELTA_CONFLICTED: return "conflicted"; - } - return "unknown"; -} - -} // namespace - -bool Repo::Shard::Contains(Str<> str, StringView path) const { - if (str.Lt(path, start_s)) return false; - if (end_s.empty()) return true; - path.len = std::min(path.len, end_s.size()); - return !str.Lt(end_s, path); -} - -Repo::Repo(git_repository* repo, Limits lim) : lim_(std::move(lim)), repo_(repo), tag_db_(repo) { - if (lim_.max_num_untracked) { - GlobalThreadPool()->Schedule([this] { - bool check = CheckDirMtime(git_repository_path(repo_)); - std::unique_lock<std::mutex> lock(mutex_); - CHECK(Load(untracked_cache_) == Tribool::kUnknown); - Store(untracked_cache_, check ? Tribool::kTrue : Tribool::kFalse); - cv_.notify_one(); - }); - } else { - untracked_cache_ = Tribool::kFalse; - } -} - -Repo::~Repo() { - { - std::unique_lock<std::mutex> lock(mutex_); - while (untracked_cache_ == Tribool::kUnknown) cv_.wait(lock); - } - if (git_index_) git_index_free(git_index_); - git_repository_free(repo_); -} - -IndexStats Repo::GetIndexStats(const git_oid* head, git_config* cfg) { - ON_SCOPE_EXIT(this, orig_lim = lim_) { lim_ = orig_lim; }; - auto Off = [&](const char* name) { - int val; - if (git_config_get_bool(&val, cfg, name) || val) return false; - LOG(INFO) << "Honoring git config option: " << name << " = false"; - return true; - }; - if (!lim_.ignore_status_show_untracked_files && Off("status.showUntrackedFiles")) { - lim_.max_num_untracked = 0; - } - if (!lim_.ignore_bash_show_untracked_files && Off("bash.showUntrackedFiles")) { - lim_.max_num_untracked = 0; - } - if (!lim_.ignore_bash_show_dirty_state && Off("bash.showDirtyState")) { - lim_.max_num_staged = 0; - lim_.max_num_unstaged = 0; - lim_.max_num_conflicted = 0; - } - - if (git_index_) { - int new_index; - VERIFY(!git_index_read_ex(git_index_, 0, &new_index)) << GitError(); - if (new_index) { - head_ = {}; - index_.reset(); - } - } else { - VERIFY(!git_repository_index(&git_index_, repo_)) << GitError(); - // Query an attribute (doesn't matter which) to initialize repo's attribute - // cache. It's a workaround for synchronization bugs (data races) in libgit2 - // that result from lazy cache initialization without synchrnonization. - // Thankfully, subsequent cache reads and writes are properly synchronized. - const char* attr; - VERIFY(!git_attr_get(&attr, repo_, 0, "x", "x")) << GitError(); - } - - UpdateShards(); - Store(error_, false); - Store(unstaged_, {}); - Store(untracked_, {}); - Store(unstaged_deleted_, {}); - - std::vector<const char*> dirty_candidates; - const size_t index_size = git_index_entrycount(git_index_); - - if (!lim_.max_num_staged && !lim_.max_num_conflicted) { - head_ = {}; - Store(staged_, {}); - Store(conflicted_, {}); - Store(staged_new_, {}); - Store(staged_deleted_, {}); - Store(skip_worktree_, {}); - Store(assume_unchanged_, {}); - } else if (head) { - if (git_oid_equal(head, &head_)) { - LOG(INFO) << "Index and HEAD unchanged; staged = " << Load(staged_) - << ", conflicted = " << Load(conflicted_); - } else { - head_ = *head; - Store(staged_, {}); - Store(conflicted_, {}); - Store(staged_new_, {}); - Store(staged_deleted_, {}); - Store(skip_worktree_, {}); - Store(assume_unchanged_, {}); - StartStagedScan(head); - } - } else { - head_ = {}; - size_t staged = 0; - size_t skip_worktree = 0; - size_t assume_unchanged = 0; - for (size_t i = 0; i != index_size; ++i) { - const git_index_entry* entry = git_index_get_byindex_no_sort(git_index_, i); - if (!(entry->flags_extended & GIT_INDEX_ENTRY_INTENT_TO_ADD)) ++staged; - if (entry->flags_extended & GIT_INDEX_ENTRY_SKIP_WORKTREE) ++skip_worktree; - if (entry->flags & GIT_INDEX_ENTRY_VALID) ++assume_unchanged; - } - Store(staged_, staged); - Store(conflicted_, {}); - Store(staged_new_, staged); - Store(staged_deleted_, {}); - Store(skip_worktree_, skip_worktree); - Store(assume_unchanged_, assume_unchanged); - } - - if (index_size <= lim_.dirty_max_index_size && - (lim_.max_num_unstaged || lim_.max_num_untracked)) { - if (!index_) index_ = std::make_unique<Index>(repo_, git_index_); - dirty_candidates = index_->GetDirtyCandidates({.include_untracked = lim_.max_num_untracked > 0, - .untracked_cache = Load(untracked_cache_)}); - if (dirty_candidates.empty()) { - LOG(INFO) << "Clean repo: no dirty candidates"; - } else { - LOG(INFO) << "Found " << dirty_candidates.size() << " dirty candidate(s) spanning from " - << Print(dirty_candidates.front()) << " to " << Print(dirty_candidates.back()); - } - StartDirtyScan(dirty_candidates); - } - - Wait(); - VERIFY(!Load(error_)); - - size_t num_staged = std::min(Load(staged_), lim_.max_num_staged); - size_t num_unstaged = std::min(Load(unstaged_), lim_.max_num_unstaged); - return {.index_size = index_size, - .num_staged = num_staged, - .num_unstaged = num_unstaged, - .num_conflicted = std::min(Load(conflicted_), lim_.max_num_conflicted), - .num_untracked = std::min(Load(untracked_), lim_.max_num_untracked), - .num_staged_new = std::min(Load(staged_new_), num_staged), - .num_staged_deleted = std::min(Load(staged_deleted_), num_staged), - .num_unstaged_deleted = std::min(Load(unstaged_deleted_), num_unstaged), - .num_skip_worktree = Load(skip_worktree_), - .num_assume_unchanged = Load(assume_unchanged_)}; -} - -int Repo::OnDelta(const char* type, const git_diff_delta& d, std::atomic<size_t>& c1, size_t m1, - const std::atomic<size_t>& c2, size_t m2) { - auto Msg = [&]() { - const char* status = DeltaStr(d.status); - std::ostringstream strm; - strm << "Found " << type << " file"; - if (strcmp(status, type)) strm << " (" << status << ")"; - strm << ": " << Print(d.new_file.path); - return strm.str(); - }; - - size_t v = Inc(c1); - if (v) { - LOG(DEBUG) << Msg(); - } else { - LOG(INFO) << Msg(); - } - if (v + 1 < m1) return GIT_DIFF_DELTA_DO_NOT_INSERT; - if (Load(c2) < m2) return GIT_DIFF_DELTA_DO_NOT_INSERT | GIT_DIFF_DELTA_SKIP_TYPE; - return GIT_EUSER; -} - -void Repo::StartDirtyScan(const std::vector<const char*>& paths) { - if (paths.empty()) return; - - git_diff_options opt = GIT_DIFF_OPTIONS_INIT; - opt.payload = this; - opt.flags = GIT_DIFF_INCLUDE_TYPECHANGE_TREES | GIT_DIFF_SKIP_BINARY_CHECK | - GIT_DIFF_DISABLE_PATHSPEC_MATCH | GIT_DIFF_EXEMPLARS; - if (lim_.max_num_untracked) { - opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED; - if (lim_.recurse_untracked_dirs) opt.flags |= GIT_DIFF_RECURSE_UNTRACKED_DIRS; - } else { - opt.flags |= GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS; - } - opt.ignore_submodules = GIT_SUBMODULE_IGNORE_DIRTY; - opt.notify_cb = +[](const git_diff* diff, const git_diff_delta* delta, - const char* matched_pathspec, void* payload) -> int { - if (delta->status == GIT_DELTA_CONFLICTED) return GIT_DIFF_DELTA_DO_NOT_INSERT; - Repo* repo = static_cast<Repo*>(payload); - if (Load(repo->error_)) return GIT_EUSER; - if (delta->status == GIT_DELTA_UNTRACKED) { - return repo->OnDelta("untracked", *delta, repo->untracked_, repo->lim_.max_num_untracked, - repo->unstaged_, repo->lim_.max_num_unstaged); - } else { - if (delta->status == GIT_DELTA_DELETED) Inc(repo->unstaged_deleted_); - return repo->OnDelta("unstaged", *delta, repo->unstaged_, repo->lim_.max_num_unstaged, - repo->untracked_, repo->lim_.max_num_untracked); - } - }; - - const Str<> str(git_index_is_case_sensitive(git_index_)); - auto shard = shards_.begin(); - for (auto p = paths.begin(); p != paths.end();) { - opt.range_start = *p; - opt.range_end = *p; - opt.pathspec.strings = const_cast<char**>(&*p); - opt.pathspec.count = 1; - while (!shard->Contains(str, StringView(*p))) ++shard; - while (++p != paths.end() && shard->Contains(str, StringView(*p))) { - opt.range_end = *p; - ++opt.pathspec.count; - } - RunAsync([this, opt]() { - git_diff* diff = nullptr; - LOG(DEBUG) << "git_diff_index_to_workdir from " << Print(opt.range_start) << " to " - << Print(opt.range_end); - switch (git_diff_index_to_workdir(&diff, repo_, git_index_, &opt)) { - case 0: - git_diff_free(diff); - break; - case GIT_EUSER: - break; - default: - LOG(ERROR) << "git_diff_index_to_workdir: " << GitError(); - throw Exception(); - } - }); - } -} - -void Repo::StartStagedScan(const git_oid* head) { - git_commit* commit = nullptr; - VERIFY(!git_commit_lookup(&commit, repo_, head)) << GitError(); - ON_SCOPE_EXIT(=) { git_commit_free(commit); }; - git_tree* tree = nullptr; - VERIFY(!git_commit_tree(&tree, commit)) << GitError(); - - git_diff_options opt = GIT_DIFF_OPTIONS_INIT; - opt.flags = GIT_DIFF_EXEMPLARS | GIT_DIFF_INCLUDE_TYPECHANGE_TREES; - opt.payload = this; - opt.notify_cb = +[](const git_diff* diff, const git_diff_delta* delta, - const char* matched_pathspec, void* payload) -> int { - Repo* repo = static_cast<Repo*>(payload); - if (Load(repo->error_)) return GIT_EUSER; - if (delta->status == GIT_DELTA_CONFLICTED) { - return repo->OnDelta("conflicted", *delta, repo->conflicted_, repo->lim_.max_num_conflicted, - repo->staged_, repo->lim_.max_num_staged); - } else { - if (delta->status == GIT_DELTA_ADDED) Inc(repo->staged_new_); - if (delta->status == GIT_DELTA_DELETED) Inc(repo->staged_deleted_); - return repo->OnDelta("staged", *delta, repo->staged_, repo->lim_.max_num_staged, - repo->conflicted_, repo->lim_.max_num_conflicted); - } - }; - - for (const Shard& shard : shards_) { - RunAsync([this, tree, opt, shard]() mutable { - size_t skip_worktree = 0; - size_t assume_unchanged = 0; - for (size_t i = shard.start_i; i != shard.end_i; ++i) { - const git_index_entry* entry = git_index_get_byindex_no_sort(git_index_, i); - if (entry->flags_extended & GIT_INDEX_ENTRY_SKIP_WORKTREE) ++skip_worktree; - if (entry->flags & GIT_INDEX_ENTRY_VALID) ++assume_unchanged; - } - Inc(skip_worktree_, skip_worktree); - Inc(assume_unchanged_, assume_unchanged); - opt.range_start = shard.start_s.c_str(); - opt.range_end = shard.end_s.c_str(); - git_diff* diff = nullptr; - LOG(DEBUG) << "git_diff_tree_to_index from " << Print(opt.range_start) << " to " - << Print(opt.range_end); - switch (git_diff_tree_to_index(&diff, repo_, tree, git_index_, &opt)) { - case 0: - git_diff_free(diff); - break; - case GIT_EUSER: - break; - default: - LOG(ERROR) << "git_diff_tree_to_index: " << GitError(); - throw Exception(); - } - }); - } -} - -void Repo::UpdateShards() { - constexpr size_t kEntriesPerShard = 512; - - const Str<> str(git_index_is_case_sensitive(git_index_)); - size_t index_size = git_index_entrycount(git_index_); - ON_SCOPE_EXIT(&) { - LOG(INFO) << "Splitting " << index_size << " object(s) into " << shards_.size() << " shard(s)"; - }; - - if (index_size <= kEntriesPerShard || GlobalThreadPool()->num_threads() < 2) { - shards_ = {{ - .start_s = "", - .end_s = "", - .start_i = 0, - .end_i = index_size}}; - return; - } - - size_t shards = - std::min(index_size / kEntriesPerShard + 1, 2 * GlobalThreadPool()->num_threads()); - shards_.clear(); - shards_.reserve(shards); - std::string last_s; - size_t last_i = 0; - - for (size_t i = 0; i != shards - 1; ++i) { - size_t idx = (i + 1) * index_size / shards; - std::string split = git_index_get_byindex_no_sort(git_index_, idx)->path; - auto pos = split.find_last_of('/'); - if (pos == std::string::npos) continue; - split = split.substr(0, pos + 1); - Shard shard; - shard.end_s = split; - --shard.end_s.back(); - if (!str.Lt(last_s, shard.end_s)) continue; - shard.start_s = std::move(last_s); - last_s = std::move(split); - shard.start_i = last_i; - shard.end_i = idx; - last_i = idx; - shards_.push_back(std::move(shard)); - } - shards_.push_back({ - .start_s = std::move(last_s), - .end_s = "", - .start_i = last_i, - .end_i = index_size}); - - CHECK(!shards_.empty()); - CHECK(shards_.size() <= shards); - CHECK(shards_.front().start_s.empty()); - CHECK(shards_.front().start_i == 0); - CHECK(shards_.back().end_s.empty()); - CHECK(shards_.back().end_i == index_size); - for (size_t i = 0; i != shards_.size(); ++i) { - if (i) { - const git_index_entry* entry = git_index_get_byindex_no_sort(git_index_, shards_[i].start_i); - CHECK(!std::memcmp(shards_[i].start_s.c_str(), entry->path, shards_[i].start_s.size())); - CHECK(str.Lt(shards_[i - 1].end_s, shards_[i].start_s)); - CHECK(shards_[i - 1].end_i == shards_[i].start_i); - } - if (i != shards_.size() - 1) { - CHECK(shards_[i].start_i < shards_[i].end_i); - CHECK(str.Lt(shards_[i].start_s, shards_[i].end_s)); - } - } -} - -void Repo::DecInflight() { - std::unique_lock<std::mutex> lock(mutex_); - CHECK(Load(inflight_) > 0); - if (Dec(inflight_) == 1) cv_.notify_one(); -} - -void Repo::RunAsync(std::function<void()> f) { - Inc(inflight_); - try { - GlobalThreadPool()->Schedule([this, f = std::move(f)] { - try { - ON_SCOPE_EXIT(&) { DecInflight(); }; - f(); - } catch (const Exception&) { - if (!Load(error_)) { - std::unique_lock<std::mutex> lock(mutex_); - if (!Load(error_)) { - Store(error_, true); - cv_.notify_one(); - } - } - } - }); - } catch (...) { - DecInflight(); - throw; - } -} - -void Repo::Wait() { - std::unique_lock<std::mutex> lock(mutex_); - while (inflight_) cv_.wait(lock); -} - -std::future<std::string> Repo::GetTagName(const git_oid* target) { - auto* promise = new std::promise<std::string>; - std::future<std::string> res = promise->get_future(); - - GlobalThreadPool()->Schedule([=] { - ON_SCOPE_EXIT(&) { delete promise; }; - if (!target) { - promise->set_value(""); - return; - } - try { - promise->set_value(tag_db_.TagForCommit(*target)); - } catch (const Exception&) { - promise->set_exception(std::current_exception()); - } - }); - - return res; -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/repo.h b/.zsh/themes/powerlevel10k/gitstatus/src/repo.h deleted file mode 100644 index f243f86..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/repo.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_REPO_H_ -#define ROMKATV_GITSTATUS_REPO_H_ - -#include <stddef.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include <git2.h> - -#include <algorithm> -#include <atomic> -#include <condition_variable> -#include <cstddef> -#include <cstring> -#include <functional> -#include <future> -#include <memory> -#include <mutex> -#include <string> -#include <utility> -#include <vector> - -#include "check.h" -#include "index.h" -#include "options.h" -#include "string_cmp.h" -#include "tag_db.h" -#include "time.h" - -namespace gitstatus { - -struct IndexStats { - size_t index_size = 0; - size_t num_staged = 0; - size_t num_unstaged = 0; - size_t num_conflicted = 0; - size_t num_untracked = 0; - size_t num_staged_new = 0; - size_t num_staged_deleted = 0; - size_t num_unstaged_deleted = 0; - size_t num_skip_worktree = 0; - size_t num_assume_unchanged = 0; -}; - -class Repo { - public: - explicit Repo(git_repository* repo, Limits lim); - Repo(Repo&& other) = delete; - ~Repo(); - - git_repository* repo() const { return repo_; } - - // Head can be null, in which case has_staged will be false. - IndexStats GetIndexStats(const git_oid* head, git_config* cfg); - - // Returns the last tag in lexicographical order whose target is equal to the given, or an - // empty string. Target can be null, in which case the tag is empty. - std::future<std::string> GetTagName(const git_oid* target); - - private: - struct Shard { - bool Contains(Str<> str, StringView path) const; - std::string start_s; - std::string end_s; - size_t start_i; - size_t end_i; - }; - - void UpdateShards(); - - int OnDelta(const char* type, const git_diff_delta& d, std::atomic<size_t>& c1, size_t m1, - const std::atomic<size_t>& c2, size_t m2); - - void StartStagedScan(const git_oid* head); - void StartDirtyScan(const std::vector<const char*>& paths); - - void DecInflight(); - void RunAsync(std::function<void()> f); - void Wait(); - - Limits lim_; - git_repository* const repo_; - git_index* git_index_ = nullptr; - std::vector<Shard> shards_; - git_oid head_ = {}; - TagDb tag_db_; - - std::unique_ptr<Index> index_; - - std::mutex mutex_; - std::condition_variable cv_; - std::atomic<size_t> inflight_{0}; - std::atomic<bool> error_{false}; - std::atomic<size_t> staged_{0}; - std::atomic<size_t> unstaged_{0}; - std::atomic<size_t> conflicted_{0}; - std::atomic<size_t> untracked_{0}; - std::atomic<size_t> staged_new_{0}; - std::atomic<size_t> staged_deleted_{0}; - std::atomic<size_t> unstaged_deleted_{0}; - std::atomic<size_t> skip_worktree_{0}; - std::atomic<size_t> assume_unchanged_{0}; - std::atomic<Tribool> untracked_cache_{Tribool::kUnknown}; -}; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_REPO_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/repo_cache.cc b/.zsh/themes/powerlevel10k/gitstatus/src/repo_cache.cc deleted file mode 100644 index d7f5f9a..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/repo_cache.cc +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "repo_cache.h" - -#include <cstring> - -#include "check.h" -#include "git.h" -#include "print.h" -#include "scope_guard.h" -#include "string_view.h" - -namespace gitstatus { - -namespace { - -void GitDirs(const char* dir, bool from_dotgit, std::string& gitdir, std::string& workdir) { - git_buf gitdir_buf = {}; - git_buf workdir_buf = {}; - ON_SCOPE_EXIT(&) { - git_buf_free(&gitdir_buf); - git_buf_free(&workdir_buf); - }; - int flags = from_dotgit ? GIT_REPOSITORY_OPEN_NO_SEARCH | GIT_REPOSITORY_OPEN_NO_DOTGIT : 0; - switch (git_repository_discover_ex(&gitdir_buf, &workdir_buf, NULL, NULL, dir, flags, nullptr)) { - case 0: - gitdir.assign(gitdir_buf.ptr, gitdir_buf.size); - workdir.assign(workdir_buf.ptr, workdir_buf.size); - VERIFY(!gitdir.empty() && gitdir.front() == '/' && gitdir.back() == '/'); - VERIFY(!workdir.empty() && workdir.front() == '/' && workdir.back() == '/'); - break; - case GIT_ENOTFOUND: - gitdir.clear(); - workdir.clear(); - break; - default: - LOG(ERROR) << "git_repository_open_ext: " << Print(dir) << ": " << GitError(); - throw Exception(); - } -} - -git_repository* OpenRepo(const std::string& dir, bool from_dotgit) { - git_repository* repo = nullptr; - int flags = from_dotgit ? GIT_REPOSITORY_OPEN_NO_SEARCH | GIT_REPOSITORY_OPEN_NO_DOTGIT : 0; - switch (git_repository_open_ext(&repo, dir.c_str(), flags, nullptr)) { - case 0: - return repo; - case GIT_ENOTFOUND: - return nullptr; - default: - LOG(ERROR) << "git_repository_open_ext: " << Print(dir) << ": " << GitError(); - throw Exception(); - } -} - -std::string DirName(std::string path) { - if (path.empty()) return ""; - while (path.back() == '/') { - path.pop_back(); - if (path.empty()) return ""; - } - do { - path.pop_back(); - if (path.empty()) return ""; - } while (path.back() != '/'); - return path; -} - -} // namespace - -Repo* RepoCache::Open(const std::string& dir, bool from_dotgit) { - if (dir.empty() || dir.front() != '/') return nullptr; - - std::string gitdir, workdir; - GitDirs(dir.c_str(), from_dotgit, gitdir, workdir); - if (gitdir.empty()) { - // This isn't quite correct because of differences in canonicalization, .git files and GIT_DIR. - // A proper solution would require tracking the "discovery dir" for every repository and - // performing path canonicalization. - if (from_dotgit) { - Erase(cache_.find(dir.back() == '/' ? dir : dir + '/')); - } else { - std::string path = dir; - if (path.back() != '/') path += '/'; - do { - Erase(cache_.find(path + ".git/")); - path = DirName(path); - } while (!path.empty()); - } - return nullptr; - } - - auto it = cache_.find(gitdir); - if (it != cache_.end()) { - lru_.erase(it->second->lru); - it->second->lru = lru_.insert({Clock::now(), it}); - return it->second.get(); - } - - // Opening from gitdir is faster but we cannot use it when gitdir came from a .git file. - git_repository* repo = - DirName(gitdir) == workdir ? OpenRepo(gitdir, true) : OpenRepo(dir, from_dotgit); - if (!repo) return nullptr; - ON_SCOPE_EXIT(&) { - if (repo) git_repository_free(repo); - }; - if (git_repository_is_bare(repo)) return nullptr; - workdir = git_repository_workdir(repo) ?: ""; - if (workdir.empty()) return nullptr; - VERIFY(workdir.front() == '/' && workdir.back() == '/') << Print(workdir); - - auto x = cache_.emplace(gitdir, nullptr); - std::unique_ptr<Entry>& elem = x.first->second; - if (elem) { - lru_.erase(elem->lru); - } else { - LOG(INFO) << "Initializing new repository: " << Print(gitdir); - - // Libgit2 initializes odb and refdb lazily with double-locking. To avoid useless work - // when multiple threads attempt to initialize the same db at the same time, we trigger - // initialization manually before threads are in play. - git_odb* odb; - VERIFY(!git_repository_odb(&odb, repo)) << GitError(); - git_odb_free(odb); - - git_refdb* refdb; - VERIFY(!git_repository_refdb(&refdb, repo)) << GitError(); - git_refdb_free(refdb); - - elem = std::make_unique<Entry>(std::exchange(repo, nullptr), lim_); - } - elem->lru = lru_.insert({Clock::now(), x.first}); - return elem.get(); -} - -void RepoCache::Free(Time cutoff) { - while (true) { - if (lru_.empty()) break; - auto it = lru_.begin(); - if (it->first > cutoff) break; - Erase(it->second); - } -} - -void RepoCache::Erase(Cache::iterator it) { - if (it == cache_.end()) return; - LOG(INFO) << "Closing repository: " << Print(it->first); - lru_.erase(it->second->lru); - cache_.erase(it); -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/repo_cache.h b/.zsh/themes/powerlevel10k/gitstatus/src/repo_cache.h deleted file mode 100644 index 9d14ec0..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/repo_cache.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_REPO_CACHE_H_ -#define ROMKATV_GITSTATUS_REPO_CACHE_H_ - -#include <map> -#include <memory> -#include <string> -#include <unordered_map> -#include <utility> - -#include <git2.h> - -#include "options.h" -#include "repo.h" -#include "time.h" - -namespace gitstatus { - -class RepoCache { - public: - explicit RepoCache(Limits lim) : lim_(std::move(lim)) {} - Repo* Open(const std::string& dir, bool from_dotgit); - void Free(Time cutoff); - - private: - struct Entry; - using Cache = std::unordered_map<std::string, std::unique_ptr<Entry>>; - using LRU = std::multimap<Time, Cache::iterator>; - - void Erase(Cache::iterator it); - - Limits lim_; - Cache cache_; - LRU lru_; - - struct Entry : Repo { - using Repo::Repo; - LRU::iterator lru; - }; -}; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_REPO_CACHE_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/request.cc b/.zsh/themes/powerlevel10k/gitstatus/src/request.cc deleted file mode 100644 index 1a81bff..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/request.cc +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "request.h" - -#include <fcntl.h> -#include <signal.h> -#include <sys/select.h> -#include <sys/types.h> -#include <unistd.h> - -#include <algorithm> -#include <cstdlib> -#include <iostream> - -#include "check.h" -#include "logging.h" -#include "print.h" -#include "serialization.h" - -namespace gitstatus { - -namespace { - -Request ParseRequest(const std::string& s) { - Request res; - auto begin = s.begin(), end = s.end(), sep = std::find(begin, end, kFieldSep); - VERIFY(sep != end) << "Malformed request: " << s; - res.id.assign(begin, sep); - - begin = sep + 1; - if (*begin == ':') { - res.from_dotgit = true; - ++begin; - } - sep = std::find(begin, end, kFieldSep); - res.dir.assign(begin, sep); - if (sep == end) return res; - - begin = sep + 1; - VERIFY(begin + 1 == end && (*begin == '0' || *begin == '1')) << "Malformed request: " << s; - res.diff = *begin == '0'; - return res; -} - -bool IsLockedFd(int fd) { - CHECK(fd >= 0); - struct flock flock = {}; - flock.l_type = F_RDLCK; - flock.l_whence = SEEK_SET; - CHECK(fcntl(fd, F_GETLK, &flock) != -1) << Errno(); - return flock.l_type != F_UNLCK; -} - -} // namespace - -std::ostream& operator<<(std::ostream& strm, const Request& req) { - strm << Print(req.id) << " for " << Print(req.dir); - if (req.from_dotgit) strm << " [from-dotgit]"; - if (!req.diff) strm << " [no-diff]"; - return strm; -} - -RequestReader::RequestReader(int fd, int lock_fd, int parent_pid) - : fd_(fd), lock_fd_(lock_fd), parent_pid_(parent_pid) { - CHECK(fd != lock_fd); -} - -bool RequestReader::ReadRequest(Request& req) { - auto eol = std::find(read_.begin(), read_.end(), kMsgSep); - if (eol != read_.end()) { - std::string msg(read_.begin(), eol); - read_.erase(read_.begin(), eol + 1); - req = ParseRequest(msg); - return true; - } - - char buf[256]; - while (true) { - fd_set fds; - FD_ZERO(&fds); - FD_SET(fd_, &fds); - struct timeval timeout = {.tv_sec = 1}; - - int n; - CHECK((n = select(fd_ + 1, &fds, NULL, NULL, &timeout)) >= 0) << Errno(); - if (n == 0) { - if (lock_fd_ >= 0 && !IsLockedFd(lock_fd_)) { - LOG(INFO) << "Lock on fd " << lock_fd_ << " is gone. Exiting."; - std::exit(0); - } - if (parent_pid_ >= 0 && kill(parent_pid_, 0)) { - LOG(INFO) << "Unable to send signal 0 to " << parent_pid_ << ". Exiting."; - std::exit(0); - } - req = {}; - return false; - } - - CHECK((n = read(fd_, buf, sizeof(buf))) >= 0) << Errno(); - if (n == 0) { - LOG(INFO) << "EOF. Exiting."; - std::exit(0); - } - read_.insert(read_.end(), buf, buf + n); - int eol = std::find(buf, buf + n, kMsgSep) - buf; - if (eol != n) { - std::string msg(read_.begin(), read_.end() - (n - eol)); - read_.erase(read_.begin(), read_.begin() + msg.size() + 1); - req = ParseRequest(msg); - return true; - } - } -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/request.h b/.zsh/themes/powerlevel10k/gitstatus/src/request.h deleted file mode 100644 index 2cc8baf..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/request.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_REQUEST_H_ -#define ROMKATV_GITSTATUS_REQUEST_H_ - -#include <deque> -#include <ostream> -#include <string> - -namespace gitstatus { - -struct Request { - std::string id; - std::string dir; - bool from_dotgit = false; - bool diff = true; -}; - -std::ostream& operator<<(std::ostream& strm, const Request& req); - -class RequestReader { - public: - RequestReader(int fd, int lock_fd, int parent_pid); - bool ReadRequest(Request& req); - - private: - int fd_; - int lock_fd_; - int parent_pid_; - std::deque<char> read_; -}; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_REQUEST_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/response.cc b/.zsh/themes/powerlevel10k/gitstatus/src/response.cc deleted file mode 100644 index eeb89c4..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/response.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "response.h" - -#include <cctype> -#include <cstring> -#include <iostream> - -#include "check.h" -#include "serialization.h" - -namespace gitstatus { - -namespace { - -constexpr char kUnreadable = '?'; - -void SafePrint(std::ostream& strm, StringView s) { - for (size_t i = 0; i != s.len; ++i) { - char c = s.ptr[i]; - strm << (c > 127 || std::isprint(c) ? c : kUnreadable); - } -} - -} // namespace - -ResponseWriter::ResponseWriter(std::string request_id) : request_id_(std::move(request_id)) { - SafePrint(strm_, request_id_); - Print(1); -} - -ResponseWriter::~ResponseWriter() { - if (!done_) { - strm_.str(""); - SafePrint(strm_, request_id_); - Print("0"); - Dump("without git status"); - } -} - -void ResponseWriter::Print(ssize_t val) { - strm_ << kFieldSep; - strm_ << val; -} - -void ResponseWriter::Print(StringView val) { - strm_ << kFieldSep; - SafePrint(strm_, val); -} - -void ResponseWriter::Dump(const char* log) { - CHECK(!done_); - done_ = true; - LOG(INFO) << "Replying " << log; - std::cout << strm_.str() << kMsgSep << std::flush; -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/response.h b/.zsh/themes/powerlevel10k/gitstatus/src/response.h deleted file mode 100644 index 12de765..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/response.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_RESPONSE_H_ -#define ROMKATV_GITSTATUS_RESPONSE_H_ - -#include <cstddef> -#include <cstdint> -#include <sstream> -#include <string> - -#include "string_view.h" - -namespace gitstatus { - -class ResponseWriter { - public: - ResponseWriter(std::string request_id); - ResponseWriter(ResponseWriter&&) = delete; - ~ResponseWriter(); - - void Print(ssize_t val); - void Print(StringView val); - void Print(const char* val) { Print(StringView(val)); } - - void Dump(const char* log); - - private: - bool done_ = false; - std::string request_id_; - std::ostringstream strm_; -}; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_RESPONSE_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/scope_guard.h b/.zsh/themes/powerlevel10k/gitstatus/src/scope_guard.h deleted file mode 100644 index 3a7aa01..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/scope_guard.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_SCOPE_GUARD_H_ -#define ROMKATV_GITSTATUS_SCOPE_GUARD_H_ - -#include <utility> - -#define ON_SCOPE_EXIT(capture...) \ - auto GITSTATUS_INTERNAL_CAT(_gitstatus_scope_guard_, __COUNTER__) = \ - ::gitstatus::internal_scope_guard::ScopeGuardGenerator() = [capture]() - -#define GITSTATUS_INTERNAL_CAT_I(x, y) x##y -#define GITSTATUS_INTERNAL_CAT(x, y) GITSTATUS_INTERNAL_CAT_I(x, y) - -namespace gitstatus { -namespace internal_scope_guard { - -void Undefined(); - -template <class F> -class ScopeGuard { - public: - explicit ScopeGuard(F f) : f_(std::move(f)) {} - ~ScopeGuard() { std::move(f_)(); } - ScopeGuard(ScopeGuard&& other) : f_(std::move(other.f_)) { Undefined(); } - - private: - F f_; -}; - -struct ScopeGuardGenerator { - template <class F> - ScopeGuard<F> operator=(F f) const { - return ScopeGuard<F>(std::move(f)); - } -}; - -} // namespace internal_scope_guard -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_SCOPE_GUARD_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/serialization.h b/.zsh/themes/powerlevel10k/gitstatus/src/serialization.h deleted file mode 100644 index 42b2409..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/serialization.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_SERIALIZATION_H_ -#define ROMKATV_GITSTATUS_SERIALIZATION_H_ - -namespace gitstatus { - -constexpr char kFieldSep = 31; // ascii 31 is unit separator -constexpr char kMsgSep = 30; // ascii 30 is record separator - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_SERIALIZATION_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/stat.h b/.zsh/themes/powerlevel10k/gitstatus/src/stat.h deleted file mode 100644 index 4f3195a..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/stat.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef ROMKATV_GITSTATUS_STAT_H_ -#define ROMKATV_GITSTATUS_STAT_H_ - -#include <sys/stat.h> - -namespace gitstatus { - -inline const struct timespec& MTim(const struct stat& s) { -#ifdef __APPLE__ - return s.st_mtimespec; -#else - return s.st_mtim; -#endif -} - -inline bool StatEq(const struct stat& x, const struct stat& y) { - return MTim(x).tv_sec == MTim(y).tv_sec && MTim(x).tv_nsec == MTim(y).tv_nsec && - x.st_size == y.st_size && x.st_ino == y.st_ino && x.st_mode == y.st_mode; -} - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_STAT_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/string_cmp.h b/.zsh/themes/powerlevel10k/gitstatus/src/string_cmp.h deleted file mode 100644 index 621c724..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/string_cmp.h +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_STRING_CMP_H_ -#define ROMKATV_GITSTATUS_STRING_CMP_H_ - -#include <string.h> // because there is no std::strcasecmp in C++ - -#include <algorithm> -#include <cctype> -#include <cstddef> -#include <cstring> - -#include "string_view.h" - -namespace gitstatus { - -// WARNING: These routines assume no embedded null characters in StringView. Violations cause UB. - -template <int kCaseSensitive = -1> -struct StrCmp; - -template <> -struct StrCmp<0> { - int operator()(StringView x, StringView y) const { - size_t n = std::min(x.len, y.len); - int cmp = strncasecmp(x.ptr, y.ptr, n); - if (cmp) return cmp; - return static_cast<ssize_t>(x.len) - static_cast<ssize_t>(y.len); - } - - int operator()(StringView x, const char* y) const { - for (const char *p = x.ptr, *e = p + x.len; p != e; ++p, ++y) { - if (int cmp = std::tolower(*p) - std::tolower(*y)) return cmp; - } - return 0 - *y; - } - - int operator()(char x, char y) const { return std::tolower(x) - std::tolower(y); } - int operator()(const char* x, const char* y) const { return strcasecmp(x, y); } - int operator()(const char* x, StringView y) const { return -operator()(y, x); } -}; - -template <> -struct StrCmp<1> { - int operator()(StringView x, StringView y) const { - size_t n = std::min(x.len, y.len); - int cmp = std::memcmp(x.ptr, y.ptr, n); - if (cmp) return cmp; - return static_cast<ssize_t>(x.len) - static_cast<ssize_t>(y.len); - } - - int operator()(StringView x, const char* y) const { - for (const char *p = x.ptr, *e = p + x.len; p != e; ++p, ++y) { - if (int cmp = *p - *y) return cmp; - } - return 0 - *y; - } - - int operator()(char x, char y) const { return x - y; } - int operator()(const char* x, const char* y) const { return std::strcmp(x, y); } - int operator()(const char* x, StringView y) const { return -operator()(y, x); } -}; - -template <> -struct StrCmp<-1> { - explicit StrCmp(bool case_sensitive) : case_sensitive(case_sensitive) {} - - template <class X, class Y> - int operator()(const X& x, const Y& y) const { - return case_sensitive ? StrCmp<1>()(x, y) : StrCmp<0>()(x, y); - } - - bool case_sensitive; -}; - -template <int kCaseSensitive = -1> -struct StrLt : private StrCmp<kCaseSensitive> { - using StrCmp<kCaseSensitive>::StrCmp; - - template <class X, class Y> - bool operator()(const X& x, const Y& y) const { - return StrCmp<kCaseSensitive>::operator()(x, y) < 0; - } -}; - -template <int kCaseSensitive = -1> -struct StrEq : private StrCmp<kCaseSensitive> { - using StrCmp<kCaseSensitive>::StrCmp; - - template <class X, class Y> - bool operator()(const X& x, const Y& y) const { - return StrCmp<kCaseSensitive>::operator()(x, y) == 0; - } - - bool operator()(const StringView& x, const StringView& y) const { - return x.len == y.len && StrCmp<kCaseSensitive>::operator()(x, y) == 0; - } -}; - -template <int kCaseSensitive = -1> -struct Str { - static_assert(kCaseSensitive == 0 || kCaseSensitive == 1, ""); - - static const bool case_sensitive = kCaseSensitive; - - StrCmp<kCaseSensitive> Cmp; - StrLt<kCaseSensitive> Lt; - StrEq<kCaseSensitive> Eq; -}; - -template <int kCaseSensitive> -const bool Str<kCaseSensitive>::case_sensitive; - -template <> -struct Str<-1> { - explicit Str(bool case_sensitive) - : case_sensitive(case_sensitive), - Cmp(case_sensitive), - Lt(case_sensitive), - Eq(case_sensitive) {} - - bool case_sensitive; - - StrCmp<-1> Cmp; - StrLt<-1> Lt; - StrEq<-1> Eq; -}; - -template <class Iter> -void StrSort(Iter begin, Iter end, bool case_sensitive) { - case_sensitive ? std::sort(begin, end, StrLt<true>()) : std::sort(begin, end, StrLt<false>()); -} - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_STRING_CMP_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/string_view.h b/.zsh/themes/powerlevel10k/gitstatus/src/string_view.h deleted file mode 100644 index e29414b..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/string_view.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_STRING_VIEW_H_ -#define ROMKATV_GITSTATUS_STRING_VIEW_H_ - -#include <algorithm> -#include <cstddef> -#include <cstring> -#include <ostream> -#include <string> - -namespace gitstatus { - -// WARNING: StringView must not have embedded null characters. Violations cause UB. -struct StringView { - StringView() : StringView("") {} - - // Requires: !memchr(s.data(), 0, s.size()). - // - // WARNING: The existence of this requirement and the fact that this constructor is implicit - // means it's dangerous to have std::string instances with embedded null characters anywhere - // in the program. If you have an std::string `s` with embedded nulls, an innocent-looking - // `F(s)` might perform an implicit conversion to StringView and land you squarely in the - // Undefined Behavior land. - StringView(const std::string& s) : StringView(s.c_str(), s.size()) {} - - // Requires: !memchr(ptr, 0, len). - StringView(const char* ptr, size_t len) : ptr(ptr), len(len) {} - - // Requires: end >= begin && !memchr(begin, 0, end - begin). - StringView(const char* begin, const char* end) : StringView(begin, end - begin) {} - - // Requires: strchr(s, 0) == s + N. - template <size_t N> - StringView(const char (&s)[N]) : StringView(s, N - 1) { - static_assert(N, ""); - } - - // Explicit because it's the only constructor that isn't O(1). - // Are you sure you don't already known the strings's length? - explicit StringView(const char* ptr) : StringView(ptr, ptr ? std::strlen(ptr) : 0) {} - - bool StartsWith(StringView prefix) const { - return len >= prefix.len && !std::memcmp(ptr, prefix.ptr, prefix.len); - } - - bool EndsWith(StringView suffix) const { - return len >= suffix.len && !std::memcmp(ptr + (len - suffix.len), suffix.ptr, suffix.len); - } - - const char* ptr; - size_t len; -}; - -inline std::ostream& operator<<(std::ostream& strm, StringView s) { - if (s.ptr) strm.write(s.ptr, s.len); - return strm; -} - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_STRING_VIEW_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/strings.cc b/.zsh/themes/powerlevel10k/gitstatus/src/strings.cc deleted file mode 100644 index a68835d..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/strings.cc +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include <cassert> - -#include "strings.h" - -namespace gitstatus { - -void CEscape(std::ostream& strm, const char* begin, const char* end) { - assert(!begin == !end); - if (!begin) return; - for (; begin != end; ++begin) { - const unsigned char c = *begin; - switch (c) { - case '\t': - strm << "\\t"; - continue; - case '\n': - strm << "\\n"; - continue; - case '\r': - strm << "\\r"; - continue; - case '"': - strm << "\\\""; - continue; - case '\'': - strm << "\\'"; - continue; - case '\\': - strm << "\\\\"; - continue; - } - if (c > 31 && c < 127) { - strm << c; - continue; - } - strm << '\\'; - strm << static_cast<char>('0' + ((c >> 6) & 7)); - strm << static_cast<char>('0' + ((c >> 3) & 7)); - strm << static_cast<char>('0' + ((c >> 0) & 7)); - } -} - -void Quote(std::ostream& strm, const char* begin, const char* end) { - assert(!begin == !end); - if (!begin) { - strm << "null"; - return; - } - strm << '"'; - CEscape(strm, begin, end); - strm << '"'; -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/strings.h b/.zsh/themes/powerlevel10k/gitstatus/src/strings.h deleted file mode 100644 index a57cf20..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/strings.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_STRINGS_H_ -#define ROMKATV_GITSTATUS_STRINGS_H_ - -#include <ostream> - -namespace gitstatus { - -// If the pointers are null, prints nothing. -// -// Requires: !begin == !end. -void CEscape(std::ostream& strm, const char* begin, const char* end); - -// If the pointers are null, prints null without quotes. -// -// Requires: !begin == !end. -void Quote(std::ostream& strm, const char* begin, const char* end); - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_STRING_VIEW_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/tag_db.cc b/.zsh/themes/powerlevel10k/gitstatus/src/tag_db.cc deleted file mode 100644 index 52cbaed..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/tag_db.cc +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "tag_db.h" - -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include <algorithm> -#include <cstdlib> -#include <cstring> -#include <iterator> -#include <utility> - -#include "check.h" -#include "dir.h" -#include "git.h" -#include "print.h" -#include "scope_guard.h" -#include "stat.h" -#include "string_cmp.h" -#include "thread_pool.h" -#include "timer.h" - -namespace gitstatus { - -namespace { - -using namespace std::string_literals; - -static constexpr char kTagPrefix[] = "refs/tags/"; - -constexpr int8_t kUnhex[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2 - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, // 3 - 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 4 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 5 - 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 6 -}; - -struct { - bool operator()(const Tag* x, const git_oid& y) const { - return std::memcmp(x->id.id, y.id, GIT_OID_RAWSZ) < 0; - } - bool operator()(const git_oid& x, const Tag* y) const { - return std::memcmp(x.id, y->id.id, GIT_OID_RAWSZ) < 0; - } - bool operator()(const Tag* x, const Tag* y) const { - return std::memcmp(x->id.id, y->id.id, GIT_OID_RAWSZ) < 0; - } -} constexpr ById = {}; - -struct { - bool operator()(const Tag* x, const char* y) const { - return std::strcmp(x->name, y) < 0; - } - bool operator()(const char* x, const Tag* y) const { - return std::strcmp(x, y->name) < 0; - } - bool operator()(const Tag* x, const Tag* y) const { - return std::strcmp(x->name, y->name) < 0; - } -} constexpr ByName = {}; - -void ParseOid(unsigned char* oid, const char* begin, const char* end) { - VERIFY(end >= begin + GIT_OID_HEXSZ); - for (size_t i = 0; i != GIT_OID_HEXSZ; i += 2) { - *oid++ = kUnhex[+begin[i]] << 4 | kUnhex[+begin[i + 1]]; - } -} - -const char* StripTag(const char* ref) { - for (size_t i = 0; i != sizeof(kTagPrefix) - 1; ++i) { - if (*ref++ != kTagPrefix[i]) return nullptr; - } - return ref; -} - -git_refdb* RefDb(git_repository* repo) { - git_refdb* res; - VERIFY(!git_repository_refdb(&res, repo)) << GitError(); - return res; -} - -} // namespace - -TagDb::TagDb(git_repository* repo) - : repo_(repo), - refdb_(RefDb(repo)), - pack_(&pack_arena_), - name2id_(&pack_arena_), - id2name_(&pack_arena_) { - CHECK(repo_ && refdb_); -} - -TagDb::~TagDb() { - Wait(); - git_refdb_free(refdb_); -} - -std::string TagDb::TagForCommit(const git_oid& oid) { - ReadLooseTags(); - UpdatePack(); - - std::string res; - - std::string ref = "refs/tags/"; - size_t prefix_len = ref.size(); - for (const char* tag : loose_tags_) { - ref.resize(prefix_len); - ref += tag; - if (res < tag && TagHasTarget(ref.c_str(), &oid)) res = tag; - } - - if ((std::unique_lock<std::mutex>(mutex_), id2name_dirty_)) { - for (auto it = name2id_.rbegin(); it != name2id_.rend(); ++it) { - if (!memcmp((*it)->id.id, oid.id, GIT_OID_RAWSZ) && !IsLooseTag((*it)->name)) { - if (res < (*it)->name) res = (*it)->name; - break; - } - } - } else { - auto r = std::equal_range(id2name_.begin(), id2name_.end(), oid, ById); - for (auto it = r.first; it != r.second; ++it) { - if (!IsLooseTag((*it)->name) && res < (*it)->name) res = (*it)->name; - } - } - - return res; -} - -void TagDb::ReadLooseTags() { - loose_tags_.clear(); - loose_arena_.Reuse(); - - std::string dirname = git_repository_path(repo_) + "refs/tags"s; - int dir_fd = open(dirname.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC); - if (dir_fd < 0) return; - ON_SCOPE_EXIT(&) { CHECK(!close(dir_fd)) << Errno(); }; - // TODO: recursively traverse directories so that the file refs/tags/foo/bar gets interpreted - // as the tag foo/bar. See https://github.com/romkatv/gitstatus/issues/254. - (void)ListDir(dir_fd, loose_arena_, loose_tags_, /* precompose_unicode = */ false, - /* case_sensitive = */ true); -} - -void TagDb::UpdatePack() { - auto Reset = [&] { - auto Wipe = [](auto& x) { - x.clear(); - x.shrink_to_fit(); - }; - Wait(); - Wipe(pack_); - Wipe(name2id_); - Wipe(id2name_); - pack_arena_.Reuse(); - std::memset(&pack_stat_, 0, sizeof(pack_stat_)); - }; - - std::string pack_path = git_repository_path(repo_) + "packed-refs"s; - struct stat st; - if (stat(pack_path.c_str(), &st)) { - Reset(); - return; - } - if (StatEq(pack_stat_, st)) return; - - Reset(); - - try { - while (true) { - LOG(INFO) << "Parsing " << Print(pack_path); - int fd = open(pack_path.c_str(), O_RDONLY | O_CLOEXEC); - VERIFY(fd >= 0); - ON_SCOPE_EXIT(&) { CHECK(!close(fd)) << Errno(); }; - pack_.resize(st.st_size + 1); - ssize_t n = read(fd, &pack_[0], st.st_size + 1); - VERIFY(n >= 0) << Errno(); - VERIFY(!fstat(fd, &pack_stat_)) << Errno(); - if (!StatEq(st, pack_stat_)) { - st = pack_stat_; - continue; - } - VERIFY(n == st.st_size); - pack_.pop_back(); - break; - } - ParsePack(); - } catch (const Exception&) { - Reset(); - throw; - } -} - -void TagDb::ParsePack() { - char* p = &pack_[0]; - char* e = p + pack_.size(); - - // Usually packed-refs starts with the following line: - // - // # pack-refs with: peeled fully-peeled sorted - // - // However, some users can produce pack-refs without this line. - // See https://github.com/romkatv/powerlevel10k/issues/1428. - // I don't know how they do it. Without the header line we cannot - // assume that refs are sorted, which isn't a big deal because we - // can just sort them. What's worse is that refs cannot be assumed - // to be fully-peeled. We don't want to peel them, so we just drop - // all tags. - if (*p != '#') { - LOG(WARN) << "packed-refs doesn't have a header. Won't resolve tags."; - return; - } - - char* eol = std::strchr(p, '\n'); - if (!eol) return; - *eol = 0; - if (!std::strstr(p, " fully-peeled") || !std::strstr(p, " sorted")) { - LOG(WARN) << "packed-refs has unexpected header. Won't resolve tags."; - } - p = eol + 1; - - name2id_.reserve(pack_.size() / 128); - id2name_.reserve(pack_.size() / 128); - - std::vector<Tag*> idx; - idx.reserve(pack_.size() / 128); - - while (p != e) { - Tag* tag = pack_arena_.Allocate<Tag>(); - ParseOid(tag->id.id, p, e); - p += GIT_OID_HEXSZ; - VERIFY(*p++ == ' '); - const char* ref = p; - VERIFY(p = std::strchr(p, '\n')); - p[p[-1] == '\r' ? -1 : 0] = 0; - ++p; - if (*p == '^') { - ParseOid(tag->id.id, p + 1, e); - p += GIT_OID_HEXSZ + 1; - if (p != e) { - VERIFY((p = std::strchr(p, '\n'))); - ++p; - } - } - tag->name = StripTag(ref); - if (!tag->name) continue; - name2id_.push_back(tag); - id2name_.push_back(tag); - } - - if (!std::is_sorted(name2id_.begin(), name2id_.end(), ByName)) { - // "sorted" in the header of packed-refs promisses that this won't trigger. - std::sort(name2id_.begin(), name2id_.end(), ByName); - } - - id2name_dirty_ = true; - GlobalThreadPool()->Schedule([this] { - std::sort(id2name_.begin(), id2name_.end(), ById); - std::unique_lock<std::mutex> lock(mutex_); - CHECK(id2name_dirty_); - id2name_dirty_ = false; - cv_.notify_one(); - }); -} - -void TagDb::Wait() { - std::unique_lock<std::mutex> lock(mutex_); - while (id2name_dirty_) cv_.wait(lock); -} - -bool TagDb::IsLooseTag(const char* name) const { - return std::binary_search(loose_tags_.begin(), loose_tags_.end(), name, - [](const char* a, const char* b) { return std::strcmp(a, b) < 0; }); -} - -bool TagDb::TagHasTarget(const char* name, const git_oid* target) const { - static constexpr size_t kMaxDerefCount = 10; - - git_reference* ref; - if (git_refdb_lookup(&ref, refdb_, name)) return false; - ON_SCOPE_EXIT(&) { git_reference_free(ref); }; - - for (int i = 0; i != kMaxDerefCount && git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC; ++i) { - git_reference* dst; - const char* ref_name = git_reference_name(ref); - if (git_refdb_lookup(&dst, refdb_, ref_name)) { - const char* tag_name = StripTag(ref_name); - auto it = std::lower_bound(name2id_.begin(), name2id_.end(), tag_name, ByName); - return it != name2id_.end() && !strcmp((*it)->name, tag_name) && !IsLooseTag(tag_name) && - git_oid_equal(&(*it)->id, target); - } - git_reference_free(ref); - ref = dst; - } - - if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) return false; - const git_oid* oid = git_reference_target_peel(ref) ?: git_reference_target(ref); - if (git_oid_equal(oid, target)) return true; - - for (int i = 0; i != kMaxDerefCount; ++i) { - git_tag* tag; - if (git_tag_lookup(&tag, repo_, oid)) return false; - ON_SCOPE_EXIT(&) { git_tag_free(tag); }; - if (git_tag_target_type(tag) == GIT_OBJECT_COMMIT) { - return git_oid_equal(git_tag_target_id(tag), target); - } - oid = git_tag_target_id(tag); - } - - return false; -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/tag_db.h b/.zsh/themes/powerlevel10k/gitstatus/src/tag_db.h deleted file mode 100644 index b5b14a4..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/tag_db.h +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_TAG_DB_H_ -#define ROMKATV_GITSTATUS_TAG_DB_H_ - -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include <git2.h> - -#include <condition_variable> -#include <cstring> -#include <mutex> -#include <string> -#include <vector> - -#include "arena.h" - -namespace gitstatus { - -struct Tag { - const char* name; - git_oid id; -}; - -class TagDb { - public: - explicit TagDb(git_repository* repo); - TagDb(TagDb&&) = delete; - ~TagDb(); - - std::string TagForCommit(const git_oid& oid); - - private: - void ReadLooseTags(); - void UpdatePack(); - void ParsePack(); - void Wait(); - - bool IsLooseTag(const char* name) const; - - bool TagHasTarget(const char* name, const git_oid* target) const; - - git_repository* const repo_; - git_refdb* const refdb_; - - Arena pack_arena_; - struct stat pack_stat_ = {}; - WithArena<std::string> pack_; - WithArena<std::vector<const Tag*>> name2id_; - WithArena<std::vector<const Tag*>> id2name_; - - Arena loose_arena_; - std::vector<char*> loose_tags_; - - std::mutex mutex_; - std::condition_variable cv_; - bool id2name_dirty_ = false; -}; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_TAG_DB_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/thread_pool.cc b/.zsh/themes/powerlevel10k/gitstatus/src/thread_pool.cc deleted file mode 100644 index b37eb20..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/thread_pool.cc +++ /dev/null @@ -1,87 +0,0 @@ -#include "thread_pool.h" - -#include <cassert> -#include <utility> - -#include "check.h" -#include "logging.h" - -namespace gitstatus { - -ThreadPool::ThreadPool(size_t num_threads) : num_inflight_(num_threads) { - for (size_t i = 0; i != num_threads; ++i) { - threads_.emplace_back([=]() { Loop(i + 1); }); - } -} - -ThreadPool::~ThreadPool() { - { - std::lock_guard<std::mutex> lock(mutex_); - exit_ = true; - } - cv_.notify_all(); - sleeper_cv_.notify_one(); - for (std::thread& t : threads_) t.join(); -} - -void ThreadPool::Schedule(Time t, std::function<void()> f) { - std::condition_variable* wake = nullptr; - { - std::unique_lock<std::mutex> lock(mutex_); - work_.push(Work{std::move(t), ++last_idx_, std::move(f)}); - if (work_.top().idx == last_idx_) wake = have_sleeper_ ? &sleeper_cv_ : &cv_; - } - if (wake) wake->notify_one(); -} - -void ThreadPool::Loop(size_t tid) { - auto Next = [&]() -> std::function<void()> { - std::unique_lock<std::mutex> lock(mutex_); - --num_inflight_; - if (work_.empty() && num_inflight_ == 0) idle_cv_.notify_all(); - while (true) { - if (exit_) return nullptr; - if (work_.empty()) { - cv_.wait(lock); - continue; - } - Time now = Clock::now(); - const Work& top = work_.top(); - if (top.t <= now) { - std::function<void()> res = std::move(top.f); - work_.pop(); - ++num_inflight_; - bool notify = !work_.empty() && !have_sleeper_; - lock.unlock(); - if (notify) cv_.notify_one(); - return res; - } - if (have_sleeper_) { - cv_.wait(lock); - continue; - } - have_sleeper_ = true; - sleeper_cv_.wait_until(lock, top.t); - assert(have_sleeper_); - have_sleeper_ = false; - } - }; - while (std::function<void()> f = Next()) f(); -} - -void ThreadPool::Wait() { - std::unique_lock<std::mutex> lock(mutex_); - idle_cv_.wait(lock, [&] { return work_.empty() && num_inflight_ == 0; }); -} - -static ThreadPool* g_thread_pool = nullptr; - -void InitGlobalThreadPool(size_t num_threads) { - CHECK(!g_thread_pool); - LOG(INFO) << "Spawning " << num_threads << " thread(s)"; - g_thread_pool = new ThreadPool(num_threads); -} - -ThreadPool* GlobalThreadPool() { return g_thread_pool; } - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/thread_pool.h b/.zsh/themes/powerlevel10k/gitstatus/src/thread_pool.h deleted file mode 100644 index 1e39b91..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/thread_pool.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef ROMKATV_GITSTATUS_THREAD_POOL_H_ -#define ROMKATV_GITSTATUS_THREAD_POOL_H_ - -#include <condition_variable> -#include <cstddef> -#include <cstdint> -#include <functional> -#include <mutex> -#include <queue> -#include <thread> -#include <tuple> -#include <utility> - -#include "time.h" - -namespace gitstatus { - -class ThreadPool { - public: - explicit ThreadPool(size_t num_threads); - ThreadPool(ThreadPool&&) = delete; - - // Waits for the currently running functions to finish. - // Does NOT wait for the queue of functions to drain. - // If you want the latter, call Wait() manually. - ~ThreadPool(); - - // Runs `f` on one of the threads at or after time `t`. Can be called - // from any thread. Can be called concurrently. - // - // Does not block. - void Schedule(Time t, std::function<void()> f); - - void Schedule(std::function<void()> f) { Schedule(Clock::now(), std::move(f)); } - - // Blocks until the work queue is empty and there are no currently - // running functions. - void Wait(); - - size_t num_threads() const { return threads_.size(); } - - private: - struct Work { - bool operator<(const Work& w) const { return std::tie(w.t, w.idx) < std::tie(t, idx); } - Time t; - int64_t idx; - mutable std::function<void()> f; - }; - - void Loop(size_t tid); - - int64_t last_idx_ = 0; - int64_t num_inflight_; - bool exit_ = false; - // Do we have a thread waiting on sleeper_cv_? - bool have_sleeper_ = false; - std::mutex mutex_; - // Any number of threads can wait on this condvar. Always without a timeout. - std::condition_variable cv_; - // At most one thread can wait on this condvar at a time. Always with a timeout. - std::condition_variable sleeper_cv_; - // Signalled when the work queue is empty and there is nothing inflight. - std::condition_variable idle_cv_; - std::priority_queue<Work> work_; - std::vector<std::thread> threads_; -}; - -void InitGlobalThreadPool(size_t num_threads); - -ThreadPool* GlobalThreadPool(); - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_THREAD_POOL_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/time.h b/.zsh/themes/powerlevel10k/gitstatus/src/time.h deleted file mode 100644 index cdd5fa2..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/time.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ROMKATV_GITSTATUS_TIME_H_ -#define ROMKATV_GITSTATUS_TIME_H_ - -#include <chrono> - -namespace gitstatus { - -using Clock = std::chrono::steady_clock; -using Time = Clock::time_point; -using Duration = Clock::duration; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_TIME_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/timer.cc b/.zsh/themes/powerlevel10k/gitstatus/src/timer.cc deleted file mode 100644 index 0e9f64e..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/timer.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#include "timer.h" - -#include <sys/resource.h> -#include <sys/time.h> -#include <time.h> - -#include <cmath> -#include <limits> - -#include "check.h" -#include "logging.h" - -namespace gitstatus { - -namespace { - -double CpuTimeMs() { - auto ToMs = [](const timeval& tv) { return 1e3 * tv.tv_sec + 1e-3 * tv.tv_usec; }; - rusage usage = {}; - CHECK(getrusage(RUSAGE_SELF, &usage) == 0) << Errno(); - return ToMs(usage.ru_utime) + ToMs(usage.ru_stime); -} - -double WallTimeMs() { - // An attempt to call clock_gettime on an ancient version of MacOS fails at runtime. - // It's possible to detect the presence of clock_gettime at runtime but I don't have - // an ancient MacOS to test the code. Hence this. -#ifdef __APPLE__ - return std::numeric_limits<double>::quiet_NaN(); -#else - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return 1e3 * ts.tv_sec + 1e-6 * ts.tv_nsec; -#endif -} - -} // namespace - -void Timer::Start() { - cpu_ = CpuTimeMs(); - wall_ = WallTimeMs(); -} - -void Timer::Report(const char* msg) { - double cpu = CpuTimeMs() - cpu_; - if (std::isnan(wall_)) { - LOG(INFO) << "Timing for: " << msg << ": " << cpu << "ms cpu"; - } else { - double wall = WallTimeMs() - wall_; - LOG(INFO) << "Timing for: " << msg << ": " << cpu << "ms cpu, " << wall << "ms wall"; - } - Start(); -} - -} // namespace gitstatus diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/timer.h b/.zsh/themes/powerlevel10k/gitstatus/src/timer.h deleted file mode 100644 index 51c557c..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/timer.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_TIMER_H_ -#define ROMKATV_GITSTATUS_TIMER_H_ - -namespace gitstatus { - -class Timer { - public: - Timer() { Start(); } - void Start(); - void Report(const char* msg); - - private: - double cpu_; - double wall_; -}; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_TIMER_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/src/tribool.h b/.zsh/themes/powerlevel10k/gitstatus/src/tribool.h deleted file mode 100644 index f06daf3..0000000 --- a/.zsh/themes/powerlevel10k/gitstatus/src/tribool.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2019 Roman Perepelitsa. -// -// This file is part of GitStatus. -// -// GitStatus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// GitStatus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GitStatus. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ROMKATV_GITSTATUS_TRIBOOL_H_ -#define ROMKATV_GITSTATUS_TRIBOOL_H_ - -namespace gitstatus { - -enum class Tribool : int { kFalse = 0, kTrue = 1, kUnknown = -1 }; - -} // namespace gitstatus - -#endif // ROMKATV_GITSTATUS_TRIBOOL_H_ diff --git a/.zsh/themes/powerlevel10k/gitstatus/usrbin/.gitkeep b/.zsh/themes/powerlevel10k/gitstatus/usrbin/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/.zsh/themes/powerlevel10k/internal/configure.zsh b/.zsh/themes/powerlevel10k/internal/configure.zsh deleted file mode 100644 index 3e880f2..0000000 --- a/.zsh/themes/powerlevel10k/internal/configure.zsh +++ /dev/null @@ -1,85 +0,0 @@ -# Fewer than 47 columns will probably work. Haven't tried it. -typeset -gr __p9k_wizard_columns=47 -# The bottleneck is ask_tails with nerd fonts. Everything else works fine with 12 lines. -typeset -gr __p9k_wizard_lines=14 -typeset -gr __p9k_zd=${ZDOTDIR:-$HOME} -typeset -gr __p9k_zd_u=${${${(q)__p9k_zd}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%} -typeset -gr __p9k_zshrc=${${:-$__p9k_zd/.zshrc}:A} -typeset -gr __p9k_zshrc_u=$__p9k_zd_u/.zshrc -typeset -gr __p9k_root_dir_u=${${${(q)__p9k_root_dir}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%} - -function _p9k_can_configure() { - [[ $1 == '-q' ]] && local -i q=1 || local -i q=0 - function $0_error() { - (( q )) || print -rP "%1F[ERROR]%f %Bp10k configure%b: $1" >&2 - } - typeset -g __p9k_cfg_path_o=${POWERLEVEL9K_CONFIG_FILE:=${ZDOTDIR:-~}/.p10k.zsh} - typeset -g __p9k_cfg_basename=${__p9k_cfg_path_o:t} - typeset -g __p9k_cfg_path=${__p9k_cfg_path_o:A} - typeset -g __p9k_cfg_path_u=${${${(q)__p9k_cfg_path_o}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%} - { - [[ -o multibyte ]] || { $0_error "multibyte option is not set"; return 1 } - [[ -e $__p9k_zd ]] || { $0_error "$__p9k_zd_u does not exist"; return 1 } - [[ -d $__p9k_zd ]] || { $0_error "$__p9k_zd_u is not a directory"; return 1 } - [[ ! -d $__p9k_cfg_path ]] || { $0_error "$__p9k_cfg_path_u is a directory"; return 1 } - [[ ! -d $__p9k_zshrc ]] || { $0_error "$__p9k_zshrc_u is a directory"; return 1 } - - local dir=${__p9k_cfg_path:h} - while [[ ! -e $dir && $dir != ${dir:h} ]]; do dir=${dir:h}; done - if [[ ! -d $dir ]]; then - $0_error "cannot create $__p9k_cfg_path_u because ${dir//\%/%%} is not a directory" - return 1 - fi - if [[ ! -w $dir ]]; then - $0_error "cannot create $__p9k_cfg_path_u because ${dir//\%/%%} is readonly" - return 1 - fi - - [[ ! -e $__p9k_cfg_path || -f $__p9k_cfg_path || -h $__p9k_cfg_path ]] || { - $0_error "$__p9k_cfg_path_u is a special file" - return 1 - } - [[ ! -e $__p9k_zshrc || -f $__p9k_zshrc || -h $__p9k_zshrc ]] || { - $0_error "$__p9k_zshrc_u a special file" - return 1 - } - [[ ! -e $__p9k_zshrc || -r $__p9k_zshrc ]] || { - $0_error "$__p9k_zshrc_u is not readable" - return 1 - } - local style - for style in lean lean-8colors classic rainbow pure; do - [[ -r $__p9k_root_dir/config/p10k-$style.zsh ]] || { - $0_error "$__p9k_root_dir_u/config/p10k-$style.zsh is not readable" - return 1 - } - done - - (( LINES >= __p9k_wizard_lines && COLUMNS >= __p9k_wizard_columns )) || { - $0_error "terminal size too small; must be at least $__p9k_wizard_columns columns by $__p9k_wizard_lines lines" - return 1 - } - [[ -t 0 && -t 1 ]] || { - $0_error "no TTY" - return 2 - } - return 0 - } always { - unfunction $0_error - } -} - -function p9k_configure() { - eval "$__p9k_intro" - _p9k_can_configure || return - ( - set -- -f - builtin source $__p9k_root_dir/internal/wizard.zsh - ) - local ret=$? - case $ret in - 0) builtin source $__p9k_cfg_path; _p9k__force_must_init=1;; - 69) return 0;; - *) return $ret;; - esac -} diff --git a/.zsh/themes/powerlevel10k/internal/icons.zsh b/.zsh/themes/powerlevel10k/internal/icons.zsh deleted file mode 100644 index d38cf7b..0000000 --- a/.zsh/themes/powerlevel10k/internal/icons.zsh +++ /dev/null @@ -1,881 +0,0 @@ -typeset -gA icons - -function _p9k_init_icons() { - [[ -n ${POWERLEVEL9K_MODE-} || ${langinfo[CODESET]} == (utf|UTF)(-|)8 ]] || local POWERLEVEL9K_MODE=ascii - [[ $_p9k__icon_mode == $POWERLEVEL9K_MODE/$POWERLEVEL9K_LEGACY_ICON_SPACING/$POWERLEVEL9K_ICON_PADDING ]] && return - typeset -g _p9k__icon_mode=$POWERLEVEL9K_MODE/$POWERLEVEL9K_LEGACY_ICON_SPACING/$POWERLEVEL9K_ICON_PADDING - - if [[ $POWERLEVEL9K_LEGACY_ICON_SPACING == true ]]; then - local s= - local q=' ' - else - local s=' ' - local q= - fi - - case $POWERLEVEL9K_MODE in - 'flat'|'awesome-patched') - # Awesome-Patched Font required! See: - # https://github.com/gabrielelana/awesome-terminal-fonts/tree/patching-strategy/patched - icons=( - RULER_CHAR '\u2500' # ─ - LEFT_SEGMENT_SEPARATOR '\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR '\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  - CARRIAGE_RETURN_ICON '\u21B5'$s # ↵ - ROOT_ICON '\uE801' #  - SUDO_ICON '\uE0A2' #  - RUBY_ICON '\uE847 ' #  - AWS_ICON '\uE895'$s #  - AWS_EB_ICON '\U1F331'$q # 🌱 - BACKGROUND_JOBS_ICON '\uE82F ' #  - TEST_ICON '\uE891'$s #  - TODO_ICON '\u2611' # ☑ - BATTERY_ICON '\uE894'$s #  - DISK_ICON '\uE1AE ' #  - OK_ICON '\u2714' # ✔ - FAIL_ICON '\u2718' # ✘ - SYMFONY_ICON 'SF' - NODE_ICON '\u2B22'$s # ⬢ - NODEJS_ICON '\u2B22'$s # ⬢ - MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uE26E'$s #  - WINDOWS_ICON '\uE26F'$s #  - FREEBSD_ICON '\U1F608'$q # 😈 - ANDROID_ICON '\uE270'$s #  - LINUX_ICON '\uE271'$s #  - LINUX_ARCH_ICON '\uE271'$s #  - LINUX_DEBIAN_ICON '\uE271'$s #  - LINUX_RASPBIAN_ICON '\uE271'$s #  - LINUX_UBUNTU_ICON '\uE271'$s #  - LINUX_CENTOS_ICON '\uE271'$s #  - LINUX_COREOS_ICON '\uE271'$s #  - LINUX_ELEMENTARY_ICON '\uE271'$s #  - LINUX_MINT_ICON '\uE271'$s #  - LINUX_FEDORA_ICON '\uE271'$s #  - LINUX_GENTOO_ICON '\uE271'$s #  - LINUX_MAGEIA_ICON '\uE271'$s #  - LINUX_NIXOS_ICON '\uE271'$s #  - LINUX_MANJARO_ICON '\uE271'$s #  - LINUX_DEVUAN_ICON '\uE271'$s #  - LINUX_ALPINE_ICON '\uE271'$s #  - LINUX_AOSC_ICON '\uE271'$s #  - LINUX_OPENSUSE_ICON '\uE271'$s #  - LINUX_SABAYON_ICON '\uE271'$s #  - LINUX_SLACKWARE_ICON '\uE271'$s #  - LINUX_VOID_ICON '\uE271'$s #  - LINUX_ARTIX_ICON '\uE271'$s #  - LINUX_RHEL_ICON '\uE271'$s #  - LINUX_AMZN_ICON '\uE271'$s #  - SUNOS_ICON '\U1F31E'$q # 🌞 - HOME_ICON '\uE12C'$s #  - HOME_SUB_ICON '\uE18D'$s #  - FOLDER_ICON '\uE818'$s #  - NETWORK_ICON '\uE1AD'$s #  - ETC_ICON '\uE82F'$s #  - LOAD_ICON '\uE190 ' #  - SWAP_ICON '\uE87D'$s #  - RAM_ICON '\uE1E2 ' #  - SERVER_ICON '\uE895'$s #  - VCS_UNTRACKED_ICON '\uE16C'$s #  - VCS_UNSTAGED_ICON '\uE17C'$s #  - VCS_STAGED_ICON '\uE168'$s #  - VCS_STASH_ICON '\uE133 ' #  - #VCS_INCOMING_CHANGES_ICON '\uE1EB ' #  - #VCS_INCOMING_CHANGES_ICON '\uE80D ' #  - VCS_INCOMING_CHANGES_ICON '\uE131 ' #  - #VCS_OUTGOING_CHANGES_ICON '\uE1EC ' #  - #VCS_OUTGOING_CHANGES_ICON '\uE80E ' #  - VCS_OUTGOING_CHANGES_ICON '\uE132 ' #  - VCS_TAG_ICON '\uE817 ' #  - VCS_BOOKMARK_ICON '\uE87B' #  - VCS_COMMIT_ICON '\uE821 ' #  - VCS_BRANCH_ICON '\uE220 ' #  - VCS_REMOTE_BRANCH_ICON '\u2192' # → - VCS_LOADING_ICON '' - VCS_GIT_ICON '\uE20E ' #  - VCS_GIT_GITHUB_ICON '\uE20E ' # - VCS_GIT_BITBUCKET_ICON '\uE20E ' # - VCS_GIT_GITLAB_ICON '\uE20E ' # - VCS_HG_ICON '\uE1C3 ' #  - VCS_SVN_ICON 'svn'$q - RUST_ICON 'R' - PYTHON_ICON '\uE63C'$s #  (doesn't always work) - SWIFT_ICON 'Swift' - GO_ICON 'Go' - GOLANG_ICON 'Go' - PUBLIC_IP_ICON 'IP' - LOCK_ICON '\UE138' #  - NORDVPN_ICON '\UE138' #  - EXECUTION_TIME_ICON '\UE89C'$s #  - SSH_ICON 'ssh' - VPN_ICON '\UE138' - KUBERNETES_ICON '\U2388'$s # ⎈ - DROPBOX_ICON '\UF16B'$s #  (doesn't always work) - DATE_ICON '\uE184'$s #  - TIME_ICON '\uE12E'$s #  - JAVA_ICON '\U2615' # ☕︎ - LARAVEL_ICON '' - RANGER_ICON '\u2B50' # ⭐ - MIDNIGHT_COMMANDER_ICON 'mc' - VIM_ICON 'vim' - TERRAFORM_ICON 'tf' - PROXY_ICON '\u2194' # ↔ - DOTNET_ICON '.NET' - DOTNET_CORE_ICON '.NET' - AZURE_ICON '\u2601' # ☁ - DIRENV_ICON '\u25BC' # ▼ - FLUTTER_ICON 'F' - GCLOUD_ICON 'G' - LUA_ICON 'lua' - PERL_ICON 'perl' - NNN_ICON 'nnn' - XPLR_ICON 'xplr' - TIMEWARRIOR_ICON 'tw' - TASKWARRIOR_ICON 'task' - NIX_SHELL_ICON 'nix' - WIFI_ICON 'WiFi' - ERLANG_ICON 'erl' - ELIXIR_ICON 'elixir' - POSTGRES_ICON 'postgres' - PHP_ICON 'php' - HASKELL_ICON 'hs' - PACKAGE_ICON 'pkg' - JULIA_ICON 'jl' - SCALA_ICON 'scala' - TOOLBOX_ICON '\u2B22' # ⬢ - ARCH_ICON 'arch' - ) - ;; - 'awesome-fontconfig') - # fontconfig with awesome-font required! See - # https://github.com/gabrielelana/awesome-terminal-fonts - icons=( - RULER_CHAR '\u2500' # ─ - LEFT_SEGMENT_SEPARATOR '\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR '\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  - CARRIAGE_RETURN_ICON '\u21B5' # ↵ - ROOT_ICON '\uF201'$s #  - SUDO_ICON '\uF09C'$s #  - RUBY_ICON '\uF219 ' #  - AWS_ICON '\uF270'$s #  - AWS_EB_ICON '\U1F331'$q # 🌱 - BACKGROUND_JOBS_ICON '\uF013 ' #  - TEST_ICON '\uF291'$s #  - TODO_ICON '\u2611' # ☑ - BATTERY_ICON '\U1F50B' # 🔋 - DISK_ICON '\uF0A0 ' #  - OK_ICON '\u2714' # ✔ - FAIL_ICON '\u2718' # ✘ - SYMFONY_ICON 'SF' - NODE_ICON '\u2B22' # ⬢ - NODEJS_ICON '\u2B22' # ⬢ - MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uF179'$s #  - WINDOWS_ICON '\uF17A'$s #  - FREEBSD_ICON '\U1F608'$q # 😈 - ANDROID_ICON '\uE17B'$s #  (doesn't always work) - LINUX_ICON '\uF17C'$s #  - LINUX_ARCH_ICON '\uF17C'$s #  - LINUX_DEBIAN_ICON '\uF17C'$s #  - LINUX_RASPBIAN_ICON '\uF17C'$s #  - LINUX_UBUNTU_ICON '\uF17C'$s #  - LINUX_CENTOS_ICON '\uF17C'$s #  - LINUX_COREOS_ICON '\uF17C'$s #  - LINUX_ELEMENTARY_ICON '\uF17C'$s #  - LINUX_MINT_ICON '\uF17C'$s #  - LINUX_FEDORA_ICON '\uF17C'$s #  - LINUX_GENTOO_ICON '\uF17C'$s #  - LINUX_MAGEIA_ICON '\uF17C'$s #  - LINUX_NIXOS_ICON '\uF17C'$s #  - LINUX_MANJARO_ICON '\uF17C'$s #  - LINUX_DEVUAN_ICON '\uF17C'$s #  - LINUX_ALPINE_ICON '\uF17C'$s #  - LINUX_AOSC_ICON '\uF17C'$s #  - LINUX_OPENSUSE_ICON '\uF17C'$s #  - LINUX_SABAYON_ICON '\uF17C'$s #  - LINUX_SLACKWARE_ICON '\uF17C'$s #  - LINUX_VOID_ICON '\uF17C'$s #  - LINUX_ARTIX_ICON '\uF17C'$s #  - LINUX_RHEL_ICON '\uF17C'$s #  - LINUX_AMZN_ICON '\uF17C'$s #  - SUNOS_ICON '\uF185 ' #  - HOME_ICON '\uF015'$s #  - HOME_SUB_ICON '\uF07C'$s #  - FOLDER_ICON '\uF115'$s #  - ETC_ICON '\uF013 ' #  - NETWORK_ICON '\uF09E'$s #  - LOAD_ICON '\uF080 ' #  - SWAP_ICON '\uF0E4'$s #  - RAM_ICON '\uF0E4'$s #  - SERVER_ICON '\uF233'$s #  - VCS_UNTRACKED_ICON '\uF059'$s #  - VCS_UNSTAGED_ICON '\uF06A'$s #  - VCS_STAGED_ICON '\uF055'$s #  - VCS_STASH_ICON '\uF01C ' #  - VCS_INCOMING_CHANGES_ICON '\uF01A ' #  - VCS_OUTGOING_CHANGES_ICON '\uF01B ' #  - VCS_TAG_ICON '\uF217 ' #  - VCS_BOOKMARK_ICON '\uF27B ' #  - VCS_COMMIT_ICON '\uF221 ' #  - VCS_BRANCH_ICON '\uF126 ' #  - VCS_REMOTE_BRANCH_ICON '\u2192' # → - VCS_LOADING_ICON '' - VCS_GIT_ICON '\uF1D3 ' #  - VCS_GIT_GITHUB_ICON '\uF113 ' #  - VCS_GIT_BITBUCKET_ICON '\uF171 ' #  - VCS_GIT_GITLAB_ICON '\uF296 ' #  - VCS_HG_ICON '\uF0C3 ' #  - VCS_SVN_ICON 'svn'$q - RUST_ICON '\uE6A8' #  - PYTHON_ICON '\uE63C'$s #  - SWIFT_ICON 'Swift' - GO_ICON 'Go' - GOLANG_ICON 'Go' - PUBLIC_IP_ICON 'IP' - LOCK_ICON '\UF023' #  - NORDVPN_ICON '\UF023' #  - EXECUTION_TIME_ICON '\uF253'$s #  - SSH_ICON 'ssh' - VPN_ICON '\uF023' - KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\UF16B'$s #  - DATE_ICON '\uF073 ' #  - TIME_ICON '\uF017 ' #  - JAVA_ICON '\U2615' # ☕︎ - LARAVEL_ICON '' - RANGER_ICON '\u2B50' # ⭐ - MIDNIGHT_COMMANDER_ICON 'mc' - VIM_ICON 'vim' - TERRAFORM_ICON 'tf' - PROXY_ICON '\u2194' # ↔ - DOTNET_ICON '.NET' - DOTNET_CORE_ICON '.NET' - AZURE_ICON '\u2601' # ☁ - DIRENV_ICON '\u25BC' # ▼ - FLUTTER_ICON 'F' - GCLOUD_ICON 'G' - LUA_ICON 'lua' - PERL_ICON 'perl' - NNN_ICON 'nnn' - XPLR_ICON 'xplr' - TIMEWARRIOR_ICON 'tw' - TASKWARRIOR_ICON 'task' - NIX_SHELL_ICON 'nix' - WIFI_ICON 'WiFi' - ERLANG_ICON 'erl' - ELIXIR_ICON 'elixir' - POSTGRES_ICON 'postgres' - PHP_ICON 'php' - HASKELL_ICON 'hs' - PACKAGE_ICON 'pkg' - JULIA_ICON 'jl' - SCALA_ICON 'scala' - TOOLBOX_ICON '\u2B22' # ⬢ - ARCH_ICON 'arch' - ) - ;; - 'awesome-mapped-fontconfig') - # mapped fontconfig with awesome-font required! See - # https://github.com/gabrielelana/awesome-terminal-fonts - # don't forget to source the font maps in your startup script - if [ -z "$AWESOME_GLYPHS_LOADED" ]; then - echo "Powerlevel9k warning: Awesome-Font mappings have not been loaded. - Source a font mapping in your shell config, per the Awesome-Font docs - (https://github.com/gabrielelana/awesome-terminal-fonts), - Or use a different Powerlevel9k font configuration."; - fi - icons=( - RULER_CHAR '\u2500' # ─ - LEFT_SEGMENT_SEPARATOR '\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR '\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  - CARRIAGE_RETURN_ICON '\u21B5' # ↵ - ROOT_ICON "${CODEPOINT_OF_OCTICONS_ZAP:+\\u$CODEPOINT_OF_OCTICONS_ZAP}" - SUDO_ICON "${CODEPOINT_OF_AWESOME_UNLOCK:+\\u$CODEPOINT_OF_AWESOME_UNLOCK$s}" - RUBY_ICON "${CODEPOINT_OF_OCTICONS_RUBY:+\\u$CODEPOINT_OF_OCTICONS_RUBY }" - AWS_ICON "${CODEPOINT_OF_AWESOME_SERVER:+\\u$CODEPOINT_OF_AWESOME_SERVER$s}" - AWS_EB_ICON '\U1F331'$q # 🌱 - BACKGROUND_JOBS_ICON "${CODEPOINT_OF_AWESOME_COG:+\\u$CODEPOINT_OF_AWESOME_COG }" - TEST_ICON "${CODEPOINT_OF_AWESOME_BUG:+\\u$CODEPOINT_OF_AWESOME_BUG$s}" - TODO_ICON "${CODEPOINT_OF_AWESOME_CHECK_SQUARE_O:+\\u$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O$s}" - BATTERY_ICON "${CODEPOINT_OF_AWESOME_BATTERY_FULL:+\\U$CODEPOINT_OF_AWESOME_BATTERY_FULL$s}" - DISK_ICON "${CODEPOINT_OF_AWESOME_HDD_O:+\\u$CODEPOINT_OF_AWESOME_HDD_O }" - OK_ICON "${CODEPOINT_OF_AWESOME_CHECK:+\\u$CODEPOINT_OF_AWESOME_CHECK$s}" - FAIL_ICON "${CODEPOINT_OF_AWESOME_TIMES:+\\u$CODEPOINT_OF_AWESOME_TIMES}" - SYMFONY_ICON 'SF' - NODE_ICON '\u2B22' # ⬢ - NODEJS_ICON '\u2B22' # ⬢ - MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON "${CODEPOINT_OF_AWESOME_APPLE:+\\u$CODEPOINT_OF_AWESOME_APPLE$s}" - FREEBSD_ICON '\U1F608'$q # 😈 - LINUX_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_ARCH_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_DEBIAN_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_RASPBIAN_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_UBUNTU_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_CENTOS_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_COREOS_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_ELEMENTARY_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_MINT_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_FEDORA_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_GENTOO_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_MAGEIA_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_NIXOS_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_MANJARO_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_DEVUAN_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_ALPINE_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_AOSC_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_OPENSUSE_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_SABAYON_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_SLACKWARE_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_VOID_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_ARTIX_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_RHEL_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_AMZN_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - SUNOS_ICON "${CODEPOINT_OF_AWESOME_SUN_O:+\\u$CODEPOINT_OF_AWESOME_SUN_O }" - HOME_ICON "${CODEPOINT_OF_AWESOME_HOME:+\\u$CODEPOINT_OF_AWESOME_HOME$s}" - HOME_SUB_ICON "${CODEPOINT_OF_AWESOME_FOLDER_OPEN:+\\u$CODEPOINT_OF_AWESOME_FOLDER_OPEN$s}" - FOLDER_ICON "${CODEPOINT_OF_AWESOME_FOLDER_O:+\\u$CODEPOINT_OF_AWESOME_FOLDER_O$s}" - ETC_ICON "${CODEPOINT_OF_AWESOME_COG:+\\u$CODEPOINT_OF_AWESOME_COG }" - NETWORK_ICON "${CODEPOINT_OF_AWESOME_RSS:+\\u$CODEPOINT_OF_AWESOME_RSS$s}" - LOAD_ICON "${CODEPOINT_OF_AWESOME_BAR_CHART:+\\u$CODEPOINT_OF_AWESOME_BAR_CHART }" - SWAP_ICON "${CODEPOINT_OF_AWESOME_DASHBOARD:+\\u$CODEPOINT_OF_AWESOME_DASHBOARD$s}" - RAM_ICON "${CODEPOINT_OF_AWESOME_DASHBOARD:+\\u$CODEPOINT_OF_AWESOME_DASHBOARD$s}" - SERVER_ICON "${CODEPOINT_OF_AWESOME_SERVER:+\\u$CODEPOINT_OF_AWESOME_SERVER$s}" - VCS_UNTRACKED_ICON "${CODEPOINT_OF_AWESOME_QUESTION_CIRCLE:+\\u$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE$s}" - VCS_UNSTAGED_ICON "${CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE:+\\u$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE$s}" - VCS_STAGED_ICON "${CODEPOINT_OF_AWESOME_PLUS_CIRCLE:+\\u$CODEPOINT_OF_AWESOME_PLUS_CIRCLE$s}" - VCS_STASH_ICON "${CODEPOINT_OF_AWESOME_INBOX:+\\u$CODEPOINT_OF_AWESOME_INBOX }" - VCS_INCOMING_CHANGES_ICON "${CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN:+\\u$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN }" - VCS_OUTGOING_CHANGES_ICON "${CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP:+\\u$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP }" - VCS_TAG_ICON "${CODEPOINT_OF_AWESOME_TAG:+\\u$CODEPOINT_OF_AWESOME_TAG }" - VCS_BOOKMARK_ICON "${CODEPOINT_OF_OCTICONS_BOOKMARK:+\\u$CODEPOINT_OF_OCTICONS_BOOKMARK}" - VCS_COMMIT_ICON "${CODEPOINT_OF_OCTICONS_GIT_COMMIT:+\\u$CODEPOINT_OF_OCTICONS_GIT_COMMIT }" - VCS_BRANCH_ICON "${CODEPOINT_OF_OCTICONS_GIT_BRANCH:+\\u$CODEPOINT_OF_OCTICONS_GIT_BRANCH }" - VCS_REMOTE_BRANCH_ICON "${CODEPOINT_OF_OCTICONS_REPO_PUSH:+\\u$CODEPOINT_OF_OCTICONS_REPO_PUSH$s}" - VCS_LOADING_ICON '' - VCS_GIT_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_GITHUB_ICON "${CODEPOINT_OF_AWESOME_GITHUB_ALT:+\\u$CODEPOINT_OF_AWESOME_GITHUB_ALT }" - VCS_GIT_BITBUCKET_ICON "${CODEPOINT_OF_AWESOME_BITBUCKET:+\\u$CODEPOINT_OF_AWESOME_BITBUCKET }" - VCS_GIT_GITLAB_ICON "${CODEPOINT_OF_AWESOME_GITLAB:+\\u$CODEPOINT_OF_AWESOME_GITLAB }" - VCS_HG_ICON "${CODEPOINT_OF_AWESOME_FLASK:+\\u$CODEPOINT_OF_AWESOME_FLASK }" - VCS_SVN_ICON 'svn'$q - RUST_ICON '\uE6A8' #  - PYTHON_ICON '\U1F40D' # 🐍 - SWIFT_ICON '\uE655'$s #  - PUBLIC_IP_ICON "${CODEPOINT_OF_AWESOME_GLOBE:+\\u$CODEPOINT_OF_AWESOME_GLOBE$s}" - LOCK_ICON "${CODEPOINT_OF_AWESOME_LOCK:+\\u$CODEPOINT_OF_AWESOME_LOCK}" - NORDVPN_ICON "${CODEPOINT_OF_AWESOME_LOCK:+\\u$CODEPOINT_OF_AWESOME_LOCK}" - EXECUTION_TIME_ICON "${CODEPOINT_OF_AWESOME_HOURGLASS_END:+\\u$CODEPOINT_OF_AWESOME_HOURGLASS_END$s}" - SSH_ICON 'ssh' - VPN_ICON "${CODEPOINT_OF_AWESOME_LOCK:+\\u$CODEPOINT_OF_AWESOME_LOCK}" - KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON "${CODEPOINT_OF_AWESOME_DROPBOX:+\\u$CODEPOINT_OF_AWESOME_DROPBOX$s}" - DATE_ICON '\uF073 ' #  - TIME_ICON '\uF017 ' #  - JAVA_ICON '\U2615' # ☕︎ - LARAVEL_ICON '' - RANGER_ICON '\u2B50' # ⭐ - MIDNIGHT_COMMANDER_ICON 'mc' - VIM_ICON 'vim' - TERRAFORM_ICON 'tf' - PROXY_ICON '\u2194' # ↔ - DOTNET_ICON '.NET' - DOTNET_CORE_ICON '.NET' - AZURE_ICON '\u2601' # ☁ - DIRENV_ICON '\u25BC' # ▼ - FLUTTER_ICON 'F' - GCLOUD_ICON 'G' - LUA_ICON 'lua' - PERL_ICON 'perl' - NNN_ICON 'nnn' - XPLR_ICON 'xplr' - TIMEWARRIOR_ICON 'tw' - TASKWARRIOR_ICON 'task' - NIX_SHELL_ICON 'nix' - WIFI_ICON 'WiFi' - ERLANG_ICON 'erl' - ELIXIR_ICON 'elixir' - POSTGRES_ICON 'postgres' - PHP_ICON 'php' - HASKELL_ICON 'hs' - PACKAGE_ICON 'pkg' - JULIA_ICON 'jl' - SCALA_ICON 'scala' - TOOLBOX_ICON '\u2B22' # ⬢ - ARCH_ICON 'arch' - ) - ;; - 'nerdfont-complete'|'nerdfont-fontconfig') - # nerd-font patched (complete) font required! See - # https://github.com/ryanoasis/nerd-fonts - # http://nerdfonts.com/#cheat-sheet - icons=( - RULER_CHAR '\u2500' # ─ - LEFT_SEGMENT_SEPARATOR '\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR '\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  - CARRIAGE_RETURN_ICON '\u21B5' # ↵ - ROOT_ICON '\uE614'$q #  - SUDO_ICON '\uF09C'$s #  - RUBY_ICON '\uF219 ' #  - AWS_ICON '\uF270'$s #  - AWS_EB_ICON '\UF1BD'$q$q #  - BACKGROUND_JOBS_ICON '\uF013 ' #  - TEST_ICON '\uF188'$s #  - TODO_ICON '\u2611' # ☑ - BATTERY_ICON '\UF240 ' #  - DISK_ICON '\uF0A0'$s #  - OK_ICON '\uF00C'$s #  - FAIL_ICON '\uF00D' #  - SYMFONY_ICON '\uE757' #  - NODE_ICON '\uE617 ' #  - NODEJS_ICON '\uE617 ' #  - MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uF179' #  - WINDOWS_ICON '\uF17A'$s #  - FREEBSD_ICON '\UF30C ' #  - ANDROID_ICON '\uF17B' #  - LINUX_ARCH_ICON '\uF303' #  - LINUX_CENTOS_ICON '\uF304'$s #  - LINUX_COREOS_ICON '\uF305'$s #  - LINUX_DEBIAN_ICON '\uF306' #  - LINUX_RASPBIAN_ICON '\uF315' #  - LINUX_ELEMENTARY_ICON '\uF309'$s #  - LINUX_FEDORA_ICON '\uF30a'$s #  - LINUX_GENTOO_ICON '\uF30d'$s #  - LINUX_MAGEIA_ICON '\uF310' #  - LINUX_MINT_ICON '\uF30e'$s #  - LINUX_NIXOS_ICON '\uF313'$s #  - LINUX_MANJARO_ICON '\uF312'$s #  - LINUX_DEVUAN_ICON '\uF307'$s #  - LINUX_ALPINE_ICON '\uF300'$s #  - LINUX_AOSC_ICON '\uF301'$s #  - LINUX_OPENSUSE_ICON '\uF314'$s #  - LINUX_SABAYON_ICON '\uF317'$s #  - LINUX_SLACKWARE_ICON '\uF319'$s #  - LINUX_VOID_ICON '\uF17C' #  - LINUX_ARTIX_ICON '\uF17C' #  - LINUX_UBUNTU_ICON '\uF31b'$s #  - LINUX_RHEL_ICON '\uF316'$s #  - LINUX_AMZN_ICON '\uF270'$s #  - LINUX_ICON '\uF17C' #  - SUNOS_ICON '\uF185 ' #  - HOME_ICON '\uF015'$s #  - HOME_SUB_ICON '\uF07C'$s #  - FOLDER_ICON '\uF115'$s #  - ETC_ICON '\uF013'$s #  - NETWORK_ICON '\uF50D'$s #  - LOAD_ICON '\uF080 ' #  - SWAP_ICON '\uF464'$s #  - RAM_ICON '\uF0E4'$s #  - SERVER_ICON '\uF0AE'$s #  - VCS_UNTRACKED_ICON '\uF059'$s #  - VCS_UNSTAGED_ICON '\uF06A'$s #  - VCS_STAGED_ICON '\uF055'$s #  - VCS_STASH_ICON '\uF01C ' #  - VCS_INCOMING_CHANGES_ICON '\uF01A ' #  - VCS_OUTGOING_CHANGES_ICON '\uF01B ' #  - VCS_TAG_ICON '\uF02B ' #  - VCS_BOOKMARK_ICON '\uF461 ' #  - VCS_COMMIT_ICON '\uE729 ' #  - VCS_BRANCH_ICON '\uF126 ' #  - VCS_REMOTE_BRANCH_ICON '\uE728 ' #  - VCS_LOADING_ICON '' - VCS_GIT_ICON '\uF1D3 ' #  - VCS_GIT_GITHUB_ICON '\uF113 ' #  - VCS_GIT_BITBUCKET_ICON '\uE703 ' #  - VCS_GIT_GITLAB_ICON '\uF296 ' #  - VCS_HG_ICON '\uF0C3 ' #  - VCS_SVN_ICON '\uE72D'$q #  - RUST_ICON '\uE7A8'$q #  - PYTHON_ICON '\UE73C ' #  - SWIFT_ICON '\uE755' #  - GO_ICON '\uE626' #  - GOLANG_ICON '\uE626' #  - PUBLIC_IP_ICON '\UF0AC'$s #  - LOCK_ICON '\UF023' #  - NORDVPN_ICON '\UF023' #  - EXECUTION_TIME_ICON '\uF252'$s #  - SSH_ICON '\uF489'$s #  - VPN_ICON '\UF023' - KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\UF16B'$s #  - DATE_ICON '\uF073 ' #  - TIME_ICON '\uF017 ' #  - JAVA_ICON '\uE738' #  - LARAVEL_ICON '\ue73f'$q #  - RANGER_ICON '\uF00b ' #  - MIDNIGHT_COMMANDER_ICON 'mc' - VIM_ICON '\uE62B' #  - TERRAFORM_ICON '\uF1BB ' #  - PROXY_ICON '\u2194' # ↔ - DOTNET_ICON '\uE77F' #  - DOTNET_CORE_ICON '\uE77F' #  - AZURE_ICON '\uFD03' # ﴃ - DIRENV_ICON '\u25BC' # ▼ - FLUTTER_ICON 'F' - GCLOUD_ICON '\uF7B7' #  - LUA_ICON '\uE620' #  - PERL_ICON '\uE769' #  - NNN_ICON 'nnn' - XPLR_ICON 'xplr' - TIMEWARRIOR_ICON '\uF49B' #  - TASKWARRIOR_ICON '\uF4A0 ' #  - NIX_SHELL_ICON '\uF313 ' #  - WIFI_ICON '\uF1EB ' #  - ERLANG_ICON '\uE7B1 ' #  - ELIXIR_ICON '\uE62D' #  - POSTGRES_ICON '\uE76E' #  - PHP_ICON '\uE608' #  - HASKELL_ICON '\uE61F' #  - PACKAGE_ICON '\uF8D6' #  - JULIA_ICON '\uE624' #  - SCALA_ICON '\uE737' #  - TOOLBOX_ICON '\uE20F'$s #  - ARCH_ICON '\uE266' #  - ) - ;; - ascii) - icons=( - RULER_CHAR '-' - LEFT_SEGMENT_SEPARATOR '' - RIGHT_SEGMENT_SEPARATOR '' - LEFT_SEGMENT_END_SEPARATOR ' ' - LEFT_SUBSEGMENT_SEPARATOR '|' - RIGHT_SUBSEGMENT_SEPARATOR '|' - CARRIAGE_RETURN_ICON '' - ROOT_ICON '#' - SUDO_ICON '' - RUBY_ICON 'rb' - AWS_ICON 'aws' - AWS_EB_ICON 'eb' - BACKGROUND_JOBS_ICON '%%' - TEST_ICON '' - TODO_ICON 'todo' - BATTERY_ICON 'battery' - DISK_ICON 'disk' - OK_ICON 'ok' - FAIL_ICON 'err' - SYMFONY_ICON 'symphony' - NODE_ICON 'node' - NODEJS_ICON 'node' - MULTILINE_FIRST_PROMPT_PREFIX '' - MULTILINE_NEWLINE_PROMPT_PREFIX '' - MULTILINE_LAST_PROMPT_PREFIX '' - APPLE_ICON 'mac' - WINDOWS_ICON 'win' - FREEBSD_ICON 'bsd' - ANDROID_ICON 'android' - LINUX_ICON 'linux' - LINUX_ARCH_ICON 'arch' - LINUX_DEBIAN_ICON 'debian' - LINUX_RASPBIAN_ICON 'pi' - LINUX_UBUNTU_ICON 'ubuntu' - LINUX_CENTOS_ICON 'centos' - LINUX_COREOS_ICON 'coreos' - LINUX_ELEMENTARY_ICON 'elementary' - LINUX_MINT_ICON 'mint' - LINUX_FEDORA_ICON 'fedora' - LINUX_GENTOO_ICON 'gentoo' - LINUX_MAGEIA_ICON 'mageia' - LINUX_NIXOS_ICON 'nixos' - LINUX_MANJARO_ICON 'manjaro' - LINUX_DEVUAN_ICON 'devuan' - LINUX_ALPINE_ICON 'alpine' - LINUX_AOSC_ICON 'aosc' - LINUX_OPENSUSE_ICON 'suse' - LINUX_SABAYON_ICON 'sabayon' - LINUX_SLACKWARE_ICON 'slack' - LINUX_VOID_ICON 'void' - LINUX_ARTIX_ICON 'artix' - LINUX_RHEL_ICON 'rhel' - LINUX_AMZN_ICON 'amzn' - SUNOS_ICON 'sunos' - HOME_ICON '' - HOME_SUB_ICON '' - FOLDER_ICON '' - ETC_ICON '' - NETWORK_ICON 'ip' - LOAD_ICON 'cpu' - SWAP_ICON 'swap' - RAM_ICON 'ram' - SERVER_ICON '' - VCS_UNTRACKED_ICON '?' - VCS_UNSTAGED_ICON '!' - VCS_STAGED_ICON '+' - VCS_STASH_ICON '#' - VCS_INCOMING_CHANGES_ICON '<' - VCS_OUTGOING_CHANGES_ICON '>' - VCS_TAG_ICON '' - VCS_BOOKMARK_ICON '^' - VCS_COMMIT_ICON '@' - VCS_BRANCH_ICON '' - VCS_REMOTE_BRANCH_ICON ':' - VCS_LOADING_ICON '' - VCS_GIT_ICON '' - VCS_GIT_GITHUB_ICON '' - VCS_GIT_BITBUCKET_ICON '' - VCS_GIT_GITLAB_ICON '' - VCS_HG_ICON '' - VCS_SVN_ICON '' - RUST_ICON 'rust' - PYTHON_ICON 'py' - SWIFT_ICON 'swift' - GO_ICON 'go' - GOLANG_ICON 'go' - PUBLIC_IP_ICON 'ip' - LOCK_ICON '!w' - NORDVPN_ICON 'nordvpn' - EXECUTION_TIME_ICON '' - SSH_ICON 'ssh' - VPN_ICON 'vpn' - KUBERNETES_ICON 'kube' - DROPBOX_ICON 'dropbox' - DATE_ICON '' - TIME_ICON '' - JAVA_ICON 'java' - LARAVEL_ICON '' - RANGER_ICON 'ranger' - MIDNIGHT_COMMANDER_ICON 'mc' - VIM_ICON 'vim' - TERRAFORM_ICON 'tf' - PROXY_ICON 'proxy' - DOTNET_ICON '.net' - DOTNET_CORE_ICON '.net' - AZURE_ICON 'az' - DIRENV_ICON 'direnv' - FLUTTER_ICON 'flutter' - GCLOUD_ICON 'gcloud' - LUA_ICON 'lua' - PERL_ICON 'perl' - NNN_ICON 'nnn' - XPLR_ICON 'xplr' - TIMEWARRIOR_ICON 'tw' - TASKWARRIOR_ICON 'task' - NIX_SHELL_ICON 'nix' - WIFI_ICON 'wifi' - ERLANG_ICON 'erlang' - ELIXIR_ICON 'elixir' - POSTGRES_ICON 'postgres' - PHP_ICON 'php' - HASKELL_ICON 'hs' - PACKAGE_ICON 'pkg' - JULIA_ICON 'jl' - SCALA_ICON 'scala' - TOOLBOX_ICON 'toolbox' - ARCH_ICON 'arch' - ) - ;; - *) - # Powerline-Patched Font required! - # See https://github.com/Lokaltog/powerline-fonts - icons=( - RULER_CHAR '\u2500' # ─ - LEFT_SEGMENT_SEPARATOR '\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR '\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  - CARRIAGE_RETURN_ICON '\u21B5' # ↵ - ROOT_ICON '\u26A1' # ⚡ - SUDO_ICON '' - RUBY_ICON 'Ruby' - AWS_ICON 'AWS' - AWS_EB_ICON '\U1F331'$q # 🌱 - BACKGROUND_JOBS_ICON '\u2699' # ⚙ - TEST_ICON '' - TODO_ICON '\u2206' # ∆ - BATTERY_ICON '\U1F50B' # 🔋 - DISK_ICON 'hdd' - OK_ICON '\u2714' # ✔ - FAIL_ICON '\u2718' # ✘ - SYMFONY_ICON 'SF' - NODE_ICON 'Node' - NODEJS_ICON 'Node' - MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON 'OSX' - WINDOWS_ICON 'WIN' - FREEBSD_ICON 'BSD' - ANDROID_ICON 'And' - LINUX_ICON 'Lx' - LINUX_ARCH_ICON 'Arc' - LINUX_DEBIAN_ICON 'Deb' - LINUX_RASPBIAN_ICON 'RPi' - LINUX_UBUNTU_ICON 'Ubu' - LINUX_CENTOS_ICON 'Cen' - LINUX_COREOS_ICON 'Cor' - LINUX_ELEMENTARY_ICON 'Elm' - LINUX_MINT_ICON 'LMi' - LINUX_FEDORA_ICON 'Fed' - LINUX_GENTOO_ICON 'Gen' - LINUX_MAGEIA_ICON 'Mag' - LINUX_NIXOS_ICON 'Nix' - LINUX_MANJARO_ICON 'Man' - LINUX_DEVUAN_ICON 'Dev' - LINUX_ALPINE_ICON 'Alp' - LINUX_AOSC_ICON 'Aos' - LINUX_OPENSUSE_ICON 'OSu' - LINUX_SABAYON_ICON 'Sab' - LINUX_SLACKWARE_ICON 'Sla' - LINUX_VOID_ICON 'Vo' - LINUX_ARTIX_ICON 'Art' - LINUX_RHEL_ICON 'RH' - LINUX_AMZN_ICON 'Amzn' - SUNOS_ICON 'Sun' - HOME_ICON '' - HOME_SUB_ICON '' - FOLDER_ICON '' - ETC_ICON '\u2699' # ⚙ - NETWORK_ICON 'IP' - LOAD_ICON 'L' - SWAP_ICON 'SWP' - RAM_ICON 'RAM' - SERVER_ICON '' - VCS_UNTRACKED_ICON '?' - VCS_UNSTAGED_ICON '\u25CF' # ● - VCS_STAGED_ICON '\u271A' # ✚ - VCS_STASH_ICON '\u235F' # ⍟ - VCS_INCOMING_CHANGES_ICON '\u2193' # ↓ - VCS_OUTGOING_CHANGES_ICON '\u2191' # ↑ - VCS_TAG_ICON '' - VCS_BOOKMARK_ICON '\u263F' # ☿ - VCS_COMMIT_ICON '' - VCS_BRANCH_ICON '\uE0A0 ' #  - VCS_REMOTE_BRANCH_ICON '\u2192' # → - VCS_LOADING_ICON '' - VCS_GIT_ICON '' - VCS_GIT_GITHUB_ICON '' - VCS_GIT_BITBUCKET_ICON '' - VCS_GIT_GITLAB_ICON '' - VCS_HG_ICON '' - VCS_SVN_ICON '' - RUST_ICON 'R' - PYTHON_ICON 'Py' - SWIFT_ICON 'Swift' - GO_ICON 'Go' - GOLANG_ICON 'Go' - PUBLIC_IP_ICON 'IP' - LOCK_ICON '\UE0A2' - NORDVPN_ICON '\UE0A2' - EXECUTION_TIME_ICON '' - SSH_ICON 'ssh' - VPN_ICON 'vpn' - KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON 'Dropbox' - DATE_ICON '' - TIME_ICON '' - JAVA_ICON '\U2615' # ☕︎ - LARAVEL_ICON '' - RANGER_ICON '\u2B50' # ⭐ - MIDNIGHT_COMMANDER_ICON 'mc' - VIM_ICON 'vim' - TERRAFORM_ICON 'tf' - PROXY_ICON '\u2194' # ↔ - DOTNET_ICON '.NET' - DOTNET_CORE_ICON '.NET' - AZURE_ICON '\u2601' # ☁ - DIRENV_ICON '\u25BC' # ▼ - FLUTTER_ICON 'F' - GCLOUD_ICON 'G' - LUA_ICON 'lua' - PERL_ICON 'perl' - NNN_ICON 'nnn' - XPLR_ICON 'xplr' - TIMEWARRIOR_ICON 'tw' - TASKWARRIOR_ICON 'task' - NIX_SHELL_ICON 'nix' - WIFI_ICON 'WiFi' - ERLANG_ICON 'erl' - ELIXIR_ICON 'elixir' - POSTGRES_ICON 'postgres' - PHP_ICON 'php' - HASKELL_ICON 'hs' - PACKAGE_ICON 'pkg' - JULIA_ICON 'jl' - SCALA_ICON 'scala' - TOOLBOX_ICON '\u2B22' # ⬢ - ARCH_ICON 'arch' - ) - ;; - esac - - # Override the above icon settings with any user-defined variables. - case $POWERLEVEL9K_MODE in - 'flat') - icons[LEFT_SEGMENT_SEPARATOR]='' - icons[RIGHT_SEGMENT_SEPARATOR]='' - icons[LEFT_SUBSEGMENT_SEPARATOR]='|' - icons[RIGHT_SUBSEGMENT_SEPARATOR]='|' - ;; - 'compatible') - icons[LEFT_SEGMENT_SEPARATOR]='\u2B80' # ⮀ - icons[RIGHT_SEGMENT_SEPARATOR]='\u2B82' # ⮂ - icons[VCS_BRANCH_ICON]='@' - ;; - esac - - if [[ $POWERLEVEL9K_ICON_PADDING == none && $POWERLEVEL9K_MODE != ascii ]]; then - icons=("${(@kv)icons%% #}") - icons[LEFT_SEGMENT_END_SEPARATOR]+=' ' - icons[MULTILINE_LAST_PROMPT_PREFIX]+=' ' - icons[VCS_TAG_ICON]+=' ' - icons[VCS_BOOKMARK_ICON]+=' ' - icons[VCS_COMMIT_ICON]+=' ' - icons[VCS_BRANCH_ICON]+=' ' - icons[VCS_REMOTE_BRANCH_ICON]+=' ' - fi -} - -# Sadly, this is a part of public API. Its use is emphatically discouraged. -function print_icon() { - eval "$__p9k_intro" - _p9k_init_icons - local var=POWERLEVEL9K_$1 - if (( $+parameters[$var] )); then - echo -n - ${(P)var} - else - echo -n - $icons[$1] - fi -} - -# Prints a list of configured icons. -# -# * $1 string - If "original", then the original icons are printed, -# otherwise "print_icon" is used, which takes the users -# overrides into account. -function get_icon_names() { - eval "$__p9k_intro" - _p9k_init_icons - local key - for key in ${(@kon)icons}; do - echo -n - "POWERLEVEL9K_$key: " - print -nP "%K{red} %k" - if [[ $1 == original ]]; then - echo -n - $icons[$key] - else - print_icon $key - fi - print -P "%K{red} %k" - done -} diff --git a/.zsh/themes/powerlevel10k/internal/notes.md b/.zsh/themes/powerlevel10k/internal/notes.md deleted file mode 100644 index dea28d3..0000000 --- a/.zsh/themes/powerlevel10k/internal/notes.md +++ /dev/null @@ -1,197 +0,0 @@ -battery: use the same technique as in vpn_ip to avoid reset=2. - ---- - -implement fake gitstatus api on top of vcs_info (or plain git?) + worker and use it if there is no -gitstatus. - ---- - -- call vcs_info on worker. the tricky question is what to display while "loading". - ---- - -- add _SHOW_SYSTEM to all *env segments. - ---- - -- support states in SHOW_ON_COMMAND: POWERLEVEL9K_SEGMENT_STATE_SHOW_ON_COMMAND='...' - ---- - -add POWERLEVEL9K_${SEGMENT}_${STATE}_SHOW_IN_DIR='pwd_pattern'; implement the same way as -SHOW_ON_UPGLOB. how should it interact with POWERLEVEL9K_${SEGMENT}_DISABLED_DIR_PATTERN? - ---- - -add `p10k upglob`; returns 0 on match and sets REPLY to the directory where match was found. - ---- - -when directory cannot be shortened any further, start chopping off segments from the left and -replacing the chopped off part with `…`. e.g., `…/x/anchor/y/anchor`. the shortest dir -representation is thus `…/last` or `…/last` depending on whether the last segment is an anchor. -the replacement parameter's value is `…/` (with a slash) to allow for `x/anchor/y/anchor`. - ---- - -- add to faq: how do i display an environment variable in prompt? link it from "extensible" - ---- - -- add to faq: how do i display an icon in prompt? link it from "extensible" - ---- - -- add root_indicator to config templates - ---- - -- test chruby and add it to config templates - ---- - -- add ssh to config templates - ---- - -- add swift version to config templates; see if there is a good pattern for PROJECT_ONLY - ---- - -- add swiftenv - ---- - -- add faq: how to customize directory shortening? mention POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER, -POWERLEVEL9K_DIR_MAX_LENGTH and co., and truncate_to_last. - ---- - -fix a bug in zsh: https://github.com/romkatv/powerlevel10k/issues/502. to reproduce: - -```zsh -emulate zsh -o prompt_percent -c 'print -P "%F{#ff0000}red%F{green}%B bold green"' -``` - ---- - -add `p10k explain` that prints something like this: - -```text -segment icons meaning - ---- - ---- - ---- - ---- - ---- - ---- - ---- - ---- --- -status ✔ ✘ exit code of the last command -``` - -implement it the hard way: for every enabled segment go over all its {state,icon} pairs, resolve -the icon (if not absolute), apply VISUAL_IDENTIFIER_EXPANSION, remove leading and trailing -whitespace and print without formatting (sort of like `print -P | cat`); print segment names in -green and icons in bold; battery can have an unlimited number of icons, so `...` would be needed -(based on total length of concatenated icons rather than the number of icons); user-defined -segments would have "unknown" icons by default (yellow and not bold); can allow them to -participate by defining `explainprompt_foo` that populates array `reply` with strings like this: -'-s STATE -i LOCK_ICON +r'; the first element must be segment description. - ---- - -add `docker_context` prompt segment; similar to `kubecontext`; the data should come from -`currentContext` field in `~/.docker/config.json` (according to -https://github.com/starship/starship/issues/995); there is also `DOCKER_CONTEXT`; more info: -https://docs.docker.com/engine/reference/commandline/context_use; also -https://github.com/starship/starship/pull/996. - ---- - -support `env`, `ionice` and `strace` precommands in `parser.zsh`. - ---- - -Add ruler to configuration wizard. Options: `─`, `·`, `╌`, `┄`, `▁`, `═`. - ---- - -Add frame styles to the wizard. - -```text -╭─ -╰─ - -┌─ -└─ - -┏━ -┗━ - -╔═ -╚═ - -▛▀ -▙▄ -``` - -Prompt connection should have matching options. - ---- - -Add `POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_MIRROR_SEPARATOR`. If set, left segments get separated with -`POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR` followed by `POWERLEVEL9K_LEFT_SEGMENT_MIRROR_SEPARATOR`. -Each is drawn without background. The first with the foreground of left segment, the second with -the background of right segment. To insert space in between, embed it in -`POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_MIRROR_SEPARATOR`. -`POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR` is unused. - ---- - -Add *Segment Connection* screen to configuration wizard with options *Fused*, *Touching* and -*Disjoint*. The last two differ by the absence/presence of space between `SEGMENT_SEPARATOR` and -`SEGMENT_MIRROR_SEPARATOR`. - -*Fused* requires line separator (there is already a screen for it) but the other two options require -two filled separators similar to heads and tail. Figure out how to present this choice. - ---- - -Optimize auto-wizard check. - -```text -time ( repeat 1000 [[ -z "${parameters[(I)POWERLEVEL9K_*~(POWERLEVEL9K_MODE|POWERLEVEL9K_CONFIG_FILE)]}" ]] ) -user=0.21s system=0.05s cpu=99% total=0.264 - -time ( repeat 1000 [[ -z "${parameters[(I)POWERLEVEL9K_*]}" ]] ) -user=0.17s system=0.00s cpu=99% total=0.175 -``` - ---- - -Add the equivalent of `P9K_PYTHON_VERSION` to all `*env` segments where it makes sense. - ---- - -Define `P9K_ICON` on initialization. Fill it with `$icon`. Duplicate every key that ends in `_ICON`. -Respect `POWERLEVEL9K_VCS_STASH_ICON` overrides but not anything with segment name or state. - -Define `POWERLEVEL9K_VCS_*` parameters in config templates for all symbols used in -`my_git_formatter`. Add missing entries to `icons`. Use `$P9K_ICON[...]` within `my_git_formatter`. -Add a screen to the wizard to choose between clear and circled icons. - ---- - -Add a screen to the wizard asking whether to set `POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'`. -Show it only if there is `$HOME/.git`. By default this parameter should be commented out. diff --git a/.zsh/themes/powerlevel10k/internal/p10k.zsh b/.zsh/themes/powerlevel10k/internal/p10k.zsh deleted file mode 100644 index 9a8f52d..0000000 --- a/.zsh/themes/powerlevel10k/internal/p10k.zsh +++ /dev/null @@ -1,9286 +0,0 @@ -if [[ $__p9k_sourced != 13 ]]; then - >&2 print -P "" - >&2 print -P "[%F{1}ERROR%f]: Corrupted powerlevel10k installation." - >&2 print -P "" - if (( ${+functions[antigen]} )); then - >&2 print -P "If using %Bantigen%b, run the following command to fix:" - >&2 print -P "" - >&2 print -P " %F{2}antigen%f reset" - if [[ -d ~/.antigen ]]; then - >&2 print -P "" - >&2 print -P "If it doesn't help, try this:" - >&2 print -P "" - >&2 print -P " %F{2}rm%f -rf %U~/.antigen%u" - fi - else - >&2 print -P "Try resetting cache in your plugin manager or" - >&2 print -P "reinstalling powerlevel10k from scratch." - fi - >&2 print -P "" - return 1 -fi - -if [[ $ZSH_VERSION != (5.<1->*|<6->.*) ]]; then - () { - >&2 echo -E "You are using ZSH version $ZSH_VERSION. The minimum required version for Powerlevel10k is 5.1." - >&2 echo -E "Type 'echo \$ZSH_VERSION' to see your current zsh version." - local def=${SHELL:c:A} - local cur=${${ZSH_ARGZERO#-}:c:A} - local cur_v="$($cur -c 'echo -E $ZSH_VERSION' 2>/dev/null)" - if [[ $cur_v == $ZSH_VERSION && $cur != $def ]]; then - >&2 echo -E "The shell you are currently running is likely $cur." - fi - local other=${${:-zsh}:c} - if [[ -n $other ]] && $other -fc '[[ $ZSH_VERSION == (5.<1->*|<6->.*) ]]' &>/dev/null; then - local other_v="$($other -fc 'echo -E $ZSH_VERSION' 2>/dev/null)" - if [[ -n $other_v && $other_v != $ZSH_VERSION ]]; then - >&2 echo -E "You have $other with version $other_v but this is not what you are using." - if [[ -n $def && $def != ${other:A} ]]; then - >&2 echo -E "To change your user shell, type the following command:" - >&2 echo -E "" - if [[ "$(grep -F $other /etc/shells 2>/dev/null)" != $other ]]; then - >&2 echo -E " echo ${(q-)other} | sudo tee -a /etc/shells" - fi - >&2 echo -E " chsh -s ${(q-)other}" - fi - fi - fi - } - return 1 -fi - -builtin source "${__p9k_root_dir}/internal/configure.zsh" -builtin source "${__p9k_root_dir}/internal/worker.zsh" -builtin source "${__p9k_root_dir}/internal/parser.zsh" -builtin source "${__p9k_root_dir}/internal/icons.zsh" - -# For compatibility with Powerlevel9k. It's not recommended to use mnemonic color -# names in the configuration except for colors 0-7 as these are standard. -typeset -grA __p9k_colors=( - black 000 red 001 green 002 yellow 003 - blue 004 magenta 005 cyan 006 white 007 - grey 008 maroon 009 lime 010 olive 011 - navy 012 fuchsia 013 aqua 014 teal 014 - silver 015 grey0 016 navyblue 017 darkblue 018 - blue3 020 blue1 021 darkgreen 022 deepskyblue4 025 - dodgerblue3 026 dodgerblue2 027 green4 028 springgreen4 029 - turquoise4 030 deepskyblue3 032 dodgerblue1 033 darkcyan 036 - lightseagreen 037 deepskyblue2 038 deepskyblue1 039 green3 040 - springgreen3 041 cyan3 043 darkturquoise 044 turquoise2 045 - green1 046 springgreen2 047 springgreen1 048 mediumspringgreen 049 - cyan2 050 cyan1 051 purple4 055 purple3 056 - blueviolet 057 grey37 059 mediumpurple4 060 slateblue3 062 - royalblue1 063 chartreuse4 064 paleturquoise4 066 steelblue 067 - steelblue3 068 cornflowerblue 069 darkseagreen4 071 cadetblue 073 - skyblue3 074 chartreuse3 076 seagreen3 078 aquamarine3 079 - mediumturquoise 080 steelblue1 081 seagreen2 083 seagreen1 085 - darkslategray2 087 darkred 088 darkmagenta 091 orange4 094 - lightpink4 095 plum4 096 mediumpurple3 098 slateblue1 099 - wheat4 101 grey53 102 lightslategrey 103 mediumpurple 104 - lightslateblue 105 yellow4 106 darkseagreen 108 lightskyblue3 110 - skyblue2 111 chartreuse2 112 palegreen3 114 darkslategray3 116 - skyblue1 117 chartreuse1 118 lightgreen 120 aquamarine1 122 - darkslategray1 123 deeppink4 125 mediumvioletred 126 darkviolet 128 - purple 129 mediumorchid3 133 mediumorchid 134 darkgoldenrod 136 - rosybrown 138 grey63 139 mediumpurple2 140 mediumpurple1 141 - darkkhaki 143 navajowhite3 144 grey69 145 lightsteelblue3 146 - lightsteelblue 147 darkolivegreen3 149 darkseagreen3 150 lightcyan3 152 - lightskyblue1 153 greenyellow 154 darkolivegreen2 155 palegreen1 156 - darkseagreen2 157 paleturquoise1 159 red3 160 deeppink3 162 - magenta3 164 darkorange3 166 indianred 167 hotpink3 168 - hotpink2 169 orchid 170 orange3 172 lightsalmon3 173 - lightpink3 174 pink3 175 plum3 176 violet 177 - gold3 178 lightgoldenrod3 179 tan 180 mistyrose3 181 - thistle3 182 plum2 183 yellow3 184 khaki3 185 - lightyellow3 187 grey84 188 lightsteelblue1 189 yellow2 190 - darkolivegreen1 192 darkseagreen1 193 honeydew2 194 lightcyan1 195 - red1 196 deeppink2 197 deeppink1 199 magenta2 200 - magenta1 201 orangered1 202 indianred1 204 hotpink 206 - mediumorchid1 207 darkorange 208 salmon1 209 lightcoral 210 - palevioletred1 211 orchid2 212 orchid1 213 orange1 214 - sandybrown 215 lightsalmon1 216 lightpink1 217 pink1 218 - plum1 219 gold1 220 lightgoldenrod2 222 navajowhite1 223 - mistyrose1 224 thistle1 225 yellow1 226 lightgoldenrod1 227 - khaki1 228 wheat1 229 cornsilk1 230 grey100 231 - grey3 232 grey7 233 grey11 234 grey15 235 - grey19 236 grey23 237 grey27 238 grey30 239 - grey35 240 grey39 241 grey42 242 grey46 243 - grey50 244 grey54 245 grey58 246 grey62 247 - grey66 248 grey70 249 grey74 250 grey78 251 - grey82 252 grey85 253 grey89 254 grey93 255) - -# For compatibility with Powerlevel9k. -# -# Type `getColorCode background` or `getColorCode foreground` to see the list of predefined colors. -function getColorCode() { - eval "$__p9k_intro" - if (( ARGC == 1 )); then - case $1 in - foreground) - local k - for k in "${(k@)__p9k_colors}"; do - local v=${__p9k_colors[$k]} - print -rP -- "%F{$v}$v - $k%f" - done - return 0 - ;; - background) - local k - for k in "${(k@)__p9k_colors}"; do - local v=${__p9k_colors[$k]} - print -rP -- "%K{$v}$v - $k%k" - done - return 0 - ;; - esac - fi - echo "Usage: getColorCode background|foreground" >&2 - return 1 -} - -# _p9k_declare <type> <uppercase-name> [default]... -function _p9k_declare() { - local -i set=$+parameters[$2] - (( ARGC > 2 || set )) || return 0 - case $1 in - -b) - if (( set )); then - [[ ${(P)2} == true ]] && typeset -gi _$2=1 || typeset -gi _$2=0 - else - typeset -gi _$2=$3 - fi - ;; - -a) - local -a v=("${(@P)2}") - if (( set )); then - eval "typeset -ga _${(q)2}=(${(@qq)v})"; - else - if [[ $3 != '--' ]]; then - echo "internal error in _p9k_declare " "${(qqq)@}" >&2 - fi - eval "typeset -ga _${(q)2}=(${(@qq)*[4,-1]})" - fi - ;; - -i) - (( set )) && typeset -gi _$2=$2 || typeset -gi _$2=$3 - ;; - -F) - (( set )) && typeset -gF _$2=$2 || typeset -gF _$2=$3 - ;; - -s) - (( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3 - ;; - -e) - if (( set )); then - local v=${(P)2} - typeset -g _$2=${(g::)v} - else - typeset -g _$2=${(g::)3} - fi - ;; - *) - echo "internal error in _p9k_declare " "${(qqq)@}" >&2 - esac -} - -function _p9k_read_word() { - local -a stat - zstat -A stat +mtime -- $1 2>/dev/null || stat=(-1) - local cached=$_p9k__read_word_cache[$1] - if [[ $cached == $stat[1]:* ]]; then - _p9k__ret=${cached#*:} - else - local rest - _p9k__ret= - { read _p9k__ret rest <$1 } 2>/dev/null - _p9k__ret=${_p9k__ret%$'\r'} - _p9k__read_word_cache[$1]=$stat[1]:$_p9k__ret - fi - [[ -n $_p9k__ret ]] -} - -function _p9k_fetch_cwd() { - if [[ $PWD == /* && $PWD -ef . ]]; then - _p9k__cwd=$PWD - else - _p9k__cwd=${${${:-.}:a}:-.} - fi - _p9k__cwd_a=${${_p9k__cwd:A}:-.} - - case $_p9k__cwd in - /|.) - _p9k__parent_dirs=() - _p9k__parent_mtimes=() - _p9k__parent_mtimes_i=() - _p9k__parent_mtimes_s= - return - ;; - ~|~/*) - local parent=${${${:-~/..}:a}%/}/ - local parts=(${(s./.)_p9k__cwd#$parent}) - ;; - *) - local parent=/ - local parts=(${(s./.)_p9k__cwd}) - ;; - esac - local MATCH - _p9k__parent_dirs=(${(@)${:-{$#parts..1}}/(#m)*/$parent${(pj./.)parts[1,MATCH]}}) - if ! zstat -A _p9k__parent_mtimes +mtime -- $_p9k__parent_dirs 2>/dev/null; then - _p9k__parent_mtimes=(${(@)parts/*/-1}) - fi - _p9k__parent_mtimes_i=(${(@)${:-{1..$#parts}}/(#m)*/$MATCH:$_p9k__parent_mtimes[MATCH]}) - _p9k__parent_mtimes_s="$_p9k__parent_mtimes_i" -} - -# Usage: _p9k_glob parent_dir_index pattern -# -# parent_dir_index indexes _p9k__parent_dirs. -# -# Returns the number of matches. -# -# Pattern cannot have slashes. -# -# Example: _p9k_glob 3 '*.csproj' -function _p9k_glob() { - local dir=$_p9k__parent_dirs[$1] - local cached=$_p9k__glob_cache[$dir/$2] - if [[ $cached == $_p9k__parent_mtimes[$1]:* ]]; then - return ${cached##*:} - fi - local -a stat - zstat -A stat +mtime -- $dir 2>/dev/null || stat=(-1) - local files=($dir/$~2(N:t)) - _p9k__glob_cache[$dir/$2]="$stat[1]:$#files" - return $#files -} - -# Usage: _p9k_upglob pattern -# -# Returns index within _p9k__parent_dirs or 0 if there is no match. -# -# Search stops before reaching ~/../ or / and never matches in those directories. -# -# Example: _p9k_upglob '*.csproj' -function _p9k_upglob() { - local cached=$_p9k__upsearch_cache[$_p9k__cwd/$1] - if [[ -n $cached ]]; then - if [[ $_p9k__parent_mtimes_s == ${cached% *}(| *) ]]; then - return ${cached##* } - fi - cached=(${(s: :)cached}) - local last_idx=$cached[-1] - cached[-1]=() - local -i i - for i in ${(@)${cached:|_p9k__parent_mtimes_i}%:*}; do - _p9k_glob $i $1 && continue - _p9k__upsearch_cache[$_p9k__cwd/$1]="${_p9k__parent_mtimes_i[1,i]} $i" - return i - done - if (( i != last_idx )); then - _p9k__upsearch_cache[$_p9k__cwd/$1]="${_p9k__parent_mtimes_i[1,$#cached]} $last_idx" - return last_idx - fi - i=$(($#cached + 1)) - else - local -i i=1 - fi - for ((; i <= $#_p9k__parent_mtimes; ++i)); do - _p9k_glob $i $1 && continue - _p9k__upsearch_cache[$_p9k__cwd/$1]="${_p9k__parent_mtimes_i[1,i]} $i" - return i - done - _p9k__upsearch_cache[$_p9k__cwd/$1]="$_p9k__parent_mtimes_s 0" - return 0 -} - -# If we execute `print -P $1`, how many characters will be printed on the last line? -# Assumes that `%{%}` and `%G` don't lie. -# -# _p9k_prompt_length '' => 0 -# _p9k_prompt_length 'abc' => 3 -# _p9k_prompt_length $'abc\nxy' => 2 -# _p9k_prompt_length $'\t' => 8 -# _p9k_prompt_length '%F{red}abc' => 3 -# _p9k_prompt_length $'%{a\b%Gb%}' => 1 -function _p9k_prompt_length() { - local -i COLUMNS=1024 - local -i x y=${#1} m - if (( y )); then - while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do - x=y - (( y *= 2 )) - done - while (( y > x + 1 )); do - (( m = x + (y - x) / 2 )) - (( ${${(%):-$1%$m(l.x.y)}[-1]} = m )) - done - fi - typeset -g _p9k__ret=$x -} - -typeset -gr __p9k_byte_suffix=('B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y') - -# 512 => 512B -# 1800 => 1.76K -# 18000 => 17.6K -function _p9k_human_readable_bytes() { - typeset -F n=$1 - local suf - for suf in $__p9k_byte_suffix; do - (( n < 1024 )) && break - (( n /= 1024 )) - done - if (( n >= 100 )); then - printf -v _p9k__ret '%.0f.' $n - elif (( n >= 10 )); then - printf -v _p9k__ret '%.1f' $n - else - printf -v _p9k__ret '%.2f' $n - fi - _p9k__ret=${${_p9k__ret%%0#}%.}$suf -} - -if [[ $ZSH_VERSION == (5.<4->*|<6->.*) ]]; then - function _p9k_print_params() { typeset -p -- "$@" } -else - # Cannot use `typeset -p` unconditionally because of bugs in zsh. - function _p9k_print_params() { - local name - for name; do - case $parameters[$name] in - array*) - print -r -- "$name=(" "${(@q)${(@P)name}}" ")" - ;; - association*) - # Cannot use "${(@q)${(@kvP)name}}" because of bugs in zsh. - local kv=("${(@kvP)name}") - print -r -- "$name=(" "${(@q)kv}" ")" - ;; - *) - print -r -- "$name=${(q)${(P)name}}" - ;; - esac - done - } -fi - -# Determine if the passed segment is used in the prompt -# -# Pass the name of the segment to this function to test for its presence in -# either the LEFT or RIGHT prompt arrays. -# * $1: The segment to be tested. -_p9k_segment_in_use() { - (( $_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(I)$1(|_joined)] || - $_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(I)$1(|_joined)] )) -} - -# Caching allows storing array-to-array associations. It should be used like this: -# -# if ! _p9k_cache_get "$key1" "$key2"; then -# # Compute val1 and val2 and then store them in the cache. -# _p9k_cache_set "$val1" "$val2" -# fi -# # Here ${_p9k__cache_val[1]} and ${_p9k__cache_val[2]} are $val1 and $val2 respectively. -# -# Limitations: -# -# * Calling _p9k_cache_set without arguments clears the cache entry. Subsequent calls to -# _p9k_cache_get for the same key will return an error. -# * There must be no intervening _p9k_cache_get calls between the associated _p9k_cache_get -# and _p9k_cache_set. -_p9k_cache_set() { - # Uncomment to see cache misses. - # echo "caching: ${(@0q)_p9k__cache_key} => (${(q)@})" >&2 - _p9k_cache[$_p9k__cache_key]="${(pj:\0:)*}0" - _p9k__cache_val=("$@") - _p9k__state_dump_scheduled=1 -} - -_p9k_cache_get() { - _p9k__cache_key="${(pj:\0:)*}" - local v=$_p9k_cache[$_p9k__cache_key] - [[ -n $v ]] && _p9k__cache_val=("${(@0)${v[1,-2]}}") -} - -_p9k_cache_ephemeral_set() { - # Uncomment to see cache misses. - # echo "caching: ${(@0q)_p9k__cache_key} => (${(q)@})" >&2 - _p9k__cache_ephemeral[$_p9k__cache_key]="${(pj:\0:)*}0" - _p9k__cache_val=("$@") -} - -_p9k_cache_ephemeral_get() { - _p9k__cache_key="${(pj:\0:)*}" - local v=$_p9k__cache_ephemeral[$_p9k__cache_key] - [[ -n $v ]] && _p9k__cache_val=("${(@0)${v[1,-2]}}") -} - -_p9k_cache_stat_get() { - local -H stat - local label=$1 f - shift - - _p9k__cache_stat_meta= - _p9k__cache_stat_fprint= - - for f; do - if zstat -H stat -- $f 2>/dev/null; then - _p9k__cache_stat_meta+="${(q)f} $stat[inode] $stat[mtime] $stat[size] $stat[mode]; " - fi - done - - if _p9k_cache_get $0 $label meta "$@"; then - if [[ $_p9k__cache_val[1] == $_p9k__cache_stat_meta ]]; then - _p9k__cache_stat_fprint=$_p9k__cache_val[2] - local -a key=($0 $label fprint "$@" "$_p9k__cache_stat_fprint") - _p9k__cache_fprint_key="${(pj:\0:)key}" - shift 2 _p9k__cache_val - return 0 - else - local -a key=($0 $label fprint "$@" "$_p9k__cache_val[2]") - _p9k__cache_ephemeral[${(pj:\0:)key}]="${(pj:\0:)_p9k__cache_val[3,-1]}0" - fi - fi - - if (( $+commands[md5] )); then - _p9k__cache_stat_fprint="$(md5 -- $* 2>&1)" - elif (( $+commands[md5sum] )); then - _p9k__cache_stat_fprint="$(md5sum -b -- $* 2>&1)" - else - return 1 - fi - - local meta_key=$_p9k__cache_key - if _p9k_cache_ephemeral_get $0 $label fprint "$@" "$_p9k__cache_stat_fprint"; then - _p9k__cache_fprint_key=$_p9k__cache_key - _p9k__cache_key=$meta_key - _p9k_cache_set "$_p9k__cache_stat_meta" "$_p9k__cache_stat_fprint" "$_p9k__cache_val[@]" - shift 2 _p9k__cache_val - return 0 - fi - - _p9k__cache_fprint_key=$_p9k__cache_key - _p9k__cache_key=$meta_key - return 1 -} - -_p9k_cache_stat_set() { - _p9k_cache_set "$_p9k__cache_stat_meta" "$_p9k__cache_stat_fprint" "$@" - _p9k__cache_key=$_p9k__cache_fprint_key - _p9k_cache_ephemeral_set "$@" -} - -# _p9k_param prompt_foo_BAR BACKGROUND red -_p9k_param() { - local key="_p9k_param ${(pj:\0:)*}" - _p9k__ret=$_p9k_cache[$key] - if [[ -n $_p9k__ret ]]; then - _p9k__ret[-1,-1]='' - else - if [[ ${1//-/_} == (#b)prompt_([a-z0-9_]#)(*) ]]; then - local var=_POWERLEVEL9K_${${(U)match[1]}//İ/I}$match[2]_$2 - if (( $+parameters[$var] )); then - _p9k__ret=${(P)var} - else - var=_POWERLEVEL9K_${${(U)match[1]%_}//İ/I}_$2 - if (( $+parameters[$var] )); then - _p9k__ret=${(P)var} - else - var=_POWERLEVEL9K_$2 - if (( $+parameters[$var] )); then - _p9k__ret=${(P)var} - else - _p9k__ret=$3 - fi - fi - fi - else - local var=_POWERLEVEL9K_$2 - if (( $+parameters[$var] )); then - _p9k__ret=${(P)var} - else - _p9k__ret=$3 - fi - fi - _p9k_cache[$key]=${_p9k__ret}. - fi -} - -# _p9k_get_icon prompt_foo_BAR BAZ_ICON quix -_p9k_get_icon() { - local key="_p9k_get_icon ${(pj:\0:)*}" - _p9k__ret=$_p9k_cache[$key] - if [[ -n $_p9k__ret ]]; then - _p9k__ret[-1,-1]='' - else - if [[ $2 == $'\1'* ]]; then - _p9k__ret=${2[2,-1]} - else - _p9k_param "$1" "$2" ${icons[$2]-$'\1'$3} - if [[ $_p9k__ret == $'\1'* ]]; then - _p9k__ret=${_p9k__ret[2,-1]} - else - _p9k__ret=${(g::)_p9k__ret} - [[ $_p9k__ret != $'\b'? ]] || _p9k__ret="%{$_p9k__ret%}" # penance for past sins - fi - fi - _p9k_cache[$key]=${_p9k__ret}. - fi -} - -_p9k_translate_color() { - if [[ $1 == <-> ]]; then # decimal color code: 255 - _p9k__ret=${(l.3..0.)1} - elif [[ $1 == '#'[[:xdigit:]]## ]]; then # hexademical color code: #ffffff - _p9k__ret=${${(L)1}//ı/i} - else # named color: red - # Strip prifixes if there are any. - _p9k__ret=$__p9k_colors[${${${1#bg-}#fg-}#br}] - fi -} - -# _p9k_color prompt_foo_BAR BACKGROUND red -_p9k_color() { - local key="_p9k_color ${(pj:\0:)*}" - _p9k__ret=$_p9k_cache[$key] - if [[ -n $_p9k__ret ]]; then - _p9k__ret[-1,-1]='' - else - _p9k_param "$@" - _p9k_translate_color $_p9k__ret - _p9k_cache[$key]=${_p9k__ret}. - fi -} - -# _p9k_vcs_style CLEAN REMOTE_BRANCH -_p9k_vcs_style() { - local key="$0 ${(pj:\0:)*}" - _p9k__ret=$_p9k_cache[$key] - if [[ -n $_p9k__ret ]]; then - _p9k__ret[-1,-1]='' - else - local style=%b # TODO: support bold - _p9k_color prompt_vcs_$1 BACKGROUND "${__p9k_vcs_states[$1]}" - _p9k_background $_p9k__ret - style+=$_p9k__ret - - local var=_POWERLEVEL9K_VCS_${1}_${2}FORMAT_FOREGROUND - if (( $+parameters[$var] )); then - _p9k_translate_color "${(P)var}" - else - var=_POWERLEVEL9K_VCS_${2}FORMAT_FOREGROUND - if (( $+parameters[$var] )); then - _p9k_translate_color "${(P)var}" - else - _p9k_color prompt_vcs_$1 FOREGROUND "$_p9k_color1" - fi - fi - - _p9k_foreground $_p9k__ret - _p9k__ret=$style$_p9k__ret - _p9k_cache[$key]=${_p9k__ret}. - fi -} - -_p9k_background() { - [[ -n $1 ]] && _p9k__ret="%K{$1}" || _p9k__ret="%k" -} - -_p9k_foreground() { - # Note: This code used to produce `%1F` instead of `%F{1}` because it's more efficient. - # Unfortunately, this triggers a bug in zsh. Namely, `%1F{2}` gets percent-expanded as if - # it was `%F{2}`. - [[ -n $1 ]] && _p9k__ret="%F{$1}" || _p9k__ret="%f" -} - -_p9k_escape_style() { - [[ $1 == *'}'* ]] && _p9k__ret='${:-"'$1'"}' || _p9k__ret=$1 -} - -_p9k_escape() { - [[ $1 == *["~!#\`\$^&*()\\\"'<>?{}[]"]* ]] && _p9k__ret="\${(Q)\${:-${(qqq)${(q)1}}}}" || _p9k__ret=$1 -} - -# * $1: Name of the function that was originally invoked. -# Necessary, to make the dynamic color-overwrite mechanism work. -# * $2: Background color. -# * $3: Foreground color. -# * $4: An identifying icon. -# * $5: 1 to to perform parameter expansion and process substitution. -# * $6: If not empty but becomes empty after parameter expansion and process substitution, -# the segment isn't rendered. -# * $7: Content. -_p9k_left_prompt_segment() { - if ! _p9k_cache_get "$0" "$1" "$2" "$3" "$4" "$_p9k__segment_index"; then - _p9k_color $1 BACKGROUND $2 - local bg_color=$_p9k__ret - _p9k_background $bg_color - local bg=$_p9k__ret - - _p9k_color $1 FOREGROUND $3 - local fg_color=$_p9k__ret - _p9k_foreground $fg_color - local fg=$_p9k__ret - - local style=%b$bg$fg - local style_=${style//\}/\\\}} - - _p9k_get_icon $1 LEFT_SEGMENT_SEPARATOR - local sep=$_p9k__ret - _p9k_escape $_p9k__ret - local sep_=$_p9k__ret - - _p9k_get_icon $1 LEFT_SUBSEGMENT_SEPARATOR - _p9k_escape $_p9k__ret - local subsep_=$_p9k__ret - - local icon_ - if [[ -n $4 ]]; then - _p9k_get_icon $1 $4 - _p9k_escape $_p9k__ret - icon_=$_p9k__ret - fi - - _p9k_get_icon $1 LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL - local start_sep=$_p9k__ret - [[ -n $start_sep ]] && start_sep="%b%k%F{$bg_color}$start_sep" - - _p9k_get_icon $1 LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL $sep - _p9k_escape $_p9k__ret - local end_sep_=$_p9k__ret - - _p9k_get_icon $1 WHITESPACE_BETWEEN_LEFT_SEGMENTS ' ' - local space=$_p9k__ret - - _p9k_get_icon $1 LEFT_LEFT_WHITESPACE $space - local left_space=$_p9k__ret - [[ $left_space == *%* ]] && left_space+=$style - - _p9k_get_icon $1 LEFT_RIGHT_WHITESPACE $space - _p9k_escape $_p9k__ret - local right_space_=$_p9k__ret - [[ $right_space_ == *%* ]] && right_space_+=$style_ - - local s='<_p9k__s>' ss='<_p9k__ss>' - - local -i non_hermetic=0 - - # Segment separator logic: - # - # if [[ $_p9k__bg == NONE ]]; then - # 1 - # elif (( joined )); then - # 2 - # elif [[ $bg_color == (${_p9k__bg}|${_p9k__bg:-0}) ]]; then - # 3 - # else - # 4 - # fi - - local t=$(($#_p9k_t - __p9k_ksh_arrays)) - _p9k_t+=$start_sep$style$left_space # 1 - _p9k_t+=$style # 2 - if [[ -n $fg_color && $fg_color == $bg_color ]]; then - if [[ $fg_color == $_p9k_color1 ]]; then - _p9k_foreground $_p9k_color2 - else - _p9k_foreground $_p9k_color1 - fi - _p9k_t+=%b$bg$_p9k__ret$ss$style$left_space # 3 - else - _p9k_t+=%b$bg$ss$style$left_space # 3 - fi - _p9k_t+=%b$bg$s$style$left_space # 4 - - local join="_p9k__i>=$_p9k_left_join[$_p9k__segment_index]" - _p9k_param $1 SELF_JOINED false - if [[ $_p9k__ret == false ]]; then - if (( _p9k__segment_index > $_p9k_left_join[$_p9k__segment_index] )); then - join+="&&_p9k__i<$_p9k__segment_index" - else - join= - fi - fi - - local p= - p+="\${_p9k__n::=}" - p+="\${\${\${_p9k__bg:-0}:#NONE}:-\${_p9k__n::=$((t+1))}}" # 1 - if [[ -n $join ]]; then - p+="\${_p9k__n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 - fi - if (( __p9k_sh_glob )); then - p+="\${_p9k__n:=\${\${(M)\${:-x$bg_color}:#x\$_p9k__bg}:+$((t+3))}}" # 3 - p+="\${_p9k__n:=\${\${(M)\${:-x$bg_color}:#x\$${_p9k__bg:-0}}:+$((t+3))}}" # 3 - else - p+="\${_p9k__n:=\${\${(M)\${:-x$bg_color}:#x(\$_p9k__bg|\${_p9k__bg:-0})}:+$((t+3))}}" # 3 - fi - p+="\${_p9k__n:=$((t+4))}" # 4 - - _p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}' - [[ $_p9k__ret == (|*[^\\])'$('* ]] && non_hermetic=1 - local icon_exp_=${_p9k__ret:+\"$_p9k__ret\"} - - _p9k_param $1 CONTENT_EXPANSION '${P9K_CONTENT}' - [[ $_p9k__ret == (|*[^\\])'$('* ]] && non_hermetic=1 - local content_exp_=${_p9k__ret:+\"$_p9k__ret\"} - - if [[ ( $icon_exp_ != '"${P9K_VISUAL_IDENTIFIER}"' && $icon_exp_ == *'$'* ) || - ( $content_exp_ != '"${P9K_CONTENT}"' && $content_exp_ == *'$'* ) ]]; then - p+="\${P9K_VISUAL_IDENTIFIER::=$icon_}" - fi - - local -i has_icon=-1 # maybe - - if [[ $icon_exp_ != '"${P9K_VISUAL_IDENTIFIER}"' && $icon_exp_ == *'$'* ]]; then - p+='${_p9k__v::='$icon_exp_$style_'}' - else - [[ $icon_exp_ == '"${P9K_VISUAL_IDENTIFIER}"' ]] && _p9k__ret=$icon_ || _p9k__ret=$icon_exp_ - if [[ -n $_p9k__ret ]]; then - p+="\${_p9k__v::=$_p9k__ret" - [[ $_p9k__ret == *%* ]] && p+=$style_ - p+="}" - has_icon=1 # definitely yes - else - has_icon=0 # definitely no - fi - fi - - p+='${_p9k__c::='$content_exp_'}${_p9k__c::=${_p9k__c//'$'\r''}}' - p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}l${${1#prompt_}%%[A-Z0-9_]#}'+00}:-' - if (( has_icon == -1 )); then - p+='${${(%):-$_p9k__c%1(l.1.0)}[-1]}${${(%):-$_p9k__v%1(l.1.0)}[-1]}}' - else - p+='${${(%):-$_p9k__c%1(l.1.0)}[-1]}'$has_icon'}' - fi - - p+='}}+}' - - p+='${${_p9k__e:#00}:+${${_p9k_t[$_p9k__n]/'$ss'/$_p9k__ss}/'$s'/$_p9k__s}' - - _p9k_param $1 ICON_BEFORE_CONTENT '' - if [[ $_p9k__ret != false ]]; then - _p9k_param $1 PREFIX '' - _p9k__ret=${(g::)_p9k__ret} - _p9k_escape $_p9k__ret - p+=$_p9k__ret - [[ $_p9k__ret == *%* ]] && local -i need_style=1 || local -i need_style=0 - - if (( has_icon != 0 )); then - _p9k_color $1 VISUAL_IDENTIFIER_COLOR $fg_color - _p9k_foreground $_p9k__ret - _p9k__ret=%b$bg$_p9k__ret - _p9k__ret=${_p9k__ret//\}/\\\}} - if [[ $_p9k__ret != $style_ ]]; then - p+=$_p9k__ret'${_p9k__v}'$style_ - else - (( need_style )) && p+=$style_ - p+='${_p9k__v}' - fi - - _p9k_get_icon $1 LEFT_MIDDLE_WHITESPACE ' ' - if [[ -n $_p9k__ret ]]; then - _p9k_escape $_p9k__ret - [[ _p9k__ret == *%* ]] && _p9k__ret+=$style_ - p+='${${(M)_p9k__e:#11}:+'$_p9k__ret'}' - fi - elif (( need_style )); then - p+=$style_ - fi - - p+='${_p9k__c}'$style_ - else - _p9k_param $1 PREFIX '' - _p9k__ret=${(g::)_p9k__ret} - _p9k_escape $_p9k__ret - p+=$_p9k__ret - [[ $_p9k__ret == *%* ]] && p+=$style_ - - p+='${_p9k__c}'$style_ - - if (( has_icon != 0 )); then - local -i need_style=0 - _p9k_get_icon $1 LEFT_MIDDLE_WHITESPACE ' ' - if [[ -n $_p9k__ret ]]; then - _p9k_escape $_p9k__ret - [[ $_p9k__ret == *%* ]] && need_style=1 - p+='${${(M)_p9k__e:#11}:+'$_p9k__ret'}' - fi - - _p9k_color $1 VISUAL_IDENTIFIER_COLOR $fg_color - _p9k_foreground $_p9k__ret - _p9k__ret=%b$bg$_p9k__ret - _p9k__ret=${_p9k__ret//\}/\\\}} - [[ $_p9k__ret != $style_ || $need_style == 1 ]] && p+=$_p9k__ret - p+='$_p9k__v' - fi - fi - - _p9k_param $1 SUFFIX '' - _p9k__ret=${(g::)_p9k__ret} - _p9k_escape $_p9k__ret - p+=$_p9k__ret - [[ $_p9k__ret == *%* && -n $right_space_ ]] && p+=$style_ - p+=$right_space_ - - p+='${${:-' - p+="\${_p9k__s::=%F{$bg_color\}$sep_}\${_p9k__ss::=$subsep_}\${_p9k__sss::=%F{$bg_color\}$end_sep_}" - p+="\${_p9k__i::=$_p9k__segment_index}\${_p9k__bg::=$bg_color}" - p+='}+}' - - p+='}' - - _p9k_param $1 SHOW_ON_UPGLOB '' - _p9k_cache_set "$p" $non_hermetic $_p9k__ret - fi - - if [[ -n $_p9k__cache_val[3] ]]; then - _p9k__has_upglob=1 - _p9k_upglob $_p9k__cache_val[3] && return - fi - - _p9k__non_hermetic_expansion=$_p9k__cache_val[2] - - (( $5 )) && _p9k__ret=\"$7\" || _p9k_escape $7 - if [[ -z $6 ]]; then - _p9k__prompt+="\${\${:-\${P9K_CONTENT::=$_p9k__ret}$_p9k__cache_val[1]" - else - _p9k__prompt+="\${\${:-\"$6\"}:+\${\${:-\${P9K_CONTENT::=$_p9k__ret}$_p9k__cache_val[1]}" - fi -} - -# The same as _p9k_left_prompt_segment above but for the right prompt. -_p9k_right_prompt_segment() { - if ! _p9k_cache_get "$0" "$1" "$2" "$3" "$4" "$_p9k__segment_index"; then - _p9k_color $1 BACKGROUND $2 - local bg_color=$_p9k__ret - _p9k_background $bg_color - local bg=$_p9k__ret - local bg_=${_p9k__ret//\}/\\\}} - - _p9k_color $1 FOREGROUND $3 - local fg_color=$_p9k__ret - _p9k_foreground $fg_color - local fg=$_p9k__ret - - local style=%b$bg$fg - local style_=${style//\}/\\\}} - - _p9k_get_icon $1 RIGHT_SEGMENT_SEPARATOR - local sep=$_p9k__ret - _p9k_escape $_p9k__ret - local sep_=$_p9k__ret - - _p9k_get_icon $1 RIGHT_SUBSEGMENT_SEPARATOR - local subsep=$_p9k__ret - [[ $subsep == *%* ]] && subsep+=$style - - local icon_ - if [[ -n $4 ]]; then - _p9k_get_icon $1 $4 - _p9k_escape $_p9k__ret - icon_=$_p9k__ret - fi - - _p9k_get_icon $1 RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL $sep - local start_sep=$_p9k__ret - [[ -n $start_sep ]] && start_sep="%b%k%F{$bg_color}$start_sep" - - _p9k_get_icon $1 RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL - _p9k_escape $_p9k__ret - local end_sep_=$_p9k__ret - - _p9k_get_icon $1 WHITESPACE_BETWEEN_RIGHT_SEGMENTS ' ' - local space=$_p9k__ret - - _p9k_get_icon $1 RIGHT_LEFT_WHITESPACE $space - local left_space=$_p9k__ret - [[ $left_space == *%* ]] && left_space+=$style - - _p9k_get_icon $1 RIGHT_RIGHT_WHITESPACE $space - _p9k_escape $_p9k__ret - local right_space_=$_p9k__ret - [[ $right_space_ == *%* ]] && right_space_+=$style_ - - local w='<_p9k__w>' s='<_p9k__s>' - - local -i non_hermetic=0 - - # Segment separator logic: - # - # if [[ $_p9k__bg == NONE ]]; then - # 1 - # elif (( joined )); then - # 2 - # elif [[ $_p9k__bg == (${bg_color}|${bg_color:-0}) ]]; then - # 3 - # else - # 4 - # fi - - local t=$(($#_p9k_t - __p9k_ksh_arrays)) - _p9k_t+=$start_sep$style$left_space # 1 - _p9k_t+=$w$style # 2 - _p9k_t+=$w$style$subsep$left_space # 3 - _p9k_t+=$w%F{$bg_color}$sep$style$left_space # 4 - - local join="_p9k__i>=$_p9k_right_join[$_p9k__segment_index]" - _p9k_param $1 SELF_JOINED false - if [[ $_p9k__ret == false ]]; then - if (( _p9k__segment_index > $_p9k_right_join[$_p9k__segment_index] )); then - join+="&&_p9k__i<$_p9k__segment_index" - else - join= - fi - fi - - local p= - p+="\${_p9k__n::=}" - p+="\${\${\${_p9k__bg:-0}:#NONE}:-\${_p9k__n::=$((t+1))}}" # 1 - if [[ -n $join ]]; then - p+="\${_p9k__n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 - fi - if (( __p9k_sh_glob )); then - p+="\${_p9k__n:=\${\${(M)\${:-x\$_p9k__bg}:#x${(b)bg_color}}:+$((t+3))}}" # 3 - p+="\${_p9k__n:=\${\${(M)\${:-x\$_p9k__bg}:#x${(b)bg_color:-0}}:+$((t+3))}}" # 3 - else - p+="\${_p9k__n:=\${\${(M)\${:-x\$_p9k__bg}:#x(${(b)bg_color}|${(b)bg_color:-0})}:+$((t+3))}}" # 3 - fi - p+="\${_p9k__n:=$((t+4))}" # 4 - - _p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}' - [[ $_p9k__ret == (|*[^\\])'$('* ]] && non_hermetic=1 - local icon_exp_=${_p9k__ret:+\"$_p9k__ret\"} - - _p9k_param $1 CONTENT_EXPANSION '${P9K_CONTENT}' - [[ $_p9k__ret == (|*[^\\])'$('* ]] && non_hermetic=1 - local content_exp_=${_p9k__ret:+\"$_p9k__ret\"} - - if [[ ( $icon_exp_ != '"${P9K_VISUAL_IDENTIFIER}"' && $icon_exp_ == *'$'* ) || - ( $content_exp_ != '"${P9K_CONTENT}"' && $content_exp_ == *'$'* ) ]]; then - p+="\${P9K_VISUAL_IDENTIFIER::=$icon_}" - fi - - local -i has_icon=-1 # maybe - - if [[ $icon_exp_ != '"${P9K_VISUAL_IDENTIFIER}"' && $icon_exp_ == *'$'* ]]; then - p+="\${_p9k__v::=$icon_exp_$style_}" - else - [[ $icon_exp_ == '"${P9K_VISUAL_IDENTIFIER}"' ]] && _p9k__ret=$icon_ || _p9k__ret=$icon_exp_ - if [[ -n $_p9k__ret ]]; then - p+="\${_p9k__v::=$_p9k__ret" - [[ $_p9k__ret == *%* ]] && p+=$style_ - p+="}" - has_icon=1 # definitely yes - else - has_icon=0 # definitely no - fi - fi - - p+='${_p9k__c::='$content_exp_'}${_p9k__c::=${_p9k__c//'$'\r''}}' - p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}r${${1#prompt_}%%[A-Z0-9_]#}'+00}:-' - if (( has_icon == -1 )); then - p+='${${(%):-$_p9k__c%1(l.1.0)}[-1]}${${(%):-$_p9k__v%1(l.1.0)}[-1]}}' - else - p+='${${(%):-$_p9k__c%1(l.1.0)}[-1]}'$has_icon'}' - fi - - p+='}}+}' - - p+='${${_p9k__e:#00}:+${_p9k_t[$_p9k__n]/'$w'/$_p9k__w}' - - _p9k_param $1 ICON_BEFORE_CONTENT '' - if [[ $_p9k__ret != true ]]; then - _p9k_param $1 PREFIX '' - _p9k__ret=${(g::)_p9k__ret} - _p9k_escape $_p9k__ret - p+=$_p9k__ret - [[ $_p9k__ret == *%* ]] && p+=$style_ - - p+='${_p9k__c}'$style_ - - if (( has_icon != 0 )); then - local -i need_style=0 - _p9k_get_icon $1 RIGHT_MIDDLE_WHITESPACE ' ' - if [[ -n $_p9k__ret ]]; then - _p9k_escape $_p9k__ret - [[ $_p9k__ret == *%* ]] && need_style=1 - p+='${${(M)_p9k__e:#11}:+'$_p9k__ret'}' - fi - - _p9k_color $1 VISUAL_IDENTIFIER_COLOR $fg_color - _p9k_foreground $_p9k__ret - _p9k__ret=%b$bg$_p9k__ret - _p9k__ret=${_p9k__ret//\}/\\\}} - [[ $_p9k__ret != $style_ || $need_style == 1 ]] && p+=$_p9k__ret - p+='$_p9k__v' - fi - else - _p9k_param $1 PREFIX '' - _p9k__ret=${(g::)_p9k__ret} - _p9k_escape $_p9k__ret - p+=$_p9k__ret - [[ $_p9k__ret == *%* ]] && local -i need_style=1 || local -i need_style=0 - - if (( has_icon != 0 )); then - _p9k_color $1 VISUAL_IDENTIFIER_COLOR $fg_color - _p9k_foreground $_p9k__ret - _p9k__ret=%b$bg$_p9k__ret - _p9k__ret=${_p9k__ret//\}/\\\}} - if [[ $_p9k__ret != $style_ ]]; then - p+=$_p9k__ret'${_p9k__v}'$style_ - else - (( need_style )) && p+=$style_ - p+='${_p9k__v}' - fi - - _p9k_get_icon $1 RIGHT_MIDDLE_WHITESPACE ' ' - if [[ -n $_p9k__ret ]]; then - _p9k_escape $_p9k__ret - [[ _p9k__ret == *%* ]] && _p9k__ret+=$style_ - p+='${${(M)_p9k__e:#11}:+'$_p9k__ret'}' - fi - elif (( need_style )); then - p+=$style_ - fi - - p+='${_p9k__c}'$style_ - fi - - _p9k_param $1 SUFFIX '' - _p9k__ret=${(g::)_p9k__ret} - _p9k_escape $_p9k__ret - p+=$_p9k__ret - - p+='${${:-' - - if [[ -n $fg_color && $fg_color == $bg_color ]]; then - if [[ $fg_color == $_p9k_color1 ]]; then - _p9k_foreground $_p9k_color2 - else - _p9k_foreground $_p9k_color1 - fi - else - _p9k__ret=$fg - fi - _p9k__ret=${_p9k__ret//\}/\\\}} - p+="\${_p9k__w::=${right_space_:+$style_}$right_space_%b$bg_$_p9k__ret}" - - p+='${_p9k__sss::=' - p+=$style_$right_space_ - [[ $right_space_ == *%* ]] && p+=$style_ - if [[ -n $end_sep_ ]]; then - p+="%k%F{$bg_color\}$end_sep_$style_" - fi - p+='}' - - p+="\${_p9k__i::=$_p9k__segment_index}\${_p9k__bg::=$bg_color}" - - p+='}+}' - p+='}' - - _p9k_param $1 SHOW_ON_UPGLOB '' - _p9k_cache_set "$p" $non_hermetic $_p9k__ret - fi - - if [[ -n $_p9k__cache_val[3] ]]; then - _p9k__has_upglob=1 - _p9k_upglob $_p9k__cache_val[3] && return - fi - - _p9k__non_hermetic_expansion=$_p9k__cache_val[2] - - (( $5 )) && _p9k__ret=\"$7\" || _p9k_escape $7 - if [[ -z $6 ]]; then - _p9k__prompt+="\${\${:-\${P9K_CONTENT::=$_p9k__ret}$_p9k__cache_val[1]" - else - _p9k__prompt+="\${\${:-\"$6\"}:+\${\${:-\${P9K_CONTENT::=$_p9k__ret}$_p9k__cache_val[1]}" - fi -} - -function _p9k_prompt_segment() { "_p9k_${_p9k__prompt_side}_prompt_segment" "$@" } -function p9k_prompt_segment() { p10k segment "$@" } - -function _p9k_python_version() { - case $commands[python] in - "") - return 1 - ;; - ${PYENV_ROOT:-~/.pyenv}/shims/python) - local P9K_PYENV_PYTHON_VERSION _p9k__pyenv_version - local -i _POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=1 _POWERLEVEL9K_PYENV_SHOW_SYSTEM=1 - local _POWERLEVEL9K_PYENV_SOURCES=(shell local global) - if _p9k_pyenv_compute && [[ $P9K_PYENV_PYTHON_VERSION == ([[:digit:].]##)* ]]; then - _p9k__ret=$P9K_PYENV_PYTHON_VERSION - return 0 - fi - ;& # fall through - *) - _p9k_cached_cmd 1 '' python --version || return - [[ $_p9k__ret == (#b)Python\ ([[:digit:].]##)* ]] && _p9k__ret=$match[1] - ;; - esac -} - -################################################################ -# Prompt Segment Definitions -################################################################ - -################################################################ -# Anaconda Environment -prompt_anaconda() { - local msg - if _p9k_python_version; then - P9K_ANACONDA_PYTHON_VERSION=$_p9k__ret - if (( _POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION )); then - msg="${P9K_ANACONDA_PYTHON_VERSION//\%/%%} " - fi - else - unset P9K_ANACONDA_PYTHON_VERSION - fi - local p=${CONDA_PREFIX:-$CONDA_ENV_PATH} - msg+="$_POWERLEVEL9K_ANACONDA_LEFT_DELIMITER${${p:t}//\%/%%}$_POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "$msg" -} - -_p9k_prompt_anaconda_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${CONDA_PREFIX:-$CONDA_ENV_PATH}' -} - -# Populates array `reply` with "$#profile:$profile:$region" where $profile and $region -# come from the AWS config (~/.aws/config). -function _p9k_parse_aws_config() { - local cfg=$1 - typeset -ga reply=() - [[ -f $cfg && -r $cfg ]] || return - - local -a lines - lines=(${(f)"$(<$cfg)"}) || return - - local line profile - local -a match mbegin mend - for line in $lines; do - if [[ $line == [[:space:]]#'[default]'[[:space:]]#(|'#'*) ]]; then - # example: [default] - profile=default - elif [[ $line == (#b)'[profile'[[:space:]]##([^[:space:]]|[^[:space:]]*[^[:space:]])[[:space:]]#']'[[:space:]]#(|'#'*) ]]; then - # example: [profile prod] - profile=${(Q)match[1]} - elif [[ $line == (#b)[[:space:]]#region[[:space:]]#=[[:space:]]#([^[:space:]]|[^[:space:]]*[^[:space:]])[[:space:]]# ]]; then - # example: region = eu-west-1 - if [[ -n $profile ]]; then - reply+=$#profile:$profile:$match[1] - profile= - fi - fi - done -} - -################################################################ -# AWS Profile -prompt_aws() { - typeset -g P9K_AWS_PROFILE="${AWS_VAULT:-${AWSUME_PROFILE:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}}" - local pat class state - for pat class in "${_POWERLEVEL9K_AWS_CLASSES[@]}"; do - if [[ $P9K_AWS_PROFILE == ${~pat} ]]; then - [[ -n $class ]] && state=_${${(U)class}//İ/I} - break - fi - done - - if [[ -n ${AWS_REGION:-$AWS_DEFAULT_REGION} ]]; then - typeset -g P9K_AWS_REGION=${AWS_REGION:-$AWS_DEFAULT_REGION} - else - local cfg=${AWS_CONFIG_FILE:-~/.aws/config} - if ! _p9k_cache_stat_get $0 $cfg; then - local -a reply - _p9k_parse_aws_config $cfg - _p9k_cache_stat_set $reply - fi - local prefix=$#P9K_AWS_PROFILE:$P9K_AWS_PROFILE: - local kv=$_p9k__cache_val[(r)${(b)prefix}*] - typeset -g P9K_AWS_REGION=${kv#$prefix} - fi - - _p9k_prompt_segment "$0$state" red white 'AWS_ICON' 0 '' "${P9K_AWS_PROFILE//\%/%%}" -} - -_p9k_prompt_aws_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${AWS_VAULT:-${AWSUME_PROFILE:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}}' -} - -################################################################ -# Current Elastic Beanstalk environment -prompt_aws_eb_env() { - _p9k_upglob .elasticbeanstalk && return - local dir=$_p9k__parent_dirs[$?] - - if ! _p9k_cache_stat_get $0 $dir/.elasticbeanstalk/config.yml; then - local env - env="$(command eb list 2>/dev/null)" || env= - env="${${(@M)${(@f)env}:#\* *}#\* }" - _p9k_cache_stat_set "$env" - fi - [[ -n $_p9k__cache_val[1] ]] || return - _p9k_prompt_segment "$0" black green 'AWS_EB_ICON' 0 '' "${_p9k__cache_val[1]//\%/%%}" -} - -_p9k_prompt_aws_eb_env_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[eb]' -} - -################################################################ -# Segment to indicate background jobs with an icon. -prompt_background_jobs() { - local -i len=$#_p9k__prompt _p9k__has_upglob - local msg - if (( _POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE )); then - if (( _POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS )); then - msg='${(%):-%j}' - else - msg='${${(%):-%j}:#1}' - fi - fi - _p9k_prompt_segment $0 "$_p9k_color1" cyan BACKGROUND_JOBS_ICON 1 '${${(%):-%j}:#0}' "$msg" - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -################################################################ -# Segment that indicates usage level of current partition. -prompt_disk_usage() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0_CRITICAL red white DISK_ICON 1 '$_p9k__disk_usage_critical' '$_p9k__disk_usage_pct%%' - _p9k_prompt_segment $0_WARNING yellow $_p9k_color1 DISK_ICON 1 '$_p9k__disk_usage_warning' '$_p9k__disk_usage_pct%%' - if (( ! _POWERLEVEL9K_DISK_USAGE_ONLY_WARNING )); then - _p9k_prompt_segment $0_NORMAL $_p9k_color1 yellow DISK_ICON 1 '$_p9k__disk_usage_normal' '$_p9k__disk_usage_pct%%' - fi - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_disk_usage_init() { - typeset -g _p9k__disk_usage_pct= - typeset -g _p9k__disk_usage_normal= - typeset -g _p9k__disk_usage_warning= - typeset -g _p9k__disk_usage_critical= - _p9k__async_segments_compute+='_p9k_worker_invoke disk_usage "_p9k_prompt_disk_usage_compute ${(q)_p9k__cwd_a}"' -} - -_p9k_prompt_disk_usage_compute() { - (( $+commands[df] )) || return - _p9k_worker_async "_p9k_prompt_disk_usage_async ${(q)1}" _p9k_prompt_disk_usage_sync -} - -_p9k_prompt_disk_usage_async() { - local pct=${${=${(f)"$(df -P $1 2>/dev/null)"}[2]}[5]%%%} - [[ $pct == <0-100> && $pct != $_p9k__disk_usage_pct ]] || return - _p9k__disk_usage_pct=$pct - _p9k__disk_usage_normal= - _p9k__disk_usage_warning= - _p9k__disk_usage_critical= - if (( _p9k__disk_usage_pct >= _POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL )); then - _p9k__disk_usage_critical=1 - elif (( _p9k__disk_usage_pct >= _POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL )); then - _p9k__disk_usage_warning=1 - elif (( ! _POWERLEVEL9K_DISK_USAGE_ONLY_WARNING )); then - _p9k__disk_usage_normal=1 - fi - _p9k_print_params \ - _p9k__disk_usage_pct \ - _p9k__disk_usage_normal \ - _p9k__disk_usage_warning \ - _p9k__disk_usage_critical - echo -E - 'reset=1' -} - -_p9k_prompt_disk_usage_sync() { - eval $REPLY - _p9k_worker_reply $REPLY -} - -function _p9k_read_file() { - _p9k__ret='' - [[ -n $1 ]] && IFS='' read -r _p9k__ret <$1 - [[ -n $_p9k__ret ]] -} - -function _p9k_fvm_old() { - _p9k_upglob fvm && return 1 - local fvm=$_p9k__parent_dirs[$?]/fvm - if [[ -L $fvm ]]; then - if [[ ${fvm:A} == (#b)*/versions/([^/]##)/bin/flutter ]]; then - _p9k_prompt_segment prompt_fvm blue $_p9k_color1 FLUTTER_ICON 0 '' ${match[1]//\%/%%} - return 0 - fi - fi - return 1 -} - -function _p9k_fvm_new() { - _p9k_upglob .fvm && return 1 - local sdk=$_p9k__parent_dirs[$?]/.fvm/flutter_sdk - if [[ -L $sdk ]]; then - if [[ ${sdk:A} == (#b)*/versions/([^/]##) ]]; then - _p9k_prompt_segment prompt_fvm blue $_p9k_color1 FLUTTER_ICON 0 '' ${match[1]//\%/%%} - return 0 - fi - fi - return 1 -} - -prompt_fvm() { - _p9k_fvm_new || _p9k_fvm_old -} - -_p9k_prompt_fvm_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[fvm]' -} - -################################################################ -# Segment that displays the battery status in levels and colors -prompt_battery() { - [[ $_p9k_os == (Linux|Android) ]] && _p9k_prompt_battery_set_args - (( $#_p9k__battery_args )) && _p9k_prompt_segment "${_p9k__battery_args[@]}" -} - -_p9k_prompt_battery_init() { - typeset -ga _p9k__battery_args=() - if [[ $_p9k_os == OSX && $+commands[pmset] == 1 ]]; then - _p9k__async_segments_compute+='_p9k_worker_invoke battery _p9k_prompt_battery_compute' - return - fi - if [[ $_p9k_os != (Linux|Android) || - -z /sys/class/power_supply/(CMB*|BAT*|*battery)/(energy_full|charge_full|charge_counter)(#qN) ]]; then - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${:-}' - fi -} - -_p9k_prompt_battery_compute() { - _p9k_worker_async _p9k_prompt_battery_async _p9k_prompt_battery_sync -} - -_p9k_prompt_battery_async() { - local prev="${(pj:\0:)_p9k__battery_args}" - _p9k_prompt_battery_set_args - [[ "${(pj:\0:)_p9k__battery_args}" == $prev ]] && return 1 - _p9k_print_params _p9k__battery_args - echo -E - 'reset=2' -} - -_p9k_prompt_battery_sync() { - eval $REPLY - _p9k_worker_reply $REPLY -} - -_p9k_prompt_battery_set_args() { - _p9k__battery_args=() - - local state remain - local -i bat_percent - - case $_p9k_os in - OSX) - (( $+commands[pmset] )) || return - local raw_data=${${(Af)"$(pmset -g batt 2>/dev/null)"}[2]} - [[ $raw_data == *InternalBattery* ]] || return - remain=${${(s: :)${${(s:; :)raw_data}[3]}}[1]} - [[ $remain == *no* ]] && remain="..." - [[ $raw_data =~ '([0-9]+)%' ]] && bat_percent=$match[1] - - case "${${(s:; :)raw_data}[2]}" in - 'charging'|'finishing charge'|'AC attached') - if (( bat_percent == 100 )); then - state=CHARGED - remain='' - else - state=CHARGING - fi - ;; - 'discharging') - (( bat_percent < _POWERLEVEL9K_BATTERY_LOW_THRESHOLD )) && state=LOW || state=DISCONNECTED - ;; - *) - state=CHARGED - remain='' - ;; - esac - ;; - - Linux|Android) - # See https://sourceforge.net/projects/acpiclient. - local -a bats=( /sys/class/power_supply/(CMB*|BAT*|*battery)/(FN) ) - (( $#bats )) || return - - local -i energy_now energy_full power_now - local -i is_full=1 is_calculating is_charching - local dir - for dir in $bats; do - local -i pow=0 full=0 - if _p9k_read_file $dir/(energy_full|charge_full|charge_counter)(N); then - (( energy_full += ${full::=_p9k__ret} )) - fi - if _p9k_read_file $dir/(power|current)_now(N) && (( $#_p9k__ret < 9 )); then - (( power_now += ${pow::=$_p9k__ret} )) - fi - if _p9k_read_file $dir/capacity(N); then - (( energy_now += _p9k__ret * full / 100. + 0.5 )) - elif _p9k_read_file $dir/(energy|charge)_now(N); then - (( energy_now += _p9k__ret )) - fi - _p9k_read_file $dir/status(N) && local bat_status=$_p9k__ret || continue - [[ $bat_status != Full ]] && is_full=0 - [[ $bat_status == Charging ]] && is_charching=1 - [[ $bat_status == (Charging|Discharging) && $pow == 0 ]] && is_calculating=1 - done - - (( energy_full )) || return - - bat_percent=$(( 100. * energy_now / energy_full + 0.5 )) - (( bat_percent > 100 )) && bat_percent=100 - - if (( is_full || (bat_percent == 100 && is_charching) )); then - state=CHARGED - else - if (( is_charching )); then - state=CHARGING - elif (( bat_percent < _POWERLEVEL9K_BATTERY_LOW_THRESHOLD )); then - state=LOW - else - state=DISCONNECTED - fi - - if (( power_now > 0 )); then - (( is_charching )) && local -i e=$((energy_full - energy_now)) || local -i e=energy_now - local -i minutes=$(( 60 * e / power_now )) - (( minutes > 0 )) && remain=$((minutes/60)):${(l#2##0#)$((minutes%60))} - elif (( is_calculating )); then - remain="..." - fi - fi - ;; - - *) - return 0 - ;; - esac - - (( bat_percent >= _POWERLEVEL9K_BATTERY_${state}_HIDE_ABOVE_THRESHOLD )) && return - - local msg="$bat_percent%%" - [[ $_POWERLEVEL9K_BATTERY_VERBOSE == 1 && -n $remain ]] && msg+=" ($remain)" - - local icon=BATTERY_ICON - local var=_POWERLEVEL9K_BATTERY_${state}_STAGES - local -i idx="${#${(@P)var}}" - if (( idx )); then - (( bat_percent < 100 )) && idx=$((bat_percent * idx / 100 + 1)) - icon=$'\1'"${${(@P)var}[idx]}" - fi - - local bg=$_p9k_color1 - local var=_POWERLEVEL9K_BATTERY_${state}_LEVEL_BACKGROUND - local -i idx="${#${(@P)var}}" - if (( idx )); then - (( bat_percent < 100 )) && idx=$((bat_percent * idx / 100 + 1)) - bg="${${(@P)var}[idx]}" - fi - - local fg=$_p9k_battery_states[$state] - local var=_POWERLEVEL9K_BATTERY_${state}_LEVEL_FOREGROUND - local -i idx="${#${(@P)var}}" - if (( idx )); then - (( bat_percent < 100 )) && idx=$((bat_percent * idx / 100 + 1)) - fg="${${(@P)var}[idx]}" - fi - - _p9k__battery_args=(prompt_battery_$state "$bg" "$fg" $icon 0 '' $msg) -} - -################################################################ -# Public IP segment -prompt_public_ip() { - local -i len=$#_p9k__prompt _p9k__has_upglob - local ip='${_p9k__public_ip:-$_POWERLEVEL9K_PUBLIC_IP_NONE}' - if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then - _p9k_prompt_segment "$0" "$_p9k_color1" "$_p9k_color2" PUBLIC_IP_ICON 1 '${_p9k__public_ip_not_vpn:+'$ip'}' $ip - _p9k_prompt_segment "$0" "$_p9k_color1" "$_p9k_color2" VPN_ICON 1 '${_p9k__public_ip_vpn:+'$ip'}' $ip - else - _p9k_prompt_segment "$0" "$_p9k_color1" "$_p9k_color2" PUBLIC_IP_ICON 1 $ip $ip - fi - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_public_ip_init() { - typeset -g _p9k__public_ip= - typeset -gF _p9k__public_ip_next_time=0 - _p9k__async_segments_compute+='_p9k_worker_invoke public_ip _p9k_prompt_public_ip_compute' -} - -_p9k_prompt_public_ip_compute() { - (( EPOCHREALTIME >= _p9k__public_ip_next_time )) || return - _p9k_worker_async _p9k_prompt_public_ip_async _p9k_prompt_public_ip_sync -} - -_p9k_prompt_public_ip_async() { - local ip method - local -F start=EPOCHREALTIME - local -F next='start + 5' - for method in $_POWERLEVEL9K_PUBLIC_IP_METHODS $_POWERLEVEL9K_PUBLIC_IP_METHODS; do - case $method in - dig) - if (( $+commands[dig] )); then - ip="$(dig +tries=1 +short -4 A myip.opendns.com @resolver1.opendns.com 2>/dev/null)" - [[ $ip == ';'* ]] && ip= - if [[ -z $ip ]]; then - ip="$(dig +tries=1 +short -6 AAAA myip.opendns.com @resolver1.opendns.com 2>/dev/null)" - [[ $ip == ';'* ]] && ip= - fi - fi - ;; - curl) - if (( $+commands[curl] )); then - ip="$(curl --max-time 5 -w '\n' "$_POWERLEVEL9K_PUBLIC_IP_HOST" 2>/dev/null)" - fi - ;; - wget) - if (( $+commands[wget] )); then - ip="$(wget -T 5 -qO- "$_POWERLEVEL9K_PUBLIC_IP_HOST" 2>/dev/null)" - fi - ;; - esac - [[ $ip =~ '^[0-9a-f.:]+$' ]] || ip='' - if [[ -n $ip ]]; then - next=$((start + _POWERLEVEL9K_PUBLIC_IP_TIMEOUT)) - break - fi - done - _p9k__public_ip_next_time=$next - _p9k_print_params _p9k__public_ip_next_time - [[ $_p9k__public_ip == $ip ]] && return - _p9k__public_ip=$ip - _p9k_print_params _p9k__public_ip - echo -E - 'reset=1' -} - -_p9k_prompt_public_ip_sync() { - eval $REPLY - _p9k_worker_reply $REPLY -} - -################################################################ -# Context: user@hostname (who am I and where am I) -prompt_context() { - local -i len=$#_p9k__prompt _p9k__has_upglob - - local content - if [[ $_POWERLEVEL9K_ALWAYS_SHOW_CONTEXT == 0 && -n $DEFAULT_USER && $P9K_SSH == 0 ]]; then - local user="${(%):-%n}" - if [[ $user == $DEFAULT_USER ]]; then - content="${user//\%/%%}" - fi - fi - - local state - if (( P9K_SSH )); then - if [[ -n "$SUDO_COMMAND" ]]; then - state="REMOTE_SUDO" - else - state="REMOTE" - fi - elif [[ -n "$SUDO_COMMAND" ]]; then - state="SUDO" - else - state="DEFAULT" - fi - - local cond - for state cond in $state '${${(%):-%#}:#\#}' ROOT '${${(%):-%#}:#\%}'; do - local text=$content - if [[ -z $text ]]; then - local var=_POWERLEVEL9K_CONTEXT_${state}_TEMPLATE - if (( $+parameters[$var] )); then - text=${(P)var} - text=${(g::)text} - else - text=$_POWERLEVEL9K_CONTEXT_TEMPLATE - fi - fi - _p9k_prompt_segment "$0_$state" "$_p9k_color1" yellow '' 0 "$cond" "$text" - done - - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -instant_prompt_context() { - if [[ $_POWERLEVEL9K_ALWAYS_SHOW_CONTEXT == 0 && -n $DEFAULT_USER && $P9K_SSH == 0 ]]; then - if [[ ${(%):-%n} == $DEFAULT_USER ]]; then - if (( ! _POWERLEVEL9K_ALWAYS_SHOW_USER )); then - return - fi - fi - fi - prompt_context -} - -_p9k_prompt_context_init() { - if [[ $_POWERLEVEL9K_ALWAYS_SHOW_CONTEXT == 0 && -n $DEFAULT_USER && $P9K_SSH == 0 ]]; then - if [[ ${(%):-%n} == $DEFAULT_USER ]]; then - if (( ! _POWERLEVEL9K_ALWAYS_SHOW_USER )); then - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${:-}' - fi - fi - fi -} - -################################################################ -# User: user (who am I) -prompt_user() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment "${0}_ROOT" "${_p9k_color1}" yellow ROOT_ICON 0 '${${(%):-%#}:#\%}' "$_POWERLEVEL9K_USER_TEMPLATE" - if [[ -n "$SUDO_COMMAND" ]]; then - _p9k_prompt_segment "${0}_SUDO" "${_p9k_color1}" yellow SUDO_ICON 0 '${${(%):-%#}:#\#}' "$_POWERLEVEL9K_USER_TEMPLATE" - else - _p9k_prompt_segment "${0}_DEFAULT" "${_p9k_color1}" yellow USER_ICON 0 '${${(%):-%#}:#\#}' "%n" - fi - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -instant_prompt_user() { - if [[ $_POWERLEVEL9K_ALWAYS_SHOW_USER == 0 && "${(%):-%n}" == $DEFAULT_USER ]]; then - return - fi - prompt_user -} - -_p9k_prompt_user_init() { - if [[ $_POWERLEVEL9K_ALWAYS_SHOW_USER == 0 && "${(%):-%n}" == $DEFAULT_USER ]]; then - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${:-}' - fi -} - -################################################################ -# Host: machine (where am I) -prompt_host() { - local -i len=$#_p9k__prompt _p9k__has_upglob - if (( P9K_SSH )); then - _p9k_prompt_segment "$0_REMOTE" "${_p9k_color1}" yellow SSH_ICON 0 '' "$_POWERLEVEL9K_HOST_TEMPLATE" - else - _p9k_prompt_segment "$0_LOCAL" "${_p9k_color1}" yellow HOST_ICON 0 '' "$_POWERLEVEL9K_HOST_TEMPLATE" - fi - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -instant_prompt_host() { prompt_host; } - -################################################################ -# Toolbox: https://github.com/containers/toolbox -function prompt_toolbox() { - _p9k_prompt_segment $0 $_p9k_color1 yellow TOOLBOX_ICON 0 '' $P9K_TOOLBOX_NAME -} - -_p9k_prompt_toolbox_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$P9K_TOOLBOX_NAME' -} - -function instant_prompt_toolbox() { - _p9k_prompt_segment prompt_toolbox $_p9k_color1 yellow TOOLBOX_ICON 1 '$P9K_TOOLBOX_NAME' '$P9K_TOOLBOX_NAME' -} - -################################################################ -# The 'custom` prompt provides a way for users to invoke commands and display -# the output in a segment. -_p9k_custom_prompt() { - local segment_name=${1:u} - local command=_POWERLEVEL9K_CUSTOM_${segment_name} - command=${(P)command} - local parts=("${(@z)command}") - local cmd="${(Q)parts[1]}" - (( $+functions[$cmd] || $+commands[$cmd] )) || return - local content="$(eval $command)" - [[ -n $content ]] || return - _p9k_prompt_segment "prompt_custom_$1" $_p9k_color2 $_p9k_color1 "CUSTOM_${segment_name}_ICON" 0 '' "$content" -} - -################################################################ -# Display the duration the command needed to run. -prompt_command_execution_time() { - (( $+P9K_COMMAND_DURATION_SECONDS )) || return - (( P9K_COMMAND_DURATION_SECONDS >= _POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD )) || return - - if (( P9K_COMMAND_DURATION_SECONDS < 60 )); then - if (( !_POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION )); then - local -i sec=$((P9K_COMMAND_DURATION_SECONDS + 0.5)) - else - local -F $_POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION sec=P9K_COMMAND_DURATION_SECONDS - fi - local text=${sec}s - else - local -i d=$((P9K_COMMAND_DURATION_SECONDS + 0.5)) - if [[ $_POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT == "H:M:S" ]]; then - local text=${(l.2..0.)$((d % 60))} - if (( d >= 60 )); then - text=${(l.2..0.)$((d / 60 % 60))}:$text - if (( d >= 36000 )); then - text=$((d / 3600)):$text - elif (( d >= 3600 )); then - text=0$((d / 3600)):$text - fi - fi - else - local text="$((d % 60))s" - if (( d >= 60 )); then - text="$((d / 60 % 60))m $text" - if (( d >= 3600 )); then - text="$((d / 3600 % 24))h $text" - if (( d >= 86400 )); then - text="$((d / 86400))d $text" - fi - fi - fi - fi - fi - - _p9k_prompt_segment "$0" "red" "yellow1" 'EXECUTION_TIME_ICON' 0 '' $text -} - -function _p9k_shorten_delim_len() { - local def=$1 - _p9k__ret=${_POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH:--1} - (( _p9k__ret >= 0 )) || _p9k_prompt_length $1 -} - -# Percents are duplicated because this function is currently used only -# where the result is going to be percent-expanded. -function _p9k_url_escape() { - if [[ $1 == [a-zA-Z0-9"/:_.-!'()~ "]# ]]; then - _p9k__ret=${1// /%%20} - else - local c - _p9k__ret= - for c in ${(s::)1}; do - [[ $c == [a-zA-Z0-9"/:_.-!'()~"] ]] || printf -v c '%%%%%02X' $(( #c )) - _p9k__ret+=$c - done - fi -} - -################################################################ -# Dir: current working directory -prompt_dir() { - if (( _POWERLEVEL9K_DIR_PATH_ABSOLUTE )); then - local p=${(V)_p9k__cwd} - local -a parts=("${(s:/:)p}") - elif [[ -o auto_name_dirs ]]; then - local p=${(V)${_p9k__cwd/#(#b)$HOME(|\/*)/'~'$match[1]}} - local -a parts=("${(s:/:)p}") - else - local p=${(%):-%~} - if [[ $p == '~['* ]]; then - # If "${(%):-%~}" expands to "~[a]/]/b", is the first component "~[a]" or "~[a]/]"? - # One would expect "${(%):-%-1~}" to give the right answer but alas it always simply - # gives the segment before the first slash, which would be "~[a]" in this case. Worse, - # for "~[a/b]" it'll give the nonsensical "~[a". To solve this problem we have to - # repeat what "${(%):-%~}" does and hope that it produces the same result. - local func='' - local -a parts=() - for func in zsh_directory_name $zsh_directory_name_functions; do - local reply=() - if (( $+functions[$func] )) && $func d $_p9k__cwd && [[ $p == '~['${(V)reply[1]}']'* ]]; then - parts+='~['${(V)reply[1]}']' - break - fi - done - if (( $#parts )); then - parts+=(${(s:/:)${p#$parts[1]}}) - else - p=${(V)_p9k__cwd} - parts=("${(s:/:)p}") - fi - else - local -a parts=("${(s:/:)p}") - fi - fi - - local -i fake_first=0 expand=0 shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1} - - if (( $+_POWERLEVEL9K_SHORTEN_DELIMITER )); then - local delim=$_POWERLEVEL9K_SHORTEN_DELIMITER - else - if [[ $langinfo[CODESET] == (utf|UTF)(-|)8 ]]; then - local delim=$'\u2026' - else - local delim='..' - fi - fi - - case $_POWERLEVEL9K_SHORTEN_STRATEGY in - truncate_absolute|truncate_absolute_chars) - if (( shortenlen > 0 && $#p > shortenlen )); then - _p9k_shorten_delim_len $delim - if (( $#p > shortenlen + $_p9k__ret )); then - local -i n=shortenlen - local -i i=$#parts - while true; do - local dir=$parts[i] - local -i len=$(( $#dir + (i > 1) )) - if (( len <= n )); then - (( n -= len )) - (( --i )) - else - parts[i]=$'\1'$dir[-n,-1] - parts[1,i-1]=() - break - fi - done - fi - fi - ;; - truncate_with_package_name|truncate_middle|truncate_from_right) - () { - [[ $_POWERLEVEL9K_SHORTEN_STRATEGY == truncate_with_package_name && - $+commands[jq] == 1 && $#_POWERLEVEL9K_DIR_PACKAGE_FILES > 0 ]] || return - local pats="(${(j:|:)_POWERLEVEL9K_DIR_PACKAGE_FILES})" - local -i i=$#parts - local dir=$_p9k__cwd - for (( ; i > 0; --i )); do - local markers=($dir/${~pats}(N)) - if (( $#markers )); then - local pat= pkg_file= - for pat in $_POWERLEVEL9K_DIR_PACKAGE_FILES; do - for pkg_file in $markers; do - [[ $pkg_file == $dir/${~pat} ]] || continue - if ! _p9k_cache_stat_get $0_pkg $pkg_file; then - local pkg_name='' - pkg_name="$(jq -j '.name | select(. != null)' <$pkg_file 2>/dev/null)" || pkg_name='' - _p9k_cache_stat_set "$pkg_name" - fi - [[ -n $_p9k__cache_val[1] ]] || continue - parts[1,i]=($_p9k__cache_val[1]) - fake_first=1 - return 0 - done - done - fi - dir=${dir:h} - done - } - if (( shortenlen > 0 )); then - _p9k_shorten_delim_len $delim - local -i d=_p9k__ret pref=shortenlen suf=0 i=2 - [[ $_POWERLEVEL9K_SHORTEN_STRATEGY == truncate_middle ]] && suf=pref - for (( ; i < $#parts; ++i )); do - local dir=$parts[i] - if (( $#dir > pref + suf + d )); then - dir[pref+1,-suf-1]=$'\1' - parts[i]=$dir - fi - done - fi - ;; - truncate_to_last) - shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1} - (( shortenlen > 0 )) || shortenlen=1 - local -i i='shortenlen+1' - if [[ $#parts -gt i || $p[1] != / && $#parts -gt shortenlen ]]; then - fake_first=1 - parts[1,-i]=() - fi - ;; - truncate_to_first_and_last) - if (( shortenlen > 0 )); then - local -i i=$(( shortenlen + 1 )) - [[ $p == /* ]] && (( ++i )) - for (( ; i <= $#parts - shortenlen; ++i )); do - parts[i]=$'\1' - done - fi - ;; - truncate_to_unique) - expand=1 - delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-'*'} - shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1} - (( shortenlen >= 0 )) || shortenlen=1 - local rp=${(g:oce:)p} - local rparts=("${(@s:/:)rp}") - - local -i i=2 e=$(($#parts - shortenlen)) - if [[ -n $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER ]]; then - (( e += shortenlen )) - local orig=("$parts[2]" "${(@)parts[$((shortenlen > $#parts ? -$#parts : -shortenlen)),-1]}") - elif [[ $p[1] == / ]]; then - (( ++i )) - fi - if (( i <= e )); then - local mtimes=(${(Oa)_p9k__parent_mtimes:$(($#parts-e)):$((e-i+1))}) - local key="${(pj.:.)mtimes}" - else - local key= - fi - if ! _p9k_cache_ephemeral_get $0 $e $i $_p9k__cwd || [[ $key != $_p9k__cache_val[1] ]]; then - local rtail=${(j./.)rparts[i,-1]} - local parent=$_p9k__cwd[1,-2-$#rtail] - _p9k_prompt_length $delim - local -i real_delim_len=_p9k__ret - [[ -n $parts[i-1] ]] && parts[i-1]="\${(Q)\${:-${(qqq)${(q)parts[i-1]}}}}"$'\2' - local -i d=${_POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH:--1} - (( d >= 0 )) || d=real_delim_len - local -i m=1 - for (( ; i <= e; ++i, ++m )); do - local sub=$parts[i] - local rsub=$rparts[i] - local dir=$parent/$rsub mtime=$mtimes[m] - local pair=$_p9k__dir_stat_cache[$dir] - if [[ $pair == ${mtime:-x}:* ]]; then - parts[i]=${pair#*:} - else - [[ $sub != *["~!#\`\$^&*()\\\"'<>?{}[]"]* ]] - local -i q=$? - if [[ -n $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER && - -n $dir/${~_POWERLEVEL9K_SHORTEN_FOLDER_MARKER}(#qN) ]]; then - (( q )) && parts[i]="\${(Q)\${:-${(qqq)${(q)sub}}}}" - parts[i]+=$'\2' - else - local -i j=$rsub[(i)[^.]] - for (( ; j + d < $#rsub; ++j )); do - local -a matching=($parent/$rsub[1,j]*/(N)) - (( $#matching == 1 )) && break - done - local -i saved=$((${(m)#${(V)${rsub:$j}}} - d)) - if (( saved > 0 )); then - if (( q )); then - parts[i]='${${${_p9k__d:#-*}:+${(Q)${:-'${(qqq)${(q)sub}}'}}}:-${(Q)${:-' - parts[i]+=$'\3'${(qqq)${(q)${(V)${rsub[1,j]}}}}$'}}\1\3''${$((_p9k__d+='$saved'))+}}' - else - parts[i]='${${${_p9k__d:#-*}:+'$sub$'}:-\3'${(V)${rsub[1,j]}}$'\1\3''${$((_p9k__d+='$saved'))+}}' - fi - else - (( q )) && parts[i]="\${(Q)\${:-${(qqq)${(q)sub}}}}" - fi - fi - [[ -n $mtime ]] && _p9k__dir_stat_cache[$dir]="$mtime:$parts[i]" - fi - parent+=/$rsub - done - if [[ -n $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER ]]; then - local _2=$'\2' - if [[ $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER == last* ]]; then - (( e = ${parts[(I)*$_2]} + ${_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER#*:} )) - else - (( e = ${parts[(ib:2:)*$_2]} + ${_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER#*:} )) - fi - if (( e > 1 && e <= $#parts )); then - parts[1,e-1]=() - fake_first=1 - elif [[ $p == /?* ]]; then - parts[2]="\${(Q)\${:-${(qqq)${(q)orig[1]}}}}"$'\2' - fi - for ((i = $#parts < shortenlen ? $#parts : shortenlen; i > 0; --i)); do - [[ $#parts[-i] == *$'\2' ]] && continue - if [[ $orig[-i] == *["~!#\`\$^&*()\\\"'<>?{}[]"]* ]]; then - parts[-i]='${(Q)${:-'${(qqq)${(q)orig[-i]}}'}}'$'\2' - else - parts[-i]=${orig[-i]}$'\2' - fi - done - else - for ((; i <= $#parts; ++i)); do - [[ $parts[i] == *["~!#\`\$^&*()\\\"'<>?{}[]"]* ]] && parts[i]='${(Q)${:-'${(qqq)${(q)parts[i]}}'}}' - parts[i]+=$'\2' - done - fi - _p9k_cache_ephemeral_set "$key" "${parts[@]}" - fi - parts=("${(@)_p9k__cache_val[2,-1]}") - ;; - truncate_with_folder_marker) - if [[ -n $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER ]]; then - local dir=$_p9k__cwd - local -a m=() - local -i i=$(($#parts - 1)) - for (( ; i > 1; --i )); do - dir=${dir:h} - [[ -n $dir/${~_POWERLEVEL9K_SHORTEN_FOLDER_MARKER}(#qN) ]] && m+=$i - done - m+=1 - for (( i=1; i < $#m; ++i )); do - (( m[i] - m[i+1] > 2 )) && parts[m[i+1]+1,m[i]-1]=($'\1') - done - fi - ;; - *) - if (( shortenlen > 0 )); then - local -i len=$#parts - [[ -z $parts[1] ]] && (( --len )) - if (( len > shortenlen )); then - parts[1,-shortenlen-1]=($'\1') - fi - fi - ;; - esac - - # w=0: writable - # w=1: not writable - # w=2: does not exist - (( !_POWERLEVEL9K_DIR_SHOW_WRITABLE )) || [[ -w $_p9k__cwd ]] - local -i w=$? - (( w && _POWERLEVEL9K_DIR_SHOW_WRITABLE > 2 )) && [[ ! -e $_p9k__cwd ]] && w=2 - if ! _p9k_cache_ephemeral_get $0 $_p9k__cwd $p $w $fake_first "${parts[@]}"; then - local state=$0 - local icon='' - local a='' b='' c='' - for a b c in "${_POWERLEVEL9K_DIR_CLASSES[@]}"; do - if [[ $_p9k__cwd == ${~a} ]]; then - [[ -n $b ]] && state+=_${${(U)b}//İ/I} - icon=$'\1'$c - break - fi - done - if (( w )); then - if (( _POWERLEVEL9K_DIR_SHOW_WRITABLE == 1 )); then - state=${0}_NOT_WRITABLE - elif (( w == 2 )); then - state+=_NON_EXISTENT - else - state+=_NOT_WRITABLE - fi - icon=LOCK_ICON - fi - - local state_u=${${(U)state}//İ/I} - - local style=%b - _p9k_color $state BACKGROUND blue - _p9k_background $_p9k__ret - style+=$_p9k__ret - _p9k_color $state FOREGROUND "$_p9k_color1" - _p9k_foreground $_p9k__ret - style+=$_p9k__ret - if (( expand )); then - _p9k_escape_style $style - style=$_p9k__ret - fi - - parts=("${(@)parts//\%/%%}") - if [[ $_POWERLEVEL9K_HOME_FOLDER_ABBREVIATION != '~' && $fake_first == 0 && $p == ('~'|'~/'*) ]]; then - (( expand )) && _p9k_escape $_POWERLEVEL9K_HOME_FOLDER_ABBREVIATION || _p9k__ret=$_POWERLEVEL9K_HOME_FOLDER_ABBREVIATION - parts[1]=$_p9k__ret - [[ $_p9k__ret == *%* ]] && parts[1]+=$style - elif [[ $_POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER == 1 && $fake_first == 0 && $#parts > 1 && -z $parts[1] && -n $parts[2] ]]; then - parts[1]=() - fi - - local last_style= - _p9k_param $state PATH_HIGHLIGHT_BOLD '' - [[ $_p9k__ret == true ]] && last_style+=%B - if (( $+parameters[_POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND] || - $+parameters[_POWERLEVEL9K_${state_u}_PATH_HIGHLIGHT_FOREGROUND] )); then - _p9k_color $state PATH_HIGHLIGHT_FOREGROUND '' - _p9k_foreground $_p9k__ret - last_style+=$_p9k__ret - fi - if [[ -n $last_style ]]; then - (( expand )) && _p9k_escape_style $last_style || _p9k__ret=$last_style - parts[-1]=$_p9k__ret${parts[-1]//$'\1'/$'\1'$_p9k__ret}$style - fi - - local anchor_style= - _p9k_param $state ANCHOR_BOLD '' - [[ $_p9k__ret == true ]] && anchor_style+=%B - if (( $+parameters[_POWERLEVEL9K_DIR_ANCHOR_FOREGROUND] || - $+parameters[_POWERLEVEL9K_${state_u}_ANCHOR_FOREGROUND] )); then - _p9k_color $state ANCHOR_FOREGROUND '' - _p9k_foreground $_p9k__ret - anchor_style+=$_p9k__ret - fi - if [[ -n $anchor_style ]]; then - (( expand )) && _p9k_escape_style $anchor_style || _p9k__ret=$anchor_style - if [[ -z $last_style ]]; then - parts=("${(@)parts/%(#b)(*)$'\2'/$_p9k__ret$match[1]$style}") - else - (( $#parts > 1 )) && parts[1,-2]=("${(@)parts[1,-2]/%(#b)(*)$'\2'/$_p9k__ret$match[1]$style}") - parts[-1]=${parts[-1]/$'\2'} - fi - else - parts=("${(@)parts/$'\2'}") - fi - - if (( $+parameters[_POWERLEVEL9K_DIR_SHORTENED_FOREGROUND] || - $+parameters[_POWERLEVEL9K_${state_u}_SHORTENED_FOREGROUND] )); then - _p9k_color $state SHORTENED_FOREGROUND '' - _p9k_foreground $_p9k__ret - (( expand )) && _p9k_escape_style $_p9k__ret - local shortened_fg=$_p9k__ret - (( expand )) && _p9k_escape $delim || _p9k__ret=$delim - [[ $_p9k__ret == *%* ]] && _p9k__ret+=$style$shortened_fg - parts=("${(@)parts/(#b)$'\3'(*)$'\1'(*)$'\3'/$shortened_fg$match[1]$_p9k__ret$match[2]$style}") - parts=("${(@)parts/(#b)(*)$'\1'(*)/$shortened_fg$match[1]$_p9k__ret$match[2]$style}") - else - (( expand )) && _p9k_escape $delim || _p9k__ret=$delim - [[ $_p9k__ret == *%* ]] && _p9k__ret+=$style - parts=("${(@)parts/$'\1'/$_p9k__ret}") - parts=("${(@)parts//$'\3'}") - fi - - if [[ $_p9k__cwd == / && $_POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER == 1 ]]; then - local sep='/' - else - local sep='' - if (( $+parameters[_POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND] || - $+parameters[_POWERLEVEL9K_${state_u}_PATH_SEPARATOR_FOREGROUND] )); then - _p9k_color $state PATH_SEPARATOR_FOREGROUND '' - _p9k_foreground $_p9k__ret - (( expand )) && _p9k_escape_style $_p9k__ret - sep=$_p9k__ret - fi - _p9k_param $state PATH_SEPARATOR / - _p9k__ret=${(g::)_p9k__ret} - (( expand )) && _p9k_escape $_p9k__ret - sep+=$_p9k__ret - [[ $sep == *%* ]] && sep+=$style - fi - - local content="${(pj.$sep.)parts}" - if (( _POWERLEVEL9K_DIR_HYPERLINK && _p9k_term_has_href )) && [[ $_p9k__cwd == /* ]]; then - _p9k_url_escape $_p9k__cwd - local header=$'%{\e]8;;file://'$_p9k__ret$'\a%}' - local footer=$'%{\e]8;;\a%}' - if (( expand )); then - _p9k_escape $header - header=$_p9k__ret - _p9k_escape $footer - footer=$_p9k__ret - fi - content=$header$content$footer - fi - - (( expand )) && _p9k_prompt_length "${(e):-"\${\${_p9k__d::=0}+}$content"}" || _p9k__ret= - _p9k_cache_ephemeral_set "$state" "$icon" "$expand" "$content" $_p9k__ret - fi - - if (( _p9k__cache_val[3] )); then - if (( $+_p9k__dir )); then - _p9k__cache_val[4]='${${_p9k__d::=-1024}+}'$_p9k__cache_val[4] - else - _p9k__dir=$_p9k__cache_val[4] - _p9k__dir_len=$_p9k__cache_val[5] - _p9k__cache_val[4]='%{d%}'$_p9k__cache_val[4]'%{d%}' - fi - fi - _p9k_prompt_segment "$_p9k__cache_val[1]" "blue" "$_p9k_color1" "$_p9k__cache_val[2]" "$_p9k__cache_val[3]" "" "$_p9k__cache_val[4]" -} - -instant_prompt_dir() { prompt_dir; } - -################################################################ -# Docker machine -prompt_docker_machine() { - _p9k_prompt_segment "$0" "magenta" "$_p9k_color1" 'SERVER_ICON' 0 '' "${DOCKER_MACHINE_NAME//\%/%%}" -} - -_p9k_prompt_docker_machine_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$DOCKER_MACHINE_NAME' -} - -################################################################ -# GO prompt -prompt_go_version() { - _p9k_cached_cmd 0 '' go version || return - [[ $_p9k__ret == (#b)*go([[:digit:].]##)* ]] || return - local v=$match[1] - if (( _POWERLEVEL9K_GO_VERSION_PROJECT_ONLY )); then - local p=$GOPATH - if [[ -z $p ]]; then - if [[ -d $HOME/go ]]; then - p=$HOME/go - else - p="$(go env GOPATH 2>/dev/null)" && [[ -n $p ]] || return - fi - fi - if [[ $_p9k__cwd/ != $p/* && $_p9k__cwd_a/ != $p/* ]]; then - _p9k_upglob go.mod && return - fi - fi - _p9k_prompt_segment "$0" "green" "grey93" "GO_ICON" 0 '' "${v//\%/%%}" -} - -_p9k_prompt_go_version_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[go]' -} - -################################################################ -# Command number (in local history) -prompt_history() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment "$0" "grey50" "$_p9k_color1" '' 0 '' '%h' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -prompt_package() { - unset P9K_PACKAGE_NAME P9K_PACKAGE_VERSION - _p9k_upglob package.json && return - - local file=$_p9k__parent_dirs[$?]/package.json - if ! _p9k_cache_stat_get $0 $file; then - () { - local data field - local -A found - # Redneck json parsing. Yields correct results for any well-formed json document. - # Produces random garbage for invalid json. - { data="$(<$file)" || return } 2>/dev/null - data=${${data//$'\r'}##[[:space:]]#} - [[ $data == '{'* ]] || return - data[1]= - local -i depth=1 - while true; do - data=${data##[[:space:]]#} - [[ -n $data ]] || return - case $data[1] in - '{'|'[') data[1]=; (( ++depth ));; - '}'|']') data[1]=; (( --depth > 0 )) || return;; - ':') data[1]=;; - ',') data[1]=; field=;; - [[:alnum:].]) data=${data##[[:alnum:].]#};; - '"') - local tail=${data##\"([^\"\\]|\\?)#} - [[ $tail == '"'* ]] || return - local s=${data:1:-$#tail} - data=${tail:1} - (( depth == 1 )) || continue - if [[ -z $field ]]; then - field=${s:-x} - elif [[ $field == (name|version) ]]; then - (( ! $+found[$field] )) || return - [[ -n $s ]] || return - [[ $s != *($'\n'|'\')* ]] || return - found[$field]=$s - (( $#found == 2 )) && break - fi - ;; - *) return 1;; - esac - done - _p9k_cache_stat_set 1 $found[name] $found[version] - return 0 - } || _p9k_cache_stat_set 0 - fi - (( _p9k__cache_val[1] )) || return - - P9K_PACKAGE_NAME=$_p9k__cache_val[2] - P9K_PACKAGE_VERSION=$_p9k__cache_val[3] - _p9k_prompt_segment "$0" "cyan" "$_p9k_color1" PACKAGE_ICON 0 '' ${P9K_PACKAGE_VERSION//\%/%%} -} - -################################################################ -# Detection for virtualization (systemd based systems only) -prompt_detect_virt() { - local virt="$(systemd-detect-virt 2>/dev/null)" - if [[ "$virt" == "none" ]]; then - local -a inode - if zstat -A inode +inode / 2>/dev/null && [[ $inode[1] != 2 ]]; then - virt="chroot" - fi - fi - if [[ -n "${virt}" ]]; then - _p9k_prompt_segment "$0" "$_p9k_color1" "yellow" '' 0 '' "${virt//\%/%%}" - fi -} - -_p9k_prompt_detect_virt_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[systemd-detect-virt]' -} - -################################################################ -# Segment to display the current IP address -prompt_ip() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment "$0" "cyan" "$_p9k_color1" 'NETWORK_ICON' 1 '$P9K_IP_IP' '$P9K_IP_IP' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -################################################################ -# Segment to display if VPN is active -prompt_vpn_ip() { - typeset -ga _p9k__vpn_ip_segments - _p9k__vpn_ip_segments+=($_p9k__prompt_side $_p9k__line_index $_p9k__segment_index) - local p='${(e)_p9k__vpn_ip_'$_p9k__prompt_side$_p9k__segment_index'}' - _p9k__prompt+=$p - typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$p -} - -_p9k_vpn_ip_render() { - local _p9k__segment_name=vpn_ip _p9k__prompt_side ip - local -i _p9k__has_upglob _p9k__segment_index - for _p9k__prompt_side _p9k__line_index _p9k__segment_index in $_p9k__vpn_ip_segments; do - local _p9k__prompt= - for ip in $_p9k__vpn_ip_ips; do - _p9k_prompt_segment prompt_vpn_ip "cyan" "$_p9k_color1" 'VPN_ICON' 0 '' $ip - done - typeset -g _p9k__vpn_ip_$_p9k__prompt_side$_p9k__segment_index=$_p9k__prompt - done -} - -################################################################ -# Segment to display laravel version -prompt_laravel_version() { - _p9k_upglob artisan && return - local dir=$_p9k__parent_dirs[$?] - local app=$dir/vendor/laravel/framework/src/Illuminate/Foundation/Application.php - [[ -r $app ]] || return - if ! _p9k_cache_stat_get $0 $dir/artisan $app; then - local v="$(php $dir/artisan --version 2> /dev/null)" - _p9k_cache_stat_set "${${(M)v:#Laravel Framework *}#Laravel Framework }" - fi - [[ -n $_p9k__cache_val[1] ]] || return - _p9k_prompt_segment "$0" "maroon" "white" 'LARAVEL_ICON' 0 '' "${_p9k__cache_val[1]//\%/%%}" -} - -_p9k_prompt_laravel_version_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[php]' -} - -################################################################ -# Segment to display load -prompt_load() { - if [[ $_p9k_os == (OSX|BSD) ]]; then - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0_CRITICAL red "$_p9k_color1" LOAD_ICON 1 '$_p9k__load_critical' '$_p9k__load_value' - _p9k_prompt_segment $0_WARNING yellow "$_p9k_color1" LOAD_ICON 1 '$_p9k__load_warning' '$_p9k__load_value' - _p9k_prompt_segment $0_NORMAL green "$_p9k_color1" LOAD_ICON 1 '$_p9k__load_normal' '$_p9k__load_value' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] - return - fi - - [[ -r /proc/loadavg ]] || return - _p9k_read_file /proc/loadavg || return - local load=${${(A)=_p9k__ret}[_POWERLEVEL9K_LOAD_WHICH]//,/.} - local -F pct='100. * load / _p9k_num_cpus' - if (( pct > _POWERLEVEL9K_LOAD_CRITICAL_PCT )); then - _p9k_prompt_segment $0_CRITICAL red "$_p9k_color1" LOAD_ICON 0 '' $load - elif (( pct > _POWERLEVEL9K_LOAD_WARNING_PCT )); then - _p9k_prompt_segment $0_WARNING yellow "$_p9k_color1" LOAD_ICON 0 '' $load - else - _p9k_prompt_segment $0_NORMAL green "$_p9k_color1" LOAD_ICON 0 '' $load - fi -} - -_p9k_prompt_load_init() { - if [[ $_p9k_os == (OSX|BSD) ]]; then - typeset -g _p9k__load_value= - typeset -g _p9k__load_normal= - typeset -g _p9k__load_warning= - typeset -g _p9k__load_critical= - _p9k__async_segments_compute+='_p9k_worker_invoke load _p9k_prompt_load_compute' - elif [[ ! -r /proc/loadavg ]]; then - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${:-}' - fi -} - -_p9k_prompt_load_compute() { - (( $+commands[sysctl] )) || return - _p9k_worker_async _p9k_prompt_load_async _p9k_prompt_load_sync -} - -_p9k_prompt_load_async() { - local load="$(sysctl -n vm.loadavg 2>/dev/null)" || return - load=${${(A)=load}[_POWERLEVEL9K_LOAD_WHICH+1]//,/.} - [[ $load == <->(|.<->) && $load != $_p9k__load_value ]] || return - _p9k__load_value=$load - _p9k__load_normal= - _p9k__load_warning= - _p9k__load_critical= - local -F pct='100. * _p9k__load_value / _p9k_num_cpus' - if (( pct > _POWERLEVEL9K_LOAD_CRITICAL_PCT )); then - _p9k__load_critical=1 - elif (( pct > _POWERLEVEL9K_LOAD_WARNING_PCT )); then - _p9k__load_warning=1 - else - _p9k__load_normal=1 - fi - _p9k_print_params \ - _p9k__load_value \ - _p9k__load_normal \ - _p9k__load_warning \ - _p9k__load_critical - echo -E - 'reset=1' -} - -_p9k_prompt_load_sync() { - eval $REPLY - _p9k_worker_reply $REPLY -} - -# Usage: _p9k_cached_cmd <0|1> <dep> <cmd> [args...] -# -# The first argument says whether to capture stderr (1) or ignore it (0). -# The second argument can be empty or a file. If it's a file, the -# output of the command is presumed to potentially depend on it. -function _p9k_cached_cmd() { - local cmd=$commands[$3] - [[ -n $cmd ]] || return - if ! _p9k_cache_stat_get $0" ${(q)*}" $2 $cmd; then - local out - if (( $1 )); then - out="$($cmd "${@:4}" 2>&1)" - else - out="$($cmd "${@:4}" 2>/dev/null)" - fi - _p9k_cache_stat_set $(( ! $? )) "$out" - fi - (( $_p9k__cache_val[1] )) || return - _p9k__ret=$_p9k__cache_val[2] -} - -################################################################ -# Segment to diplay Node version -prompt_node_version() { - _p9k_upglob package.json - local -i idx=$? - if (( idx )); then - _p9k_cached_cmd 0 $_p9k__parent_dirs[idx]/package.json node --version || return - else - (( _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY )) && return - _p9k_cached_cmd 0 '' node --version || return - fi - [[ $_p9k__ret == v?* ]] || return - _p9k_prompt_segment "$0" "green" "white" 'NODE_ICON' 0 '' "${_p9k__ret#v}" -} - -_p9k_prompt_node_version_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[node]' -} - -# Almost the same as `nvm_version default` but faster. The differences shouldn't affect -# the observable behavior of Powerlevel10k. -function _p9k_nvm_ls_default() { - local v=default - local -a seen=($v) - while [[ -r $NVM_DIR/alias/$v ]]; do - local target= - IFS='' read -r target <$NVM_DIR/alias/$v - target=${target%$'\r'} - [[ -z $target ]] && break - (( $seen[(I)$target] )) && return - seen+=$target - v=$target - done - - case $v in - default|N/A) - return 1 - ;; - system|v) - _p9k__ret=system - return 0 - ;; - iojs-[0-9]*) - v=iojs-v${v#iojs-} - ;; - [0-9]*) - v=v$v - ;; - esac - - if [[ $v == v*.*.* ]]; then - if [[ -x $NVM_DIR/versions/node/$v/bin/node || -x $NVM_DIR/$v/bin/node ]]; then - _p9k__ret=$v - return 0 - elif [[ -x $NVM_DIR/versions/io.js/$v/bin/node ]]; then - _p9k__ret=iojs-$v - return 0 - else - return 1 - fi - fi - - local -a dirs=() - case $v in - node|node-|stable) - dirs=($NVM_DIR/versions/node $NVM_DIR) - v='(v[1-9]*|v0.*[02468].*)' - ;; - unstable) - dirs=($NVM_DIR/versions/node $NVM_DIR) - v='v0.*[13579].*' - ;; - iojs*) - dirs=($NVM_DIR/versions/io.js) - v=v${${${v#iojs}#-}#v}'*' - ;; - *) - dirs=($NVM_DIR/versions/node $NVM_DIR $NVM_DIR/versions/io.js) - v=v${v#v}'*' - ;; - esac - - local -a matches=(${^dirs}/${~v}(/N)) - (( $#matches )) || return - - local max path - for path in ${(Oa)matches}; do - [[ ${path:t} == (#b)v(*).(*).(*) ]] || continue - v=${(j::)${(@l:6::0:)match}} - [[ $v > $max ]] || continue - max=$v - _p9k__ret=${path:t} - [[ ${path:h:t} != io.js ]] || _p9k__ret=iojs-$_p9k__ret - done - - [[ -n $max ]] -} - -# The same as `nvm_version current` but faster. -_p9k_nvm_ls_current() { - local node_path=${commands[node]:A} - [[ -n $node_path ]] || return - - local nvm_dir=${NVM_DIR:A} - if [[ -n $nvm_dir && $node_path == $nvm_dir/versions/io.js/* ]]; then - _p9k_cached_cmd 0 '' iojs --version || return - _p9k__ret=iojs-v${_p9k__ret#v} - elif [[ -n $nvm_dir && $node_path == $nvm_dir/* ]]; then - _p9k_cached_cmd 0 '' node --version || return - _p9k__ret=v${_p9k__ret#v} - else - _p9k__ret=system - fi -} - -################################################################ -# Segment to display Node version from NVM -# Only prints the segment if different than the default value -prompt_nvm() { - [[ -n $NVM_DIR ]] && _p9k_nvm_ls_current || return - local current=$_p9k__ret - ! _p9k_nvm_ls_default || [[ $_p9k__ret != $current ]] || return - _p9k_prompt_segment "$0" "magenta" "black" 'NODE_ICON' 0 '' "${${current#v}//\%/%%}" -} - -_p9k_prompt_nvm_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[nvm]:-${${+functions[nvm]}:#0}}' -} - -################################################################ -# Segment to display NodeEnv -prompt_nodeenv() { - local msg - if (( _POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION )) && _p9k_cached_cmd 0 '' node --version; then - msg="${_p9k__ret//\%/%%} " - fi - msg+="$_POWERLEVEL9K_NODEENV_LEFT_DELIMITER${${NODE_VIRTUAL_ENV:t}//\%/%%}$_POWERLEVEL9K_NODEENV_RIGHT_DELIMITER" - _p9k_prompt_segment "$0" "black" "green" 'NODE_ICON' 0 '' "$msg" -} - -_p9k_prompt_nodeenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$NODE_VIRTUAL_ENV' -} - -function _p9k_nodeenv_version_transform() { - local dir=${NODENV_ROOT:-$HOME/.nodenv}/versions - [[ -z $1 || $1 == system ]] && _p9k__ret=$1 && return - [[ -d $dir/$1 ]] && _p9k__ret=$1 && return - [[ -d $dir/${1/v} ]] && _p9k__ret=${1/v} && return - [[ -d $dir/${1#node-} ]] && _p9k__ret=${1#node-} && return - [[ -d $dir/${1#node-v} ]] && _p9k__ret=${1#node-v} && return - return 1 -} - -function _p9k_nodenv_global_version() { - _p9k_read_word ${NODENV_ROOT:-$HOME/.nodenv}/version || _p9k__ret=system -} - -################################################################ -# Segment to display nodenv information -# https://github.com/nodenv/nodenv -prompt_nodenv() { - if [[ -n $NODENV_VERSION ]]; then - (( ${_POWERLEVEL9K_NODENV_SOURCES[(I)shell]} )) || return - local v=$NODENV_VERSION - else - (( ${_POWERLEVEL9K_NODENV_SOURCES[(I)local|global]} )) || return - _p9k__ret= - if [[ $NODENV_DIR != (|.) ]]; then - [[ $NODENV_DIR == /* ]] && local dir=$NODENV_DIR || local dir="$_p9k__cwd_a/$NODENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if _p9k_read_word $dir/.node-version; then - (( ${_POWERLEVEL9K_NODENV_SOURCES[(I)local]} )) || return - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - if [[ -z $_p9k__ret ]]; then - _p9k_upglob .node-version - local -i idx=$? - if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.node-version; then - (( ${_POWERLEVEL9K_NODENV_SOURCES[(I)local]} )) || return - else - _p9k__ret= - fi - fi - if [[ -z $_p9k__ret ]]; then - (( _POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_NODENV_SOURCES[(I)global]} )) || return - _p9k_nodenv_global_version - fi - - _p9k_nodeenv_version_transform $_p9k__ret || return - local v=$_p9k__ret - fi - - if (( !_POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW )); then - _p9k_nodenv_global_version - _p9k_nodeenv_version_transform $_p9k__ret && [[ $v == $_p9k__ret ]] && return - fi - - if (( !_POWERLEVEL9K_NODENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return - fi - - _p9k_prompt_segment "$0" "black" "green" 'NODE_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_nodenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[nodenv]:-${${+functions[nodenv]}:#0}}' -} - -prompt_dotnet_version() { - if (( _POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY )); then - _p9k_upglob 'project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln' && return - fi - _p9k_cached_cmd 0 '' dotnet --version || return - _p9k_prompt_segment "$0" "magenta" "white" 'DOTNET_ICON' 0 '' "$_p9k__ret" -} - -_p9k_prompt_dotnet_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[dotnet]' -} - -################################################################ -# Segment to print a little OS icon -prompt_os_icon() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment "$0" "black" "white" '' 0 '' "$_p9k_os_icon" - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -instant_prompt_os_icon() { prompt_os_icon; } - -################################################################ -# Segment to display PHP version number -prompt_php_version() { - if (( _POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY )); then - _p9k_upglob 'composer.json|*.php' && return - fi - _p9k_cached_cmd 0 '' php --version || return - [[ $_p9k__ret == (#b)(*$'\n')#'PHP '([[:digit:].]##)* ]] || return - local v=$match[2] - _p9k_prompt_segment "$0" "fuchsia" "grey93" 'PHP_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_php_version_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[php]' -} - -################################################################ -# Segment to display free RAM and used Swap -prompt_ram() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 yellow "$_p9k_color1" RAM_ICON 1 '$_p9k__ram_free' '$_p9k__ram_free' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -function _p9k_prompt_ram_init() { - if [[ $_p9k_os == OSX && $+commands[vm_stat] == 0 || - $_p9k_os == BSD && ! -r /var/run/dmesg.boot || - $_p9k_os != (OSX|BSD) && ! -r /proc/meminfo ]]; then - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${:-}' - return - fi - typeset -g _p9k__ram_free= - _p9k__async_segments_compute+='_p9k_worker_invoke ram _p9k_prompt_ram_compute' -} - -_p9k_prompt_ram_compute() { - _p9k_worker_async _p9k_prompt_ram_async _p9k_prompt_ram_sync -} - -_p9k_prompt_ram_async() { - local -F free_bytes - - case $_p9k_os in - OSX) - (( $+commands[vm_stat] )) || return - local stat && stat="$(vm_stat 2>/dev/null)" || return - [[ $stat =~ 'Pages free:[[:space:]]+([0-9]+)' ]] || return - (( free_bytes += match[1] )) - [[ $stat =~ 'Pages inactive:[[:space:]]+([0-9]+)' ]] || return - (( free_bytes += match[1] )) - if (( ! $+_p9k__ram_pagesize )); then - local p - (( $+commands[pagesize] )) && p=$(pagesize 2>/dev/null) && [[ $p == <1-> ]] || p=4096 - typeset -gi _p9k__ram_pagesize=p - _p9k_print_params _p9k__ram_pagesize - fi - (( free_bytes *= _p9k__ram_pagesize )) - ;; - BSD) - local stat && stat="$(grep -F 'avail memory' /var/run/dmesg.boot 2>/dev/null)" || return - free_bytes=${${(A)=stat}[4]} - ;; - *) - [[ -r /proc/meminfo ]] || return - local stat && stat="$(</proc/meminfo)" || return - [[ $stat == (#b)*(MemAvailable:|MemFree:)[[:space:]]#(<->)* ]] || return - free_bytes=$(( $match[2] * 1024 )) - ;; - esac - - _p9k_human_readable_bytes $free_bytes - [[ $_p9k__ret != $_p9k__ram_free ]] || return - _p9k__ram_free=$_p9k__ret - _p9k_print_params _p9k__ram_free - echo -E - 'reset=1' -} - -_p9k_prompt_ram_sync() { - eval $REPLY - _p9k_worker_reply $REPLY -} - -function _p9k_rbenv_global_version() { - _p9k_read_word ${RBENV_ROOT:-$HOME/.rbenv}/version || _p9k__ret=system -} - -################################################################ -# Segment to display rbenv information -# https://github.com/rbenv/rbenv#choosing-the-ruby-version -prompt_rbenv() { - if [[ -n $RBENV_VERSION ]]; then - (( ${_POWERLEVEL9K_RBENV_SOURCES[(I)shell]} )) || return - local v=$RBENV_VERSION - else - (( ${_POWERLEVEL9K_RBENV_SOURCES[(I)local|global]} )) || return - _p9k__ret= - if [[ $RBENV_DIR != (|.) ]]; then - [[ $RBENV_DIR == /* ]] && local dir=$RBENV_DIR || local dir="$_p9k__cwd_a/$RBENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if _p9k_read_word $dir/.ruby-version; then - (( ${_POWERLEVEL9K_RBENV_SOURCES[(I)local]} )) || return - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - if [[ -z $_p9k__ret ]]; then - _p9k_upglob .ruby-version - local -i idx=$? - if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.ruby-version; then - (( ${_POWERLEVEL9K_RBENV_SOURCES[(I)local]} )) || return - else - _p9k__ret= - fi - fi - if [[ -z $_p9k__ret ]]; then - (( _POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_RBENV_SOURCES[(I)global]} )) || return - _p9k_rbenv_global_version - fi - local v=$_p9k__ret - fi - - if (( !_POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW )); then - _p9k_rbenv_global_version - [[ $v == $_p9k__ret ]] && return - fi - - if (( !_POWERLEVEL9K_RBENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return - fi - - _p9k_prompt_segment "$0" "red" "$_p9k_color1" 'RUBY_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_rbenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[rbenv]:-${${+functions[rbenv]}:#0}}' -} - -function _p9k_phpenv_global_version() { - _p9k_read_word ${PHPENV_ROOT:-$HOME/.phpenv}/version || _p9k__ret=system -} - -function _p9k_scalaenv_global_version() { - _p9k_read_word ${SCALAENV_ROOT:-$HOME/.scalaenv}/version || _p9k__ret=system -} - -# https://github.com/scalaenv/scalaenv -prompt_scalaenv() { - if [[ -n $SCALAENV_VERSION ]]; then - (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)shell]} )) || return - local v=$SCALAENV_VERSION - else - (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)local|global]} )) || return - _p9k__ret= - if [[ $SCALAENV_DIR != (|.) ]]; then - [[ $SCALAENV_DIR == /* ]] && local dir=$SCALAENV_DIR || local dir="$_p9k__cwd_a/$SCALAENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if _p9k_read_word $dir/.scala-version; then - (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)local]} )) || return - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - if [[ -z $_p9k__ret ]]; then - _p9k_upglob .scala-version - local -i idx=$? - if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.scala-version; then - (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)local]} )) || return - else - _p9k__ret= - fi - fi - if [[ -z $_p9k__ret ]]; then - (( _POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)global]} )) || return - _p9k_scalaenv_global_version - fi - local v=$_p9k__ret - fi - - if (( !_POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW )); then - _p9k_scalaenv_global_version - [[ $v == $_p9k__ret ]] && return - fi - - if (( !_POWERLEVEL9K_SCALAENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return - fi - - _p9k_prompt_segment "$0" "red" "$_p9k_color1" 'SCALA_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_scalaenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[scalaenv]:-${${+functions[scalaenv]}:#0}}' -} - -function _p9k_phpenv_global_version() { - _p9k_read_word ${PHPENV_ROOT:-$HOME/.phpenv}/version || _p9k__ret=system -} - -prompt_phpenv() { - if [[ -n $PHPENV_VERSION ]]; then - (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)shell]} )) || return - local v=$PHPENV_VERSION - else - (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local|global]} )) || return - _p9k__ret= - if [[ $PHPENV_DIR != (|.) ]]; then - [[ $PHPENV_DIR == /* ]] && local dir=$PHPENV_DIR || local dir="$_p9k__cwd_a/$PHPENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if _p9k_read_word $dir/.php-version; then - (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local]} )) || return - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - if [[ -z $_p9k__ret ]]; then - _p9k_upglob .php-version - local -i idx=$? - if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.php-version; then - (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local]} )) || return - else - _p9k__ret= - fi - fi - if [[ -z $_p9k__ret ]]; then - (( _POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)global]} )) || return - _p9k_phpenv_global_version - fi - local v=$_p9k__ret - fi - - if (( !_POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW )); then - _p9k_phpenv_global_version - [[ $v == $_p9k__ret ]] && return - fi - - if (( !_POWERLEVEL9K_PHPENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return - fi - - _p9k_prompt_segment "$0" "magenta" "$_p9k_color1" 'PHP_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_phpenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[phpenv]:-${${+functions[phpenv]}:#0}}' -} - -function _p9k_luaenv_global_version() { - _p9k_read_word ${LUAENV_ROOT:-$HOME/.luaenv}/version || _p9k__ret=system -} - -################################################################ -# Segment to display luaenv information -# https://github.com/cehoffman/luaenv -prompt_luaenv() { - if [[ -n $LUAENV_VERSION ]]; then - (( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)shell]} )) || return - local v=$LUAENV_VERSION - else - (( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)local|global]} )) || return - _p9k__ret= - if [[ $LUAENV_DIR != (|.) ]]; then - [[ $LUAENV_DIR == /* ]] && local dir=$LUAENV_DIR || local dir="$_p9k__cwd_a/$LUAENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if _p9k_read_word $dir/.lua-version; then - (( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)local]} )) || return - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - if [[ -z $_p9k__ret ]]; then - _p9k_upglob .lua-version - local -i idx=$? - if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.lua-version; then - (( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)local]} )) || return - else - _p9k__ret= - fi - fi - if [[ -z $_p9k__ret ]]; then - (( _POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)global]} )) || return - _p9k_luaenv_global_version - fi - local v=$_p9k__ret - fi - - if (( !_POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW )); then - _p9k_luaenv_global_version - [[ $v == $_p9k__ret ]] && return - fi - - if (( !_POWERLEVEL9K_LUAENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return - fi - - _p9k_prompt_segment "$0" blue "$_p9k_color1" 'LUA_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_luaenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[luaenv]:-${${+functions[luaenv]}:#0}}' -} - -function _p9k_jenv_global_version() { - _p9k_read_word ${JENV_ROOT:-$HOME/.jenv}/version || _p9k__ret=system -} - -################################################################ -# Segment to display jenv information -# https://github.com/jenv/jenv -prompt_jenv() { - if [[ -n $JENV_VERSION ]]; then - (( ${_POWERLEVEL9K_JENV_SOURCES[(I)shell]} )) || return - local v=$JENV_VERSION - else - (( ${_POWERLEVEL9K_JENV_SOURCES[(I)local|global]} )) || return - _p9k__ret= - if [[ $JENV_DIR != (|.) ]]; then - [[ $JENV_DIR == /* ]] && local dir=$JENV_DIR || local dir="$_p9k__cwd_a/$JENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if _p9k_read_word $dir/.java-version; then - (( ${_POWERLEVEL9K_JENV_SOURCES[(I)local]} )) || return - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - if [[ -z $_p9k__ret ]]; then - _p9k_upglob .java-version - local -i idx=$? - if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.java-version; then - (( ${_POWERLEVEL9K_JENV_SOURCES[(I)local]} )) || return - else - _p9k__ret= - fi - fi - if [[ -z $_p9k__ret ]]; then - (( _POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_JENV_SOURCES[(I)global]} )) || return - _p9k_jenv_global_version - fi - local v=$_p9k__ret - fi - - if (( !_POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW )); then - _p9k_jenv_global_version - [[ $v == $_p9k__ret ]] && return - fi - - if (( !_POWERLEVEL9K_JENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return - fi - - _p9k_prompt_segment "$0" white red 'JAVA_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_jenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[jenv]:-${${+functions[jenv]}:#0}}' -} - -function _p9k_plenv_global_version() { - _p9k_read_word ${PLENV_ROOT:-$HOME/.plenv}/version || _p9k__ret=system -} - -################################################################ -# Segment to display plenv information -# https://github.com/plenv/plenv#choosing-the-perl-version -prompt_plenv() { - if [[ -n $PLENV_VERSION ]]; then - (( ${_POWERLEVEL9K_PLENV_SOURCES[(I)shell]} )) || return - local v=$PLENV_VERSION - else - (( ${_POWERLEVEL9K_PLENV_SOURCES[(I)local|global]} )) || return - _p9k__ret= - if [[ $PLENV_DIR != (|.) ]]; then - [[ $PLENV_DIR == /* ]] && local dir=$PLENV_DIR || local dir="$_p9k__cwd_a/$PLENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if _p9k_read_word $dir/.perl-version; then - (( ${_POWERLEVEL9K_PLENV_SOURCES[(I)local]} )) || return - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - if [[ -z $_p9k__ret ]]; then - _p9k_upglob .perl-version - local -i idx=$? - if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.perl-version; then - (( ${_POWERLEVEL9K_PLENV_SOURCES[(I)local]} )) || return - else - _p9k__ret= - fi - fi - if [[ -z $_p9k__ret ]]; then - (( _POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_PLENV_SOURCES[(I)global]} )) || return - _p9k_plenv_global_version - fi - local v=$_p9k__ret - fi - - if (( !_POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW )); then - _p9k_plenv_global_version - [[ $v == $_p9k__ret ]] && return - fi - - if (( !_POWERLEVEL9K_PLENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return - fi - - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PERL_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_plenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[plenv]:-${${+functions[plenv]}:#0}}' -} - -################################################################ -# Segment to display perlbrew information -# https://github.com/gugod/App-perlbrew - -prompt_perlbrew() { - if (( _POWERLEVEL9K_PERLBREW_PROJECT_ONLY )); then - _p9k_upglob 'cpanfile|.perltidyrc|(|MY)META.(yml|json)|(Makefile|Build).PL|*.(pl|pm|t|pod)' && return - fi - - local v=$PERLBREW_PERL - (( _POWERLEVEL9K_PERLBREW_SHOW_PREFIX )) || v=${v#*-} - [[ -n $v ]] || return - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PERL_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_perlbrew_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$PERLBREW_PERL' -} - -################################################################ -# Segment to display chruby information -# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH -prompt_chruby() { - local v=${(M)RUBY_ENGINE:#$~_POWERLEVEL9K_CHRUBY_SHOW_ENGINE_PATTERN} - [[ $_POWERLEVEL9K_CHRUBY_SHOW_VERSION == 1 && -n $RUBY_VERSION ]] && v+=${v:+ }$RUBY_VERSION - _p9k_prompt_segment "$0" "red" "$_p9k_color1" 'RUBY_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_chruby_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$RUBY_ENGINE' -} - -################################################################ -# Segment to print an icon if user is root. -prompt_root_indicator() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment "$0" "$_p9k_color1" "yellow" 'ROOT_ICON' 0 '${${(%):-%#}:#\%}' '' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -instant_prompt_root_indicator() { prompt_root_indicator; } - -################################################################ -# Segment to display Rust version number -prompt_rust_version() { - unset P9K_RUST_VERSION - if (( _POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY )); then - _p9k_upglob Cargo.toml && return - fi - local rustc=$commands[rustc] toolchain deps=() - if (( $+commands[ldd] )); then - if ! _p9k_cache_stat_get $0_so $rustc; then - local line so - for line in "${(@f)$(ldd $rustc 2>/dev/null)}"; do - [[ $line == (#b)[[:space:]]#librustc_driver[^[:space:]]#.so' => '(*)' (0x'[[:xdigit:]]#')' ]] || continue - so=$match[1] - break - done - _p9k_cache_stat_set "$so" - fi - deps+=$_p9k__cache_val[1] - fi - if (( $+commands[rustup] )); then - local rustup=$commands[rustup] - local rustup_home=${RUSTUP_HOME:-~/.rustup} - local cfg=($rustup_home/settings.toml(.N)) - deps+=($cfg $rustup_home/update-hashes/*(.N)) - if [[ -z ${toolchain::=$RUSTUP_TOOLCHAIN} ]]; then - if ! _p9k_cache_stat_get $0_overrides $rustup $cfg; then - local lines=(${(f)"$(rustup override list 2>/dev/null)"}) - if [[ $lines[1] == "no overrides" ]]; then - _p9k_cache_stat_set - else - local MATCH - local keys=(${(@)${lines%%[[:space:]]#[^[:space:]]#}/(#m)*/${(b)MATCH}/}) - local vals=(${(@)lines/(#m)*/$MATCH[(I)/] ${MATCH##*[[:space:]]}}) - _p9k_cache_stat_set ${keys:^vals} - fi - fi - local -A overrides=($_p9k__cache_val) - _p9k_upglob rust-toolchain - local dir=$_p9k__parent_dirs[$?] - local -i n m=${dir[(I)/]} - local pair - for pair in ${overrides[(K)$_p9k__cwd/]}; do - n=${pair%% *} - (( n <= m )) && continue - m=n - toolchain=${pair#* } - done - if [[ -z $toolchain && -n $dir ]]; then - _p9k_read_word $dir/rust-toolchain - toolchain=$_p9k__ret - fi - fi - fi - if ! _p9k_cache_stat_get $0_v$toolchain $rustc $deps; then - _p9k_cache_stat_set "$($rustc --version 2>/dev/null)" - fi - local v=${${_p9k__cache_val[1]#rustc }%% *} - [[ -n $v ]] || return - typeset -g P9K_RUST_VERSION=$_p9k__cache_val[1] - _p9k_prompt_segment "$0" "darkorange" "$_p9k_color1" 'RUST_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_rust_version_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[rustc]' -} - -# RSpec test ratio -prompt_rspec_stats() { - if [[ -d app && -d spec ]]; then - local -a code=(app/**/*.rb(N)) - (( $#code )) || return - local tests=(spec/**/*.rb(N)) - _p9k_build_test_stats "$0" "$#code" "$#tests" "RSpec" 'TEST_ICON' - fi -} - -################################################################ -# Segment to display Ruby Version Manager information -prompt_rvm() { - [[ $GEM_HOME == *rvm* && $ruby_string != $rvm_path/bin/ruby ]] || return - local v=${GEM_HOME:t} - (( _POWERLEVEL9K_RVM_SHOW_GEMSET )) || v=${v%%${rvm_gemset_separator:-@}*} - (( _POWERLEVEL9K_RVM_SHOW_PREFIX )) || v=${v#*-} - [[ -n $v ]] || return - _p9k_prompt_segment "$0" "240" "$_p9k_color1" 'RUBY_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_rvm_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[rvm-prompt]:-${${+functions[rvm-prompt]}:#0}}' -} - -################################################################ -# Segment to display SSH icon when connected -prompt_ssh() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment "$0" "$_p9k_color1" "yellow" 'SSH_ICON' 0 '' '' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_ssh_init() { - if (( ! P9K_SSH )); then - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${:-}' - fi -} - -instant_prompt_ssh() { - if (( ! P9K_SSH )); then - return - fi - prompt_ssh -} - -################################################################ -# Status: When an error occur, return the error code, or a cross icon if option is set -# Display an ok icon when no error occur, or hide the segment if option is set to false -prompt_status() { - if ! _p9k_cache_get $0 $_p9k__status $_p9k__pipestatus; then - (( _p9k__status )) && local state=ERROR || local state=OK - if (( _POWERLEVEL9K_STATUS_EXTENDED_STATES )); then - if (( _p9k__status )); then - if (( $#_p9k__pipestatus > 1 )); then - state+=_PIPE - elif (( _p9k__status > 128 )); then - state+=_SIGNAL - fi - elif [[ "$_p9k__pipestatus" == *[1-9]* ]]; then - state+=_PIPE - fi - fi - _p9k__cache_val=(:) - if (( _POWERLEVEL9K_STATUS_$state )); then - if (( _POWERLEVEL9K_STATUS_SHOW_PIPESTATUS )); then - local text=${(j:|:)${(@)_p9k__pipestatus:/(#b)(*)/$_p9k_exitcode2str[$match[1]+1]}} - else - local text=$_p9k_exitcode2str[_p9k__status+1] - fi - if (( _p9k__status )); then - if (( !_POWERLEVEL9K_STATUS_CROSS && _POWERLEVEL9K_STATUS_VERBOSE )); then - _p9k__cache_val=($0_$state red yellow1 CARRIAGE_RETURN_ICON 0 '' "$text") - else - _p9k__cache_val=($0_$state $_p9k_color1 red FAIL_ICON 0 '' '') - fi - elif (( _POWERLEVEL9K_STATUS_VERBOSE || _POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE )); then - [[ $state == OK ]] && text='' - _p9k__cache_val=($0_$state "$_p9k_color1" green OK_ICON 0 '' "$text") - fi - fi - if (( $#_p9k__pipestatus < 3 )); then - _p9k_cache_set "${(@)_p9k__cache_val}" - fi - fi - _p9k_prompt_segment "${(@)_p9k__cache_val}" -} - -instant_prompt_status() { - if (( _POWERLEVEL9K_STATUS_OK )); then - _p9k_prompt_segment prompt_status_OK "$_p9k_color1" green OK_ICON 0 '' '' - fi -} - -prompt_prompt_char() { - local saved=$_p9k__prompt_char_saved[$_p9k__prompt_side$_p9k__segment_index$((!_p9k__status))] - if [[ -n $saved ]]; then - _p9k__prompt+=$saved - return - fi - local -i len=$#_p9k__prompt _p9k__has_upglob - if (( __p9k_sh_glob )); then - if (( _p9k__status )); then - if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${${${${:-$_p9k__keymap.$_p9k__zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' '❯' - _p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${${${${${:-$_p9k__keymap.$_p9k__zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' '▶' - else - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${${_p9k__keymap:#vicmd}:#vivis}:#vivli}}' '❯' - fi - _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k__keymap$_p9k__region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${$((! ${#${${${${:-$_p9k__keymap$_p9k__region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' 'Ⅴ' - else - if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${${${${:-$_p9k__keymap.$_p9k__zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' '❯' - _p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${${${${${:-$_p9k__keymap.$_p9k__zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' '▶' - else - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${${_p9k__keymap:#vicmd}:#vivis}:#vivli}}' '❯' - fi - _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k__keymap$_p9k__region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${$((! ${#${${${${:-$_p9k__keymap$_p9k__region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' 'Ⅴ' - fi - else - if (( _p9k__status )); then - if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${:-$_p9k__keymap.$_p9k__zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' - _p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${:-$_p9k__keymap.$_p9k__zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' - else - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${_p9k__keymap:#(vicmd|vivis|vivli)}' '❯' - fi - _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k__keymap$_p9k__region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k__keymap$_p9k__region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' - else - if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${:-$_p9k__keymap.$_p9k__zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' - _p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${:-$_p9k__keymap.$_p9k__zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' - else - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${_p9k__keymap:#(vicmd|vivis|vivli)}' '❯' - fi - _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k__keymap$_p9k__region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k__keymap$_p9k__region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' - fi - fi - (( _p9k__has_upglob )) || _p9k__prompt_char_saved[$_p9k__prompt_side$_p9k__segment_index$((!_p9k__status))]=$_p9k__prompt[len+1,-1] -} - -instant_prompt_prompt_char() { - _p9k_prompt_segment prompt_prompt_char_OK_VIINS "$_p9k_color1" 76 '' 0 '' '❯' -} - -################################################################ -# Segment to display Swap information -prompt_swap() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 yellow "$_p9k_color1" SWAP_ICON 1 '$_p9k__swap_used' '$_p9k__swap_used' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -function _p9k_prompt_swap_init() { - if [[ $_p9k_os == OSX && $+commands[sysctl] == 0 || $_p9k_os != OSX && ! -r /proc/meminfo ]]; then - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${:-}' - return - fi - typeset -g _p9k__swap_used= - _p9k__async_segments_compute+='_p9k_worker_invoke swap _p9k_prompt_swap_compute' -} - -_p9k_prompt_swap_compute() { - _p9k_worker_async _p9k_prompt_swap_async _p9k_prompt_swap_sync -} - -_p9k_prompt_swap_async() { - local -F used_bytes - - if [[ "$_p9k_os" == "OSX" ]]; then - (( $+commands[sysctl] )) || return - [[ "$(sysctl vm.swapusage 2>/dev/null)" =~ "used = ([0-9,.]+)([A-Z]+)" ]] || return - used_bytes=${match[1]//,/.} - case ${match[2]} in - 'K') (( used_bytes *= 1024 ));; - 'M') (( used_bytes *= 1048576 ));; - 'G') (( used_bytes *= 1073741824 ));; - 'T') (( used_bytes *= 1099511627776 ));; - *) return 0;; - esac - else - local meminfo && meminfo="$(grep -F 'Swap' /proc/meminfo 2>/dev/null)" || return - [[ $meminfo =~ 'SwapTotal:[[:space:]]+([0-9]+)' ]] || return - (( used_bytes+=match[1] )) - [[ $meminfo =~ 'SwapFree:[[:space:]]+([0-9]+)' ]] || return - (( used_bytes-=match[1] )) - (( used_bytes *= 1024 )) - fi - - (( used_bytes >= 0 || (used_bytes = 0) )) - - _p9k_human_readable_bytes $used_bytes - [[ $_p9k__ret != $_p9k__swap_used ]] || return - _p9k__swap_used=$_p9k__ret - _p9k_print_params _p9k__swap_used - echo -E - 'reset=1' -} - -_p9k_prompt_swap_sync() { - eval $REPLY - _p9k_worker_reply $REPLY -} - -################################################################ -# Symfony2-PHPUnit test ratio -prompt_symfony2_tests() { - if [[ -d src && -d app && -f app/AppKernel.php ]]; then - local -a all=(src/**/*.php(N)) - local -a code=(${(@)all##*Tests*}) - (( $#code )) || return - _p9k_build_test_stats "$0" "$#code" "$(($#all - $#code))" "SF2" 'TEST_ICON' - fi -} - -################################################################ -# Segment to display Symfony2-Version -prompt_symfony2_version() { - if [[ -r app/bootstrap.php.cache ]]; then - local v="${$(grep -F " VERSION " app/bootstrap.php.cache 2>/dev/null)//[![:digit:].]}" - _p9k_prompt_segment "$0" "grey35" "$_p9k_color1" 'SYMFONY_ICON' 0 '' "${v//\%/%%}" - fi -} - -################################################################ -# Show a ratio of tests vs code -_p9k_build_test_stats() { - local code_amount="$2" - local tests_amount="$3" - local headline="$4" - - (( code_amount > 0 )) || return - local -F 2 ratio=$(( 100. * tests_amount / code_amount )) - - (( ratio >= 75 )) && _p9k_prompt_segment "${1}_GOOD" "cyan" "$_p9k_color1" "$5" 0 '' "$headline: $ratio%%" - (( ratio >= 50 && ratio < 75 )) && _p9k_prompt_segment "$1_AVG" "yellow" "$_p9k_color1" "$5" 0 '' "$headline: $ratio%%" - (( ratio < 50 )) && _p9k_prompt_segment "$1_BAD" "red" "$_p9k_color1" "$5" 0 '' "$headline: $ratio%%" -} - -################################################################ -# System time -prompt_time() { - if (( _POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME )); then - _p9k_prompt_segment "$0" "$_p9k_color2" "$_p9k_color1" "TIME_ICON" 0 '' "$_POWERLEVEL9K_TIME_FORMAT" - else - if [[ $_p9k__refresh_reason == precmd ]]; then - if [[ $+__p9k_instant_prompt_active == 1 && $__p9k_instant_prompt_time_format == $_POWERLEVEL9K_TIME_FORMAT ]]; then - _p9k__time=${__p9k_instant_prompt_time//\%/%%} - else - _p9k__time=${${(%)_POWERLEVEL9K_TIME_FORMAT}//\%/%%} - fi - fi - if (( _POWERLEVEL9K_TIME_UPDATE_ON_COMMAND )); then - _p9k_escape $_p9k__time - local t=$_p9k__ret - _p9k_escape $_POWERLEVEL9K_TIME_FORMAT - _p9k_prompt_segment "$0" "$_p9k_color2" "$_p9k_color1" "TIME_ICON" 1 '' \ - "\${_p9k__line_finished-$t}\${_p9k__line_finished+$_p9k__ret}" - else - _p9k_prompt_segment "$0" "$_p9k_color2" "$_p9k_color1" "TIME_ICON" 0 '' $_p9k__time - fi - fi -} - -instant_prompt_time() { - _p9k_escape $_POWERLEVEL9K_TIME_FORMAT - local stash='${${__p9k_instant_prompt_time::=${(%)${__p9k_instant_prompt_time_format::='$_p9k__ret'}}}+}' - _p9k_escape $_POWERLEVEL9K_TIME_FORMAT - _p9k_prompt_segment prompt_time "$_p9k_color2" "$_p9k_color1" "TIME_ICON" 1 '' $stash$_p9k__ret -} - -_p9k_prompt_time_init() { - (( _POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME )) || return - _p9k__async_segments_compute+='_p9k_worker_invoke time _p9k_prompt_time_compute' -} - -_p9k_prompt_time_compute() { - _p9k_worker_async _p9k_prompt_time_async _p9k_prompt_time_sync -} - -_p9k_prompt_time_async() { - sleep 1 || true -} - -_p9k_prompt_time_sync() { - _p9k_worker_reply '_p9k_worker_invoke _p9k_prompt_time_compute _p9k_prompt_time_compute; reset=1' -} - -################################################################ -# System date -prompt_date() { - if [[ $_p9k__refresh_reason == precmd ]]; then - if [[ $+__p9k_instant_prompt_active == 1 && $__p9k_instant_prompt_date_format == $_POWERLEVEL9K_DATE_FORMAT ]]; then - _p9k__date=${__p9k_instant_prompt_date//\%/%%} - else - _p9k__date=${${(%)_POWERLEVEL9K_DATE_FORMAT}//\%/%%} - fi - fi - _p9k_prompt_segment "$0" "$_p9k_color2" "$_p9k_color1" "DATE_ICON" 0 '' "$_p9k__date" -} - -instant_prompt_date() { - _p9k_escape $_POWERLEVEL9K_DATE_FORMAT - local stash='${${__p9k_instant_prompt_date::=${(%)${__p9k_instant_prompt_date_format::='$_p9k__ret'}}}+}' - _p9k_escape $_POWERLEVEL9K_DATE_FORMAT - _p9k_prompt_segment prompt_date "$_p9k_color2" "$_p9k_color1" "DATE_ICON" 1 '' $stash$_p9k__ret -} - -################################################################ -# todo.sh: shows the number of tasks in your todo.sh file -prompt_todo() { - unset P9K_TODO_TOTAL_TASK_COUNT P9K_TODO_FILTERED_TASK_COUNT - [[ -r $_p9k__todo_file && -x $_p9k__todo_command ]] || return - if ! _p9k_cache_stat_get $0 $_p9k__todo_file; then - local count="$($_p9k__todo_command -p ls | command tail -1)" - if [[ $count == (#b)'TODO: '([[:digit:]]##)' of '([[:digit:]]##)' '* ]]; then - _p9k_cache_stat_set 1 $match[1] $match[2] - else - _p9k_cache_stat_set 0 - fi - fi - (( $_p9k__cache_val[1] )) || return - typeset -gi P9K_TODO_FILTERED_TASK_COUNT=$_p9k__cache_val[2] - typeset -gi P9K_TODO_TOTAL_TASK_COUNT=$_p9k__cache_val[3] - if (( (P9K_TODO_TOTAL_TASK_COUNT || !_POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL) && - (P9K_TODO_FILTERED_TASK_COUNT || !_POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED) )); then - if (( P9K_TODO_TOTAL_TASK_COUNT == P9K_TODO_FILTERED_TASK_COUNT )); then - local text=$P9K_TODO_TOTAL_TASK_COUNT - else - local text="$P9K_TODO_FILTERED_TASK_COUNT/$P9K_TODO_TOTAL_TASK_COUNT" - fi - _p9k_prompt_segment "$0" "grey50" "$_p9k_color1" 'TODO_ICON' 0 '' "$text" - fi -} - -_p9k_prompt_todo_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$_p9k__todo_file' -} - -################################################################ -# VCS segment: shows the state of your repository, if you are in a folder under -# version control - -# The vcs segment can have 4 different states - defaults to 'CLEAN'. -typeset -gA __p9k_vcs_states=( - 'CLEAN' '2' - 'MODIFIED' '3' - 'UNTRACKED' '2' - 'LOADING' '8' - 'CONFLICTED' '3' -) - -function +vi-git-untracked() { - [[ -z "${vcs_comm[gitdir]}" || "${vcs_comm[gitdir]}" == "." ]] && return - - # get the root for the current repo or submodule - local repoTopLevel="$(git rev-parse --show-toplevel 2> /dev/null)" - # dump out if we're outside a git repository (which includes being in the .git folder) - [[ $? != 0 || -z $repoTopLevel ]] && return - - local untrackedFiles="$(git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null)" - - if [[ -z $untrackedFiles && $_POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY == 1 ]]; then - untrackedFiles+="$(git submodule foreach --quiet --recursive 'git ls-files --others --exclude-standard' 2> /dev/null)" - fi - - [[ -z $untrackedFiles ]] && return - - hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" - VCS_WORKDIR_HALF_DIRTY=true -} - -function +vi-git-aheadbehind() { - local ahead behind - local -a gitstatus - - # for git prior to 1.7 - # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l) - ahead="$(git rev-list --count "${hook_com[branch]}"@{upstream}..HEAD 2>/dev/null)" - (( ahead )) && gitstatus+=( " $(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" ) - - # for git prior to 1.7 - # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l) - behind="$(git rev-list --count HEAD.."${hook_com[branch]}"@{upstream} 2>/dev/null)" - (( behind )) && gitstatus+=( " $(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" ) - - hook_com[misc]+=${(j::)gitstatus} -} - -function +vi-git-remotebranch() { - local remote - local branch_name="${hook_com[branch]}" - - # Are we on a remote-tracking branch? - remote="$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)" - remote=${remote/refs\/(remotes|heads)\/} - - if (( $+_POWERLEVEL9K_VCS_SHORTEN_LENGTH && $+_POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH )); then - if (( ${#hook_com[branch]} > _POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH && ${#hook_com[branch]} > _POWERLEVEL9K_VCS_SHORTEN_LENGTH )); then - case $_POWERLEVEL9K_VCS_SHORTEN_STRATEGY in - truncate_middle) - hook_com[branch]="${branch_name:0:$_POWERLEVEL9K_VCS_SHORTEN_LENGTH}${_POWERLEVEL9K_VCS_SHORTEN_DELIMITER}${branch_name: -$_POWERLEVEL9K_VCS_SHORTEN_LENGTH}" - ;; - truncate_from_right) - hook_com[branch]="${branch_name:0:$_POWERLEVEL9K_VCS_SHORTEN_LENGTH}${_POWERLEVEL9K_VCS_SHORTEN_DELIMITER}" - ;; - esac - fi - fi - - if (( _POWERLEVEL9K_HIDE_BRANCH_ICON )); then - hook_com[branch]="${hook_com[branch]}" - else - hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}" - fi - # Always show the remote - #if [[ -n ${remote} ]] ; then - # Only show the remote if it differs from the local - if [[ -n ${remote} ]] && [[ "${remote#*/}" != "${branch_name}" ]] ; then - hook_com[branch]+="$(print_icon 'VCS_REMOTE_BRANCH_ICON')${remote// /}" - fi -} - -function +vi-git-tagname() { - if (( !_POWERLEVEL9K_VCS_HIDE_TAGS )); then - # If we are on a tag, append the tagname to the current branch string. - local tag - tag="$(git describe --tags --exact-match HEAD 2>/dev/null)" - - if [[ -n "${tag}" ]] ; then - # There is a tag that points to our current commit. Need to determine if we - # are also on a branch, or are in a DETACHED_HEAD state. - if [[ -z "$(git symbolic-ref HEAD 2>/dev/null)" ]]; then - # DETACHED_HEAD state. We want to append the tag name to the commit hash - # and print it. Unfortunately, `vcs_info` blows away the hash when a tag - # exists, so we have to manually retrieve it and clobber the branch - # string. - local revision - revision="$(git rev-list -n 1 --abbrev-commit --abbrev=${_POWERLEVEL9K_CHANGESET_HASH_LENGTH} HEAD)" - if (( _POWERLEVEL9K_HIDE_BRANCH_ICON )); then - hook_com[branch]="${revision} $(print_icon 'VCS_TAG_ICON')${tag}" - else - hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}" - fi - else - # We are on both a tag and a branch; print both by appending the tag name. - hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}" - fi - fi - fi -} - -# Show count of stashed changes -# Port from https://github.com/whiteinge/dotfiles/blob/5dfd08d30f7f2749cfc60bc55564c6ea239624d9/.zsh_shouse_prompt#L268 -function +vi-git-stash() { - if [[ -s "${vcs_comm[gitdir]}/logs/refs/stash" ]] ; then - local -a stashes=( "${(@f)"$(<${vcs_comm[gitdir]}/logs/refs/stash)"}" ) - hook_com[misc]+=" $(print_icon 'VCS_STASH_ICON')${#stashes}" - fi -} - -function +vi-hg-bookmarks() { - if [[ -n "${hgbmarks[@]}" ]]; then - hook_com[hg-bookmark-string]=" $(print_icon 'VCS_BOOKMARK_ICON')${hgbmarks[@]}" - - # To signal that we want to use the sting we just generated, set the special - # variable `ret' to something other than the default zero: - ret=1 - return 0 - fi -} - -function +vi-vcs-detect-changes() { - if [[ "${hook_com[vcs]}" == "git" ]]; then - - local remote="$(git ls-remote --get-url 2> /dev/null)" - if [[ "$remote" =~ "github" ]] then - vcs_visual_identifier='VCS_GIT_GITHUB_ICON' - elif [[ "$remote" =~ "bitbucket" ]] then - vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON' - elif [[ "$remote" =~ "stash" ]] then - vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON' - elif [[ "$remote" =~ "gitlab" ]] then - vcs_visual_identifier='VCS_GIT_GITLAB_ICON' - else - vcs_visual_identifier='VCS_GIT_ICON' - fi - - elif [[ "${hook_com[vcs]}" == "hg" ]]; then - vcs_visual_identifier='VCS_HG_ICON' - elif [[ "${hook_com[vcs]}" == "svn" ]]; then - vcs_visual_identifier='VCS_SVN_ICON' - fi - - if [[ -n "${hook_com[staged]}" ]] || [[ -n "${hook_com[unstaged]}" ]]; then - VCS_WORKDIR_DIRTY=true - else - VCS_WORKDIR_DIRTY=false - fi -} - -function +vi-svn-detect-changes() { - local svn_status="$(svn status)" - if [[ -n "$(echo "$svn_status" | \grep \^\?)" ]]; then - hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" - VCS_WORKDIR_HALF_DIRTY=true - fi - if [[ -n "$(echo "$svn_status" | \grep \^\M)" ]]; then - hook_com[unstaged]+=" $(print_icon 'VCS_UNSTAGED_ICON')" - VCS_WORKDIR_DIRTY=true - fi - if [[ -n "$(echo "$svn_status" | \grep \^\A)" ]]; then - hook_com[staged]+=" $(print_icon 'VCS_STAGED_ICON')" - VCS_WORKDIR_DIRTY=true - fi -} - -_p9k_vcs_info_init() { - autoload -Uz vcs_info - - local prefix='' - if (( _POWERLEVEL9K_SHOW_CHANGESET )); then - _p9k_get_icon '' VCS_COMMIT_ICON - prefix="$_p9k__ret%0.${_POWERLEVEL9K_CHANGESET_HASH_LENGTH}i " - fi - - zstyle ':vcs_info:*' check-for-changes true - - zstyle ':vcs_info:*' formats "$prefix%b%c%u%m" - zstyle ':vcs_info:*' actionformats "%b %F{$_POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}| %a%f" - _p9k_get_icon '' VCS_STAGED_ICON - zstyle ':vcs_info:*' stagedstr " $_p9k__ret" - _p9k_get_icon '' VCS_UNSTAGED_ICON - zstyle ':vcs_info:*' unstagedstr " $_p9k__ret" - zstyle ':vcs_info:git*+set-message:*' hooks $_POWERLEVEL9K_VCS_GIT_HOOKS - zstyle ':vcs_info:hg*+set-message:*' hooks $_POWERLEVEL9K_VCS_HG_HOOKS - zstyle ':vcs_info:svn*+set-message:*' hooks $_POWERLEVEL9K_VCS_SVN_HOOKS - - # For Hg, only show the branch name - if (( _POWERLEVEL9K_HIDE_BRANCH_ICON )); then - zstyle ':vcs_info:hg*:*' branchformat "%b" - else - _p9k_get_icon '' VCS_BRANCH_ICON - zstyle ':vcs_info:hg*:*' branchformat "$_p9k__ret%b" - fi - # The `get-revision` function must be turned on for dirty-check to work for Hg - zstyle ':vcs_info:hg*:*' get-revision true - zstyle ':vcs_info:hg*:*' get-bookmarks true - zstyle ':vcs_info:hg*+gen-hg-bookmark-string:*' hooks hg-bookmarks - - # TODO: fix the %b (branch) format for svn. Using %b breaks color-encoding of the foreground - # for the rest of the powerline. - zstyle ':vcs_info:svn*:*' formats "$prefix%c%u" - zstyle ':vcs_info:svn*:*' actionformats "$prefix%c%u %F{$_POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}| %a%f" - - if (( _POWERLEVEL9K_SHOW_CHANGESET )); then - zstyle ':vcs_info:*' get-revision true - else - zstyle ':vcs_info:*' get-revision false - fi -} - -function _p9k_vcs_status_save() { - local z=$'\0' - _p9k__gitstatus_last[${${_p9k__git_dir:+GIT_DIR:$_p9k__git_dir}:-$VCS_STATUS_WORKDIR}]=\ -$VCS_STATUS_COMMIT$z$VCS_STATUS_LOCAL_BRANCH$z$VCS_STATUS_REMOTE_BRANCH$z$VCS_STATUS_REMOTE_NAME$z\ -$VCS_STATUS_REMOTE_URL$z$VCS_STATUS_ACTION$z$VCS_STATUS_INDEX_SIZE$z$VCS_STATUS_NUM_STAGED$z\ -$VCS_STATUS_NUM_UNSTAGED$z$VCS_STATUS_NUM_CONFLICTED$z$VCS_STATUS_NUM_UNTRACKED$z\ -$VCS_STATUS_HAS_STAGED$z$VCS_STATUS_HAS_UNSTAGED$z$VCS_STATUS_HAS_CONFLICTED$z\ -$VCS_STATUS_HAS_UNTRACKED$z$VCS_STATUS_COMMITS_AHEAD$z$VCS_STATUS_COMMITS_BEHIND$z\ -$VCS_STATUS_STASHES$z$VCS_STATUS_TAG$z$VCS_STATUS_NUM_UNSTAGED_DELETED$z\ -$VCS_STATUS_NUM_STAGED_NEW$z$VCS_STATUS_NUM_STAGED_DELETED$z$VCS_STATUS_PUSH_REMOTE_NAME$z\ -$VCS_STATUS_PUSH_REMOTE_URL$z$VCS_STATUS_PUSH_COMMITS_AHEAD$z$VCS_STATUS_PUSH_COMMITS_BEHIND$z\ -$VCS_STATUS_NUM_SKIP_WORKTREE$z$VCS_STATUS_NUM_ASSUME_UNCHANGED -} - -function _p9k_vcs_status_restore() { - for VCS_STATUS_COMMIT VCS_STATUS_LOCAL_BRANCH VCS_STATUS_REMOTE_BRANCH VCS_STATUS_REMOTE_NAME \ - VCS_STATUS_REMOTE_URL VCS_STATUS_ACTION VCS_STATUS_INDEX_SIZE VCS_STATUS_NUM_STAGED \ - VCS_STATUS_NUM_UNSTAGED VCS_STATUS_NUM_CONFLICTED VCS_STATUS_NUM_UNTRACKED \ - VCS_STATUS_HAS_STAGED VCS_STATUS_HAS_UNSTAGED VCS_STATUS_HAS_CONFLICTED \ - VCS_STATUS_HAS_UNTRACKED VCS_STATUS_COMMITS_AHEAD VCS_STATUS_COMMITS_BEHIND \ - VCS_STATUS_STASHES VCS_STATUS_TAG VCS_STATUS_NUM_UNSTAGED_DELETED VCS_STATUS_NUM_STAGED_NEW \ - VCS_STATUS_NUM_STAGED_DELETED VCS_STATUS_PUSH_REMOTE_NAME VCS_STATUS_PUSH_REMOTE_URL \ - VCS_STATUS_PUSH_COMMITS_AHEAD VCS_STATUS_PUSH_COMMITS_BEHIND VCS_STATUS_NUM_SKIP_WORKTREE \ - VCS_STATUS_NUM_ASSUME_UNCHANGED - in "${(@0)1}"; do done -} - -function _p9k_vcs_status_for_dir() { - if [[ -n $GIT_DIR ]]; then - _p9k__ret=$_p9k__gitstatus_last[GIT_DIR:$GIT_DIR] - [[ -n $_p9k__ret ]] - else - local dir=$_p9k__cwd_a - while true; do - _p9k__ret=$_p9k__gitstatus_last[$dir] - [[ -n $_p9k__ret ]] && return 0 - [[ $dir == (/|.) ]] && return 1 - dir=${dir:h} - done - fi -} - -function _p9k_vcs_status_purge() { - if [[ -n $_p9k__git_dir ]]; then - _p9k__gitstatus_last[GIT_DIR:$_p9k__git_dir]="" - else - local dir=$1 - while true; do - # unset doesn't work if $dir contains weird shit - _p9k__gitstatus_last[$dir]="" - _p9k_git_slow[$dir]="" - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi -} - -function _p9k_vcs_icon() { - case "$VCS_STATUS_REMOTE_URL" in - *github*) _p9k__ret=VCS_GIT_GITHUB_ICON;; - *bitbucket*) _p9k__ret=VCS_GIT_BITBUCKET_ICON;; - *stash*) _p9k__ret=VCS_GIT_BITBUCKET_ICON;; - *gitlab*) _p9k__ret=VCS_GIT_GITLAB_ICON;; - *) _p9k__ret=VCS_GIT_ICON;; - esac -} - -function _p9k_vcs_render() { - local state - - if (( $+_p9k__gitstatus_next_dir )); then - if _p9k_vcs_status_for_dir; then - _p9k_vcs_status_restore $_p9k__ret - state=LOADING - else - _p9k_prompt_segment prompt_vcs_LOADING "${__p9k_vcs_states[LOADING]}" "$_p9k_color1" VCS_LOADING_ICON 0 '' "$_POWERLEVEL9K_VCS_LOADING_TEXT" - return 0 - fi - elif [[ $VCS_STATUS_RESULT != ok-* ]]; then - return 1 - fi - - if (( _POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING )); then - if [[ -z $state ]]; then - if [[ $VCS_STATUS_HAS_CONFLICTED == 1 && $_POWERLEVEL9K_VCS_CONFLICTED_STATE == 1 ]]; then - state=CONFLICTED - elif [[ $VCS_STATUS_HAS_STAGED != 0 || $VCS_STATUS_HAS_UNSTAGED != 0 ]]; then - state=MODIFIED - elif [[ $VCS_STATUS_HAS_UNTRACKED != 0 ]]; then - state=UNTRACKED - else - state=CLEAN - fi - fi - _p9k_vcs_icon - _p9k_prompt_segment prompt_vcs_$state "${__p9k_vcs_states[$state]}" "$_p9k_color1" "$_p9k__ret" 0 '' "" - return 0 - fi - - (( ${_POWERLEVEL9K_VCS_GIT_HOOKS[(I)git-untracked]} )) || VCS_STATUS_HAS_UNTRACKED=0 - (( ${_POWERLEVEL9K_VCS_GIT_HOOKS[(I)git-aheadbehind]} )) || { VCS_STATUS_COMMITS_AHEAD=0 && VCS_STATUS_COMMITS_BEHIND=0 } - (( ${_POWERLEVEL9K_VCS_GIT_HOOKS[(I)git-stash]} )) || VCS_STATUS_STASHES=0 - (( ${_POWERLEVEL9K_VCS_GIT_HOOKS[(I)git-remotebranch]} )) || VCS_STATUS_REMOTE_BRANCH="" - (( ${_POWERLEVEL9K_VCS_GIT_HOOKS[(I)git-tagname]} )) || VCS_STATUS_TAG="" - - (( _POWERLEVEL9K_VCS_COMMITS_AHEAD_MAX_NUM >= 0 && VCS_STATUS_COMMITS_AHEAD > _POWERLEVEL9K_VCS_COMMITS_AHEAD_MAX_NUM )) && - VCS_STATUS_COMMITS_AHEAD=$_POWERLEVEL9K_VCS_COMMITS_AHEAD_MAX_NUM - - (( _POWERLEVEL9K_VCS_COMMITS_BEHIND_MAX_NUM >= 0 && VCS_STATUS_COMMITS_BEHIND > _POWERLEVEL9K_VCS_COMMITS_BEHIND_MAX_NUM )) && - VCS_STATUS_COMMITS_BEHIND=$_POWERLEVEL9K_VCS_COMMITS_BEHIND_MAX_NUM - - local -a cache_key=( - "$VCS_STATUS_LOCAL_BRANCH" - "$VCS_STATUS_REMOTE_BRANCH" - "$VCS_STATUS_REMOTE_URL" - "$VCS_STATUS_ACTION" - "$VCS_STATUS_NUM_STAGED" - "$VCS_STATUS_NUM_UNSTAGED" - "$VCS_STATUS_NUM_UNTRACKED" - "$VCS_STATUS_HAS_CONFLICTED" - "$VCS_STATUS_HAS_STAGED" - "$VCS_STATUS_HAS_UNSTAGED" - "$VCS_STATUS_HAS_UNTRACKED" - "$VCS_STATUS_COMMITS_AHEAD" - "$VCS_STATUS_COMMITS_BEHIND" - "$VCS_STATUS_STASHES" - "$VCS_STATUS_TAG" - "$VCS_STATUS_NUM_UNSTAGED_DELETED" - ) - if [[ $_POWERLEVEL9K_SHOW_CHANGESET == 1 || -z $VCS_STATUS_LOCAL_BRANCH ]]; then - cache_key+=$VCS_STATUS_COMMIT - fi - - if ! _p9k_cache_ephemeral_get "$state" "${(@)cache_key}"; then - local icon - local content - - if (( ${_POWERLEVEL9K_VCS_GIT_HOOKS[(I)vcs-detect-changes]} )); then - if [[ $VCS_STATUS_HAS_CONFLICTED == 1 && $_POWERLEVEL9K_VCS_CONFLICTED_STATE == 1 ]]; then - : ${state:=CONFLICTED} - elif [[ $VCS_STATUS_HAS_STAGED != 0 || $VCS_STATUS_HAS_UNSTAGED != 0 ]]; then - : ${state:=MODIFIED} - elif [[ $VCS_STATUS_HAS_UNTRACKED != 0 ]]; then - : ${state:=UNTRACKED} - fi - - # It's weird that removing vcs-detect-changes from POWERLEVEL9K_VCS_GIT_HOOKS gets rid - # of the GIT icon. That's what vcs_info does, so we do the same in the name of compatiblity. - _p9k_vcs_icon - icon=$_p9k__ret - fi - - : ${state:=CLEAN} - - function _$0_fmt() { - _p9k_vcs_style $state $1 - content+="$_p9k__ret$2" - } - - local ws - if [[ $_POWERLEVEL9K_SHOW_CHANGESET == 1 || -z $VCS_STATUS_LOCAL_BRANCH ]]; then - _p9k_get_icon prompt_vcs_$state VCS_COMMIT_ICON - _$0_fmt COMMIT "$_p9k__ret${${VCS_STATUS_COMMIT:0:$_POWERLEVEL9K_CHANGESET_HASH_LENGTH}:-HEAD}" - ws=' ' - fi - - if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - local branch=$ws - if (( !_POWERLEVEL9K_HIDE_BRANCH_ICON )); then - _p9k_get_icon prompt_vcs_$state VCS_BRANCH_ICON - branch+=$_p9k__ret - fi - if (( $+_POWERLEVEL9K_VCS_SHORTEN_LENGTH && $+_POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH && - $#VCS_STATUS_LOCAL_BRANCH > _POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH && - $#VCS_STATUS_LOCAL_BRANCH > _POWERLEVEL9K_VCS_SHORTEN_LENGTH )) && - [[ $_POWERLEVEL9K_VCS_SHORTEN_STRATEGY == (truncate_middle|truncate_from_right) ]]; then - branch+=${VCS_STATUS_LOCAL_BRANCH[1,_POWERLEVEL9K_VCS_SHORTEN_LENGTH]//\%/%%}${_POWERLEVEL9K_VCS_SHORTEN_DELIMITER} - if [[ $_POWERLEVEL9K_VCS_SHORTEN_STRATEGY == truncate_middle ]]; then - _p9k_vcs_style $state BRANCH - branch+=${_p9k__ret}${VCS_STATUS_LOCAL_BRANCH[-_POWERLEVEL9K_VCS_SHORTEN_LENGTH,-1]//\%/%%} - fi - else - branch+=${VCS_STATUS_LOCAL_BRANCH//\%/%%} - fi - _$0_fmt BRANCH $branch - fi - - if [[ $_POWERLEVEL9K_VCS_HIDE_TAGS == 0 && -n $VCS_STATUS_TAG ]]; then - _p9k_get_icon prompt_vcs_$state VCS_TAG_ICON - _$0_fmt TAG " $_p9k__ret${VCS_STATUS_TAG//\%/%%}" - fi - - if [[ -n $VCS_STATUS_ACTION ]]; then - _$0_fmt ACTION " | ${VCS_STATUS_ACTION//\%/%%}" - else - if [[ -n $VCS_STATUS_REMOTE_BRANCH && - $VCS_STATUS_LOCAL_BRANCH != $VCS_STATUS_REMOTE_BRANCH ]]; then - _p9k_get_icon prompt_vcs_$state VCS_REMOTE_BRANCH_ICON - _$0_fmt REMOTE_BRANCH " $_p9k__ret${VCS_STATUS_REMOTE_BRANCH//\%/%%}" - fi - if [[ $VCS_STATUS_HAS_STAGED == 1 || $VCS_STATUS_HAS_UNSTAGED == 1 || $VCS_STATUS_HAS_UNTRACKED == 1 ]]; then - _p9k_get_icon prompt_vcs_$state VCS_DIRTY_ICON - _$0_fmt DIRTY "$_p9k__ret" - if [[ $VCS_STATUS_HAS_STAGED == 1 ]]; then - _p9k_get_icon prompt_vcs_$state VCS_STAGED_ICON - (( _POWERLEVEL9K_VCS_STAGED_MAX_NUM != 1 )) && _p9k__ret+=$VCS_STATUS_NUM_STAGED - _$0_fmt STAGED " $_p9k__ret" - fi - if [[ $VCS_STATUS_HAS_UNSTAGED == 1 ]]; then - _p9k_get_icon prompt_vcs_$state VCS_UNSTAGED_ICON - (( _POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM != 1 )) && _p9k__ret+=$VCS_STATUS_NUM_UNSTAGED - _$0_fmt UNSTAGED " $_p9k__ret" - fi - if [[ $VCS_STATUS_HAS_UNTRACKED == 1 ]]; then - _p9k_get_icon prompt_vcs_$state VCS_UNTRACKED_ICON - (( _POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM != 1 )) && _p9k__ret+=$VCS_STATUS_NUM_UNTRACKED - _$0_fmt UNTRACKED " $_p9k__ret" - fi - fi - if [[ $VCS_STATUS_COMMITS_BEHIND -gt 0 ]]; then - _p9k_get_icon prompt_vcs_$state VCS_INCOMING_CHANGES_ICON - (( _POWERLEVEL9K_VCS_COMMITS_BEHIND_MAX_NUM != 1 )) && _p9k__ret+=$VCS_STATUS_COMMITS_BEHIND - _$0_fmt INCOMING_CHANGES " $_p9k__ret" - fi - if [[ $VCS_STATUS_COMMITS_AHEAD -gt 0 ]]; then - _p9k_get_icon prompt_vcs_$state VCS_OUTGOING_CHANGES_ICON - (( _POWERLEVEL9K_VCS_COMMITS_AHEAD_MAX_NUM != 1 )) && _p9k__ret+=$VCS_STATUS_COMMITS_AHEAD - _$0_fmt OUTGOING_CHANGES " $_p9k__ret" - fi - if [[ $VCS_STATUS_STASHES -gt 0 ]]; then - _p9k_get_icon prompt_vcs_$state VCS_STASH_ICON - _$0_fmt STASH " $_p9k__ret$VCS_STATUS_STASHES" - fi - fi - - _p9k_cache_ephemeral_set "prompt_vcs_$state" "${__p9k_vcs_states[$state]}" "$_p9k_color1" "$icon" 0 '' "$content" - fi - - _p9k_prompt_segment "$_p9k__cache_val[@]" - return 0 -} - -function _p9k_maybe_ignore_git_repo() { - if [[ $VCS_STATUS_RESULT == ok-* && $VCS_STATUS_WORKDIR == $~_POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN ]]; then - VCS_STATUS_RESULT=norepo${VCS_STATUS_RESULT#ok} - fi -} - -function _p9k_vcs_resume() { - eval "$__p9k_intro" - - _p9k_maybe_ignore_git_repo - - if [[ $VCS_STATUS_RESULT == ok-async ]]; then - local latency=$((EPOCHREALTIME - _p9k__gitstatus_start_time)) - if (( latency > _POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS )); then - _p9k_git_slow[${${_p9k__git_dir:+GIT_DIR:$_p9k__git_dir}:-$VCS_STATUS_WORKDIR}]=1 - elif (( $1 && latency < 0.8 * _POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS )); then # 0.8 to avoid flip-flopping - _p9k_git_slow[${${_p9k__git_dir:+GIT_DIR:$_p9k__git_dir}:-$VCS_STATUS_WORKDIR}]=0 - fi - _p9k_vcs_status_save - fi - - if [[ -z $_p9k__gitstatus_next_dir ]]; then - unset _p9k__gitstatus_next_dir - case $VCS_STATUS_RESULT in - norepo-async) (( $1 )) && _p9k_vcs_status_purge $_p9k__cwd_a;; - ok-async) (( $1 )) || _p9k__gitstatus_next_dir=$_p9k__cwd_a;; - esac - fi - - if [[ -n $_p9k__gitstatus_next_dir ]]; then - _p9k__git_dir=$GIT_DIR - if ! gitstatus_query_p9k_ -d $_p9k__gitstatus_next_dir -t 0 -c '_p9k_vcs_resume 1' POWERLEVEL9K; then - unset _p9k__gitstatus_next_dir - unset VCS_STATUS_RESULT - else - _p9k_maybe_ignore_git_repo - case $VCS_STATUS_RESULT in - tout) _p9k__gitstatus_next_dir=''; _p9k__gitstatus_start_time=$EPOCHREALTIME;; - norepo-sync) _p9k_vcs_status_purge $_p9k__gitstatus_next_dir; unset _p9k__gitstatus_next_dir;; - ok-sync) _p9k_vcs_status_save; unset _p9k__gitstatus_next_dir;; - esac - fi - fi - - if (( _p9k_vcs_index && $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )); then - local _p9k__prompt _p9k__prompt_side=$_p9k_vcs_side _p9k__segment_name=vcs - local -i _p9k__has_upglob _p9k__segment_index=_p9k_vcs_index _p9k__line_index=_p9k_vcs_line_index - _p9k_vcs_render - typeset -g _p9k__vcs=$_p9k__prompt - else - _p9k__refresh_reason=gitstatus - _p9k_set_prompt - _p9k__refresh_reason='' - fi - _p9k_reset_prompt -} - -function _p9k_vcs_gitstatus() { - if [[ $_p9k__refresh_reason == precmd ]] && (( !_p9k__vcs_called )); then - typeset -gi _p9k__vcs_called=1 - if (( $+_p9k__gitstatus_next_dir )); then - _p9k__gitstatus_next_dir=$_p9k__cwd_a - else - local -F timeout=_POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS - if ! _p9k_vcs_status_for_dir; then - _p9k__git_dir=$GIT_DIR - gitstatus_query_p9k_ -d $_p9k__cwd_a -t $timeout -p -c '_p9k_vcs_resume 0' POWERLEVEL9K || return 1 - _p9k_maybe_ignore_git_repo - case $VCS_STATUS_RESULT in - tout) _p9k__gitstatus_next_dir=''; _p9k__gitstatus_start_time=$EPOCHREALTIME; return 0;; - norepo-sync) return 0;; - ok-sync) _p9k_vcs_status_save;; - esac - else - if [[ -n $GIT_DIR ]]; then - [[ $_p9k_git_slow[GIT_DIR:$GIT_DIR] == 1 ]] && timeout=0 - else - local dir=$_p9k__cwd_a - while true; do - case $_p9k_git_slow[$dir] in - "") [[ $dir == (/|.) ]] && break; dir=${dir:h};; - 0) break;; - 1) timeout=0; break;; - esac - done - fi - fi - (( _p9k__prompt_idx == 1 )) && timeout=0 - _p9k__git_dir=$GIT_DIR - if (( _p9k_vcs_index && $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )); then - if ! gitstatus_query_p9k_ -d $_p9k__cwd_a -t 0 -c '_p9k_vcs_resume 1' POWERLEVEL9K; then - unset VCS_STATUS_RESULT - return 1 - fi - typeset -gF _p9k__vcs_timeout=timeout - _p9k__gitstatus_next_dir='' - _p9k__gitstatus_start_time=$EPOCHREALTIME - return 0 - fi - if ! gitstatus_query_p9k_ -d $_p9k__cwd_a -t $timeout -c '_p9k_vcs_resume 1' POWERLEVEL9K; then - unset VCS_STATUS_RESULT - return 1 - fi - _p9k_maybe_ignore_git_repo - case $VCS_STATUS_RESULT in - tout) _p9k__gitstatus_next_dir=''; _p9k__gitstatus_start_time=$EPOCHREALTIME;; - norepo-sync) _p9k_vcs_status_purge $_p9k__cwd_a;; - ok-sync) _p9k_vcs_status_save;; - esac - fi - fi - return 0 -} - -################################################################ -# Segment to show VCS information - -prompt_vcs() { - if (( _p9k_vcs_index && $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )); then - _p9k__prompt+='${(e)_p9k__vcs}' - return - fi - - local -a backends=($_POWERLEVEL9K_VCS_BACKENDS) - if (( ${backends[(I)git]} && $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )) && _p9k_vcs_gitstatus; then - _p9k_vcs_render && return - backends=(${backends:#git}) - fi - if (( $#backends )); then - VCS_WORKDIR_DIRTY=false - VCS_WORKDIR_HALF_DIRTY=false - local current_state="" - # Actually invoke vcs_info manually to gather all information. - zstyle ':vcs_info:*' enable ${backends} - vcs_info - local vcs_prompt="${vcs_info_msg_0_}" - if [[ -n "$vcs_prompt" ]]; then - if [[ "$VCS_WORKDIR_DIRTY" == true ]]; then - # $vcs_visual_identifier gets set in +vi-vcs-detect-changes in functions/vcs.zsh, - # as we have there access to vcs_info internal hooks. - current_state='MODIFIED' - else - if [[ "$VCS_WORKDIR_HALF_DIRTY" == true ]]; then - current_state='UNTRACKED' - else - current_state='CLEAN' - fi - fi - _p9k_prompt_segment "${0}_${${(U)current_state}//İ/I}" "${__p9k_vcs_states[$current_state]}" "$_p9k_color1" "$vcs_visual_identifier" 0 '' "$vcs_prompt" - fi - fi -} - -################################################################ -# Vi Mode: show editing mode (NORMAL|INSERT|VISUAL) -prompt_vi_mode() { - local -i len=$#_p9k__prompt _p9k__has_upglob - if (( __p9k_sh_glob )); then - if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${${${${:-$_p9k__keymap.$_p9k__zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" - fi - _p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${${${${${:-$_p9k__keymap.$_p9k__zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING" - else - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${${_p9k__keymap:#vicmd}:#vivis}:#vivli}}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" - fi - fi - - if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k__keymap$_p9k__region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" - _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${$((! ${#${${${${:-$_p9k__keymap$_p9k__region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" - else - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${$((! ${#${${${_p9k__keymap:#vicmd}:#vivis}:#vivli}})):#0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" - fi - else - if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${:-$_p9k__keymap.$_p9k__zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" - fi - _p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${:-$_p9k__keymap.$_p9k__zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING" - else - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${_p9k__keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" - fi - fi - - if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k__keymap$_p9k__region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" - _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k__keymap$_p9k__region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" - else - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)_p9k__keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" - fi - fi - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -instant_prompt_vi_mode() { - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment prompt_vi_mode_INSERT "$_p9k_color1" blue '' 0 '' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" - fi -} - -################################################################ -# Virtualenv: current working virtualenv -# More information on virtualenv (Python): -# https://virtualenv.pypa.io/en/latest/ -prompt_virtualenv() { - local msg='' - if (( _POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION )) && _p9k_python_version; then - msg="${_p9k__ret//\%/%%} " - fi - local v=${VIRTUAL_ENV:t} - if [[ $VIRTUAL_ENV_PROMPT == '('?*') ' && $VIRTUAL_ENV_PROMPT != "($v) " ]]; then - v=$VIRTUAL_ENV_PROMPT[2,-3] - elif [[ $v == $~_POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES ]]; then - v=${VIRTUAL_ENV:h:t} - fi - msg+="$_POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER${v//\%/%%}$_POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER" - case $_POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV in - false) - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '${(M)${#P9K_PYENV_PYTHON_VERSION}:#0}' "$msg" - ;; - if-different) - _p9k_escape $v - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '${${:-'$_p9k__ret'}:#$_p9k__pyenv_version}' "$msg" - ;; - *) - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "$msg" - ;; - esac -} - -_p9k_prompt_virtualenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$VIRTUAL_ENV' -} - -# _p9k_read_pyenv_like_version_file <filepath> [prefix] -function _p9k_read_pyenv_like_version_file() { - local -a stat - zstat -A stat +mtime -- $1 2>/dev/null || stat=(-1) - local cached=$_p9k__read_pyenv_like_version_file_cache[$1:$2] - if [[ $cached == $stat[1]:* ]]; then - _p9k__ret=${cached#*:} - else - local fd content - { - { sysopen -r -u fd -- $1 && sysread -i $fd -s 1024 content } 2>/dev/null - } always { - [[ -n $fd ]] && exec {fd}>&- - } - local MATCH - local versions=(${${${${(f)content}/(#m)*/${MATCH[(w)1]}}##\#*}#$2}) - _p9k__ret=${(j.:.)versions} - _p9k__read_pyenv_like_version_file_cache[$1:$2]=$stat[1]:$_p9k__ret - fi - [[ -n $_p9k__ret ]] -} - -function _p9k_pyenv_global_version() { - _p9k_read_pyenv_like_version_file ${PYENV_ROOT:-$HOME/.pyenv}/version python- || _p9k__ret=system -} - -function _p9k_pyenv_compute() { - unset P9K_PYENV_PYTHON_VERSION _p9k__pyenv_version - - local v=${(j.:.)${(@)${(s.:.)PYENV_VERSION}#python-}} - if [[ -n $v ]]; then - (( ${_POWERLEVEL9K_PYENV_SOURCES[(I)shell]} )) || return - else - (( ${_POWERLEVEL9K_PYENV_SOURCES[(I)local|global]} )) || return - _p9k__ret= - if [[ $PYENV_DIR != (|.) ]]; then - [[ $PYENV_DIR == /* ]] && local dir=$PYENV_DIR || local dir="$_p9k__cwd_a/$PYENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if _p9k_read_pyenv_like_version_file $dir/.python-version python-; then - (( ${_POWERLEVEL9K_PYENV_SOURCES[(I)local]} )) || return - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - if [[ -z $_p9k__ret ]]; then - _p9k_upglob .python-version - local -i idx=$? - if (( idx )) && _p9k_read_pyenv_like_version_file $_p9k__parent_dirs[idx]/.python-version python-; then - (( ${_POWERLEVEL9K_PYENV_SOURCES[(I)local]} )) || return - else - _p9k__ret= - fi - fi - if [[ -z $_p9k__ret ]]; then - (( _POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_PYENV_SOURCES[(I)global]} )) || return - _p9k_pyenv_global_version - fi - v=$_p9k__ret - fi - - if (( !_POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW )); then - _p9k_pyenv_global_version - [[ $v == $_p9k__ret ]] && return 1 - fi - - if (( !_POWERLEVEL9K_PYENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return 1 - fi - - local versions=${PYENV_ROOT:-$HOME/.pyenv}/versions - versions=${versions:A} - local name version - for name in ${(s.:.)v}; do - version=$versions/$name - version=${version:A} - if [[ $version(#qN/) == (#b)$versions/([^/]##)* ]]; then - typeset -g P9K_PYENV_PYTHON_VERSION=$match[1] - break - fi - done - - typeset -g _p9k__pyenv_version=$v -} - -################################################################ -# Segment to display pyenv information -# https://github.com/pyenv/pyenv#choosing-the-python-version -prompt_pyenv() { - _p9k_pyenv_compute || return - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "${_p9k__pyenv_version//\%/%%}" -} - -_p9k_prompt_pyenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[pyenv]:-${${+functions[pyenv]}:#0}}' -} - -function _p9k_goenv_global_version() { - _p9k_read_pyenv_like_version_file ${GOENV_ROOT:-$HOME/.goenv}/version go- || _p9k__ret=system -} - -################################################################ -# Segment to display goenv information: https://github.com/syndbg/goenv -prompt_goenv() { - local v=${(j.:.)${(@)${(s.:.)GOENV_VERSION}#go-}} - if [[ -n $v ]]; then - (( ${_POWERLEVEL9K_GOENV_SOURCES[(I)shell]} )) || return - else - (( ${_POWERLEVEL9K_GOENV_SOURCES[(I)local|global]} )) || return - _p9k__ret= - if [[ $GOENV_DIR != (|.) ]]; then - [[ $GOENV_DIR == /* ]] && local dir=$GOENV_DIR || local dir="$_p9k__cwd_a/$GOENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if _p9k_read_pyenv_like_version_file $dir/.go-version go-; then - (( ${_POWERLEVEL9K_GOENV_SOURCES[(I)local]} )) || return - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - if [[ -z $_p9k__ret ]]; then - _p9k_upglob .go-version - local -i idx=$? - if (( idx )) && _p9k_read_pyenv_like_version_file $_p9k__parent_dirs[idx]/.go-version go-; then - (( ${_POWERLEVEL9K_GOENV_SOURCES[(I)local]} )) || return - else - _p9k__ret= - fi - fi - if [[ -z $_p9k__ret ]]; then - (( _POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_GOENV_SOURCES[(I)global]} )) || return - _p9k_goenv_global_version - fi - v=$_p9k__ret - fi - - if (( !_POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW )); then - _p9k_goenv_global_version - [[ $v == $_p9k__ret ]] && return - fi - - if (( !_POWERLEVEL9K_GOENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return - fi - - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'GO_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_goenv_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[goenv]:-${${+functions[goenv]}:#0}}' -} - -################################################################ -# Display openfoam information -prompt_openfoam() { - if [[ -z "$WM_FORK" ]] ; then - _p9k_prompt_segment "$0" "yellow" "$_p9k_color1" '' 0 '' "OF: ${${WM_PROJECT_VERSION:t}//\%/%%}" - else - _p9k_prompt_segment "$0" "yellow" "$_p9k_color1" '' 0 '' "F-X: ${${WM_PROJECT_VERSION:t}//\%/%%}" - fi -} - -_p9k_prompt_openfoam_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$WM_PROJECT_VERSION' -} - -################################################################ -# Segment to display Swift version -prompt_swift_version() { - _p9k_cached_cmd 0 '' swift --version || return - [[ $_p9k__ret == (#b)[^[:digit:]]#([[:digit:].]##)* ]] || return - _p9k_prompt_segment "$0" "magenta" "white" 'SWIFT_ICON' 0 '' "${match[1]//\%/%%}" -} - -_p9k_prompt_swift_version_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[swift]' -} - -################################################################ -# dir_writable: Display information about the user's permission to write in the current directory -prompt_dir_writable() { - if [[ ! -w "$_p9k__cwd_a" ]]; then - _p9k_prompt_segment "$0_FORBIDDEN" "red" "yellow1" 'LOCK_ICON' 0 '' '' - fi -} - -instant_prompt_dir_writable() { prompt_dir_writable; } - -################################################################ -# Kubernetes Current Context/Namespace -prompt_kubecontext() { - if ! _p9k_cache_stat_get $0 ${(s.:.)${KUBECONFIG:-$HOME/.kube/config}}; then - local name namespace cluster user cloud_name cloud_account cloud_zone cloud_cluster text state - () { - local cfg && cfg=(${(f)"$(kubectl config view -o=yaml 2>/dev/null)"}) || return - local qstr='"*"' - local str='([^"'\''|>]*|'$qstr')' - local ctx=(${(@M)cfg:#current-context: $~str}) - (( $#ctx == 1 )) || return - name=${ctx[1]#current-context: } - local -i pos=${cfg[(i)contexts:]} - { - (( pos <= $#cfg )) || return - shift $pos cfg - pos=${cfg[(i) name: ${(b)name}]} - (( pos <= $#cfg )) || return - (( --pos )) - for ((; pos > 0; --pos)); do - local line=$cfg[pos] - if [[ $line == '- context:' ]]; then - return 0 - elif [[ $line == (#b)' cluster: '($~str) ]]; then - cluster=$match[1] - [[ $cluster == $~qstr ]] && cluster=$cluster[2,-2] - elif [[ $line == (#b)' namespace: '($~str) ]]; then - namespace=$match[1] - [[ $namespace == $~qstr ]] && namespace=$namespace[2,-2] - elif [[ $line == (#b)' user: '($~str) ]]; then - user=$match[1] - [[ $user == $~qstr ]] && user=$user[2,-2] - fi - done - } always { - [[ $name == $~qstr ]] && name=$name[2,-2] - } - } - if [[ -n $name ]]; then - : ${namespace:=default} - # gke_my-account_us-east1-a_cluster-01 - # gke_my-account_us-east1_cluster-01 - if [[ $cluster == (#b)gke_(?*)_(asia|australia|europe|northamerica|southamerica|us)-([a-z]##<->)(-[a-z]|)_(?*) ]]; then - cloud_name=gke - cloud_account=$match[1] - cloud_zone=$match[2]-$match[3]$match[4] - cloud_cluster=$match[5] - if (( ${_POWERLEVEL9K_KUBECONTEXT_SHORTEN[(I)gke]} )); then - text=$cloud_cluster - fi - # arn:aws:eks:us-east-1:123456789012:cluster/cluster-01 - elif [[ $cluster == (#b)arn:aws:eks:([[:alnum:]-]##):([[:digit:]]##):cluster/(?*) ]]; then - cloud_name=eks - cloud_zone=$match[1] - cloud_account=$match[2] - cloud_cluster=$match[3] - if (( ${_POWERLEVEL9K_KUBECONTEXT_SHORTEN[(I)eks]} )); then - text=$cloud_cluster - fi - fi - if [[ -z $text ]]; then - text=$name - if [[ $_POWERLEVEL9K_KUBECONTEXT_SHOW_DEFAULT_NAMESPACE == 1 || $namespace != (default|$name) ]]; then - text+="/$namespace" - fi - fi - local pat class - for pat class in "${_POWERLEVEL9K_KUBECONTEXT_CLASSES[@]}"; do - if [[ $text == ${~pat} ]]; then - [[ -n $class ]] && state=_${${(U)class}//İ/I} - break - fi - done - fi - _p9k_cache_stat_set "${(g::)name}" "${(g::)namespace}" "${(g::)cluster}" "${(g::)user}" "${(g::)cloud_name}" "${(g::)cloud_account}" "${(g::)cloud_zone}" "${(g::)cloud_cluster}" "${(g::)text}" "$state" - fi - - typeset -g P9K_KUBECONTEXT_NAME=$_p9k__cache_val[1] - typeset -g P9K_KUBECONTEXT_NAMESPACE=$_p9k__cache_val[2] - typeset -g P9K_KUBECONTEXT_CLUSTER=$_p9k__cache_val[3] - typeset -g P9K_KUBECONTEXT_USER=$_p9k__cache_val[4] - typeset -g P9K_KUBECONTEXT_CLOUD_NAME=$_p9k__cache_val[5] - typeset -g P9K_KUBECONTEXT_CLOUD_ACCOUNT=$_p9k__cache_val[6] - typeset -g P9K_KUBECONTEXT_CLOUD_ZONE=$_p9k__cache_val[7] - typeset -g P9K_KUBECONTEXT_CLOUD_CLUSTER=$_p9k__cache_val[8] - [[ -n $_p9k__cache_val[9] ]] || return - _p9k_prompt_segment $0$_p9k__cache_val[10] magenta white KUBERNETES_ICON 0 '' "${_p9k__cache_val[9]//\%/%%}" -} - -_p9k_prompt_kubecontext_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[kubectl]' -} - -################################################################ -# Dropbox status -prompt_dropbox() { - # The first column is just the directory, so cut it - local dropbox_status="$(dropbox-cli filestatus . | cut -d\ -f2-)" - - # Only show if the folder is tracked and dropbox is running - if [[ "$dropbox_status" != 'unwatched' && "$dropbox_status" != "isn't running!" ]]; then - # If "up to date", only show the icon - if [[ "$dropbox_status" =~ 'up to date' ]]; then - dropbox_status="" - fi - - _p9k_prompt_segment "$0" "white" "blue" "DROPBOX_ICON" 0 '' "${dropbox_status//\%/%%}" - fi -} - -_p9k_prompt_dropbox_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[dropbox-cli]' -} - -# print Java version number -prompt_java_version() { - if (( _POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY )); then - _p9k_upglob 'pom.xml|build.gradle.kts|build.sbt|deps.edn|project.clj|build.boot|*.(java|class|jar|gradle|clj|cljc)' && return - fi - - local java=$commands[java] - if ! _p9k_cache_stat_get $0 $java ${JAVA_HOME:+$JAVA_HOME/release}; then - local v - v="$(java -fullversion 2>&1)" || v= - v=${${v#*\"}%\"*} - (( _POWERLEVEL9K_JAVA_VERSION_FULL )) || v=${v%%-*} - _p9k_cache_stat_set "${v//\%/%%}" - fi - - [[ -n $_p9k__cache_val[1] ]] || return - _p9k_prompt_segment "$0" "red" "white" "JAVA_ICON" 0 '' $_p9k__cache_val[1] -} - -_p9k_prompt_java_version_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[java]' -} - -prompt_azure() { - local cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json - if ! _p9k_cache_stat_get $0 $cfg; then - local name - if (( $+commands[jq] )) && name="$(jq -r '[.subscriptions[]|select(.isDefault==true)|.name][]|strings' $cfg 2>/dev/null)"; then - name=${name%%$'\n'*} - elif ! name="$(az account show --query name --output tsv 2>/dev/null)"; then - name= - fi - _p9k_cache_stat_set "$name" - fi - local pat class state - for pat class in "${_POWERLEVEL9K_AZURE_CLASSES[@]}"; do - if [[ $name == ${~pat} ]]; then - [[ -n $class ]] && state=_${${(U)class}//İ/I} - break - fi - done - [[ -n $_p9k__cache_val[1] ]] || return - _p9k_prompt_segment "$0$state" "blue" "white" "AZURE_ICON" 0 '' "${_p9k__cache_val[1]//\%/%%}" -} - -_p9k_prompt_azure_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[az]' -} - -prompt_gcloud() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment \ - $0_PARTIAL blue white GCLOUD_ICON 1 \ - '${${(M)${#P9K_GCLOUD_PROJECT_NAME}:#0}:+$P9K_GCLOUD_ACCOUNT$P9K_GCLOUD_PROJECT_ID}' \ - '${P9K_GCLOUD_ACCOUNT//\%/%%}:${P9K_GCLOUD_PROJECT_ID//\%/%%}' - _p9k_prompt_segment \ - $0_COMPLETE blue white GCLOUD_ICON 1 \ - '$P9K_GCLOUD_PROJECT_NAME' \ - '${P9K_GCLOUD_ACCOUNT//\%/%%}:${P9K_GCLOUD_PROJECT_ID//\%/%%}' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_gcloud_prefetch() { - # P9K_GCLOUD_PROJECT is deprecated; it's always equal to P9K_GCLOUD_PROJECT_ID - unset P9K_GCLOUD_CONFIGURATION P9K_GCLOUD_ACCOUNT P9K_GCLOUD_PROJECT P9K_GCLOUD_PROJECT_ID P9K_GCLOUD_PROJECT_NAME - (( $+commands[gcloud] )) || return - _p9k_read_word ${CLOUDSDK_CONFIG:-~/.config/gcloud}/active_config || return - P9K_GCLOUD_CONFIGURATION=$_p9k__ret - if ! _p9k_cache_stat_get $0 ${CLOUDSDK_CONFIG:-~/.config/gcloud}/configurations/config_$P9K_GCLOUD_CONFIGURATION; then - local pair account project_id - pair="$(gcloud config configurations describe $P9K_GCLOUD_CONFIGURATION \ - --format=$'value[separator="\1"](properties.core.account,properties.core.project)')" - (( ! $? )) && IFS=$'\1' read account project_id <<<$pair - _p9k_cache_stat_set "$account" "$project_id" - fi - if [[ -n $_p9k__cache_val[1] ]]; then - P9K_GCLOUD_ACCOUNT=$_p9k__cache_val[1] - fi - if [[ -n $_p9k__cache_val[2] ]]; then - P9K_GCLOUD_PROJECT_ID=$_p9k__cache_val[2] - P9K_GCLOUD_PROJECT=$P9K_GCLOUD_PROJECT_ID # deprecated parameter; set for backward compatibility - fi - if [[ $P9K_GCLOUD_CONFIGURATION == $_p9k_gcloud_configuration && - $P9K_GCLOUD_ACCOUNT == $_p9k_gcloud_account && - $P9K_GCLOUD_PROJECT_ID == $_p9k_gcloud_project_id ]]; then - [[ -n $_p9k_gcloud_project_name ]] && P9K_GCLOUD_PROJECT_NAME=$_p9k_gcloud_project_name - if (( _POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS < 0 || - _p9k__gcloud_last_fetch_ts + _POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS > EPOCHREALTIME )); then - return - fi - else - _p9k_gcloud_configuration=$P9K_GCLOUD_CONFIGURATION - _p9k_gcloud_account=$P9K_GCLOUD_ACCOUNT - _p9k_gcloud_project_id=$P9K_GCLOUD_PROJECT_ID - _p9k_gcloud_project_name= - _p9k__state_dump_scheduled=1 - fi - [[ -n $P9K_GCLOUD_CONFIGURATION && -n $P9K_GCLOUD_ACCOUNT && -n $P9K_GCLOUD_PROJECT_ID ]] || return - _p9k__gcloud_last_fetch_ts=EPOCHREALTIME - _p9k_worker_invoke gcloud "_p9k_prompt_gcloud_compute ${(q)commands[gcloud]} ${(q)P9K_GCLOUD_CONFIGURATION} ${(q)P9K_GCLOUD_ACCOUNT} ${(q)P9K_GCLOUD_PROJECT_ID}" -} - -_p9k_prompt_gcloud_init() { - _p9k__async_segments_compute+=_p9k_gcloud_prefetch - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[gcloud]' -} - -_p9k_prompt_gcloud_compute() { - local gcloud=$1 - P9K_GCLOUD_CONFIGURATION=$2 - P9K_GCLOUD_ACCOUNT=$3 - P9K_GCLOUD_PROJECT_ID=$4 - _p9k_worker_async "_p9k_prompt_gcloud_async ${(q)gcloud}" _p9k_prompt_gcloud_sync -} - -_p9k_prompt_gcloud_async() { - local gcloud=$1 - $gcloud projects describe $P9K_GCLOUD_PROJECT_ID --configuration=$P9K_GCLOUD_CONFIGURATION \ - --account=$P9K_GCLOUD_ACCOUNT --format='value(name)' -} - -_p9k_prompt_gcloud_sync() { - _p9k_worker_reply "_p9k_prompt_gcloud_update ${(q)P9K_GCLOUD_CONFIGURATION} ${(q)P9K_GCLOUD_ACCOUNT} ${(q)P9K_GCLOUD_PROJECT_ID} ${(q)REPLY%$'\n'}" -} - -_p9k_prompt_gcloud_update() { - [[ $1 == $P9K_GCLOUD_CONFIGURATION && - $2 == $P9K_GCLOUD_ACCOUNT && - $3 == $P9K_GCLOUD_PROJECT_ID && - $4 != $P9K_GCLOUD_PROJECT_NAME ]] || return - [[ -n $4 ]] && P9K_GCLOUD_PROJECT_NAME=$4 || unset P9K_GCLOUD_PROJECT_NAME - _p9k_gcloud_project_name=$P9K_GCLOUD_PROJECT_NAME - _p9k__state_dump_scheduled=1 - reset=1 -} - -prompt_google_app_cred() { - unset P9K_GOOGLE_APP_CRED_{TYPE,PROJECT_ID,CLIENT_EMAIL} - - if ! _p9k_cache_stat_get $0 $GOOGLE_APPLICATION_CREDENTIALS; then - local -a lines - local q='[.type//"", .project_id//"", .client_email//"", 0][]' - if lines=("${(@f)$(jq -r $q <$GOOGLE_APPLICATION_CREDENTIALS 2>/dev/null)}") && (( $#lines == 4 )); then - local text="${(j.:.)lines[1,-2]}" - local pat class state - for pat class in "${_POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES[@]}"; do - if [[ $text == ${~pat} ]]; then - [[ -n $class ]] && state=_${${(U)class}//İ/I} - break - fi - done - _p9k_cache_stat_set 1 "${(@)lines[1,-2]}" "$text" "$state" - else - _p9k_cache_stat_set 0 - fi - fi - - (( _p9k__cache_val[1] )) || return - P9K_GOOGLE_APP_CRED_TYPE=$_p9k__cache_val[2] - P9K_GOOGLE_APP_CRED_PROJECT_ID=$_p9k__cache_val[3] - P9K_GOOGLE_APP_CRED_CLIENT_EMAIL=$_p9k__cache_val[4] - _p9k_prompt_segment "$0$_p9k__cache_val[6]" "blue" "white" "GCLOUD_ICON" 0 '' "$_p9k__cache_val[5]" -} - -_p9k_prompt_google_app_cred_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${GOOGLE_APPLICATION_CREDENTIALS:+$commands[jq]}' -} - -typeset -gra __p9k_nordvpn_tag=( - P9K_NORDVPN_STATUS - P9K_NORDVPN_TECHNOLOGY - P9K_NORDVPN_PROTOCOL - P9K_NORDVPN_IP_ADDRESS - P9K_NORDVPN_SERVER - P9K_NORDVPN_COUNTRY - P9K_NORDVPN_CITY -) - -function _p9k_fetch_nordvpn_status() { - setopt err_return no_multi_byte - local REPLY - zsocket /run/nordvpn/nordvpnd.sock - local -i fd=REPLY - { - print -nu $fd 'PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n\0\0\0\4\1\0\0\0\0\0\0;\1\4\0\0\0\1\203\206E\213b\270\327\2762\322z\230\326j\246A\206\240\344\35\23\235\t_\213\35u\320b\r&=LMedz\212\232\312\310\264\307`+\262\332\340@\2te\206M\2035\5\261\37\0\0\5\0\1\0\0\0\1\0\0\0\0\0\0\0\25\1\4\0\0\0\3\203\206E\215b\270\327\2762\322z\230\334\221\246\324\177\302\301\300\277\0\0\5\0\1\0\0\0\3\0\0\0\0\0' - local val - local -i len n wire tag - { - IFS='' read -t 0.25 -r val - val=$'\n' - while true; do - tag=$((#val)) - wire='tag & 7' - (( (tag >>= 3) && tag <= $#__p9k_nordvpn_tag )) || break - if (( wire == 0 )); then - # varint - sysread -s 1 -t 0.25 val - n=$((#val)) - (( n < 128 )) || break # bail on multi-byte varints - if (( tag == 2 )); then - # P9K_NORDVPN_TECHNOLOGY - case $n in - 1) typeset -g P9K_NORDVPN_TECHNOLOGY=OPENVPN;; - 2) typeset -g P9K_NORDVPN_TECHNOLOGY=NORDLYNX;; - 3) typeset -g P9K_NORDVPN_TECHNOLOGY=SKYLARK;; - *) typeset -g P9K_NORDVPN_TECHNOLOGY=UNKNOWN;; - esac - elif (( tag == 3 )); then - # P9K_NORDVPN_PROTOCOL - case $n in - 1) typeset -g P9K_NORDVPN_PROTOCOL=UDP;; - 2) typeset -g P9K_NORDVPN_PROTOCOL=TCP;; - *) typeset -g P9K_NORDVPN_PROTOCOL=UNKNOWN;; - esac - else - break - fi - else - # length-delimited - (( wire == 2 )) || break - (( tag != 2 && tag != 3 )) || break - [[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html - sysread -s 1 -t 0.25 val - len=$((#val)) - val= - while (( $#val < len )); do - [[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html - sysread -s $(( len - $#val )) -t 0.25 'val[$#val+1]' - done - typeset -g $__p9k_nordvpn_tag[tag]=$val - fi - [[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html - sysread -s 1 -t 0.25 val - done - } <&$fd - } always { - exec {fd}>&- - } -} - -# Shows the state of NordVPN connection. Works only on Linux. Can be in the following 5 states. -# -# CONNECTED: NordVPN is connected. By default shows NORDVPN_ICON as icon and country code as -# content. In addition, the following variables are set for the use by -# POWERLEVEL9K_NORDVPN_CONNECTED_VISUAL_IDENTIFIER_EXPANSION and -# POWERLEVEL9K_NORDVPN_CONNECTED_CONTENT_EXPANSION: -# -# - P9K_NORDVPN_STATUS -# - P9K_NORDVPN_PROTOCOL -# - P9K_NORDVPN_TECHNOLOGY -# - P9K_NORDVPN_IP_ADDRESS -# - P9K_NORDVPN_SERVER -# - P9K_NORDVPN_COUNTRY -# - P9K_NORDVPN_CITY -# - P9K_NORDVPN_COUNTRY_CODE -# -# The last variable is trivially derived from P9K_NORDVPN_SERVER. The rest correspond to the output -# lines of `nordvpn status` command. Example of using these variables: -# -# # Display the name of the city where VPN servers are located when connected to NordVPN. -# POWERLEVEL9K_NORDVPN_CONNECTED_CONTENT_EXPANSION='${P9K_NORDVPN_CITY}' -# -# DISCONNECTED, CONNECTING, DISCONNECTING: NordVPN is disconnected/connecting/disconnecting. By -# default shows NORDVPN_ICON as icon and FAIL_ICON as content. In state CONNECTING the same -# P9K_NORDVPN_* variables are set as in CONNECTED. In states DISCONNECTED and DISCONNECTING only -# P9K_NORDVPN_STATUS is set. Example customizations: -# -# # Hide NordVPN segment when disconnected (segments with no icon and no content are not shown). -# POWERLEVEL9K_NORDVPN_DISCONNECTED_CONTENT_EXPANSION= -# POWERLEVEL9K_NORDVPN_DISCONNECTED_VISUAL_IDENTIFIER_EXPANSION= -# -# # When NordVPN is connecting, show country code on cyan background. -# POWERLEVEL9K_NORDVPN_CONNECTING_CONTENT_EXPANSION='${P9K_NORDVPN_COUNTRY_CODE}' -# POWERLEVEL9K_NORDVPN_CONNECTING_BACKGROUND=cyan -function prompt_nordvpn() { - unset $__p9k_nordvpn_tag P9K_NORDVPN_COUNTRY_CODE - [[ -e /run/nordvpn/nordvpnd.sock ]] || return - _p9k_fetch_nordvpn_status 2>/dev/null || return - if [[ $P9K_NORDVPN_SERVER == (#b)([[:alpha:]]##)[[:digit:]]##.nordvpn.com ]]; then - typeset -g P9K_NORDVPN_COUNTRY_CODE=${${(U)match[1]}//İ/I} - fi - case $P9K_NORDVPN_STATUS in - Connected) - _p9k_prompt_segment $0_CONNECTED blue white NORDVPN_ICON 0 '' "$P9K_NORDVPN_COUNTRY_CODE" - ;; - Disconnected|Connecting|Disconnecting) - local state=${${(U)P9K_NORDVPN_STATUS}//İ/I} - _p9k_get_icon $0_$state FAIL_ICON - _p9k_prompt_segment $0_$state yellow white NORDVPN_ICON 0 '' "$_p9k__ret" - ;; - *) - return - ;; - esac -} - -_p9k_prompt_nordvpn_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[nordvpn]' -} - -function prompt_ranger() { - _p9k_prompt_segment $0 $_p9k_color1 yellow RANGER_ICON 0 '' $RANGER_LEVEL -} - -_p9k_prompt_ranger_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$RANGER_LEVEL' -} - -function instant_prompt_ranger() { - _p9k_prompt_segment prompt_ranger $_p9k_color1 yellow RANGER_ICON 1 '$RANGER_LEVEL' '$RANGER_LEVEL' -} - -function prompt_midnight_commander() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 $_p9k_color1 yellow MIDNIGHT_COMMANDER_ICON 0 '' '' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_midnight_commander_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$MC_TMPDIR' -} - -function instant_prompt_midnight_commander() { - _p9k_prompt_segment prompt_midnight_commander $_p9k_color1 yellow MIDNIGHT_COMMANDER_ICON 0 '$MC_TMPDIR' '' -} - -function prompt_nnn() { - _p9k_prompt_segment $0 6 $_p9k_color1 NNN_ICON 0 '' $NNNLVL -} - -_p9k_prompt_nnn_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${NNNLVL:#0}' -} - -function instant_prompt_nnn() { - _p9k_prompt_segment prompt_nnn 6 $_p9k_color1 NNN_ICON 1 '${NNNLVL:#0}' '$NNNLVL' -} - -function prompt_xplr() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 6 $_p9k_color1 XPLR_ICON 0 '' '' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_xplr_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$XPLR_PID' -} - -function instant_prompt_xplr() { - _p9k_prompt_segment prompt_xplr 6 $_p9k_color1 XPLR_ICON 0 '$XPLR_PID' '' -} - -function prompt_vim_shell() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 green $_p9k_color1 VIM_ICON 0 '' '' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_vim_shell_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$VIMRUNTIME' -} - -function instant_prompt_vim_shell() { - _p9k_prompt_segment prompt_vim_shell green $_p9k_color1 VIM_ICON 0 '$VIMRUNTIME' '' -} - -function prompt_nix_shell() { - _p9k_prompt_segment $0 4 $_p9k_color1 NIX_SHELL_ICON 0 '' "${(M)IN_NIX_SHELL:#(pure|impure)}" -} - -_p9k_prompt_nix_shell_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${IN_NIX_SHELL:#0}' -} - -function instant_prompt_nix_shell() { - _p9k_prompt_segment prompt_nix_shell 4 $_p9k_color1 NIX_SHELL_ICON 1 '${IN_NIX_SHELL:#0}' '${(M)IN_NIX_SHELL:#(pure|impure)}' -} - -function prompt_terraform() { - local ws=$TF_WORKSPACE - if [[ -z $TF_WORKSPACE ]]; then - _p9k_read_word ${${TF_DATA_DIR:-.terraform}:A}/environment && ws=$_p9k__ret - fi - [[ -z $ws || $ws == default && $_POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT == 0 ]] && return - local pat class state - for pat class in "${_POWERLEVEL9K_TERRAFORM_CLASSES[@]}"; do - if [[ $ws == ${~pat} ]]; then - [[ -n $class ]] && state=_${${(U)class}//İ/I} - break - fi - done - _p9k_prompt_segment "$0$state" $_p9k_color1 blue TERRAFORM_ICON 0 '' $ws -} - -_p9k_prompt_terraform_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[terraform]' -} - -function prompt_terraform_version() { - _p9k_cached_cmd 0 '' terraform --version || return - local v=${_p9k__ret#Terraform v} - (( $#v < $#_p9k__ret )) || return - v=${v%%$'\n'*} - [[ -n $v ]] || return - _p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' $v -} - -_p9k_prompt_terraform_version_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[terraform]' -} - -function prompt_proxy() { - local -U p=( - $all_proxy $http_proxy $https_proxy $ftp_proxy - $ALL_PROXY $HTTP_PROXY $HTTPS_PROXY $FTP_PROXY) - p=(${(@)${(@)${(@)p#*://}##*@}%%/*}) - (( $#p == 1 )) || p=("") - _p9k_prompt_segment $0 $_p9k_color1 blue PROXY_ICON 0 '' "$p[1]" -} - -_p9k_prompt_proxy_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$all_proxy$http_proxy$https_proxy$ftp_proxy$ALL_PROXY$HTTP_PROXY$HTTPS_PROXY$FTP_PROXY' -} - -function prompt_direnv() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 $_p9k_color1 yellow DIRENV_ICON 0 '${DIRENV_DIR-}' '' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_direnv_init() { - # DIRENV_DIR is set in a precmd hook. If our hook isn't the last, DIRENV_DIR might - # still get set before prompt is expanded. - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${DIRENV_DIR-${precmd_functions[-1]:#_p9k_precmd}}' -} - -function instant_prompt_direnv() { - if [[ -n ${DIRENV_DIR:-} && $precmd_functions[-1] == _p9k_precmd ]]; then - _p9k_prompt_segment prompt_direnv $_p9k_color1 yellow DIRENV_ICON 0 '' '' - fi -} - -function _p9k_timewarrior_clear() { - [[ -z $_p9k_timewarrior_dir ]] && return - _p9k_timewarrior_dir= - _p9k_timewarrior_dir_mtime=0 - _p9k_timewarrior_file_mtime=0 - _p9k_timewarrior_file_name= - unset _p9k_timewarrior_tags - _p9k__state_dump_scheduled=1 -} - -function prompt_timewarrior() { - local -a stat - local dir=${TIMEWARRIORDB:-~/.timewarrior}/data - [[ $dir == $_p9k_timewarrior_dir ]] || _p9k_timewarrior_clear - if [[ -n $_p9k_timewarrior_file_name ]]; then - zstat -A stat +mtime -- $dir $_p9k_timewarrior_file_name 2>/dev/null || stat=() - if [[ $stat[1] == $_p9k_timewarrior_dir_mtime && $stat[2] == $_p9k_timewarrior_file_mtime ]]; then - if (( $+_p9k_timewarrior_tags )); then - _p9k_prompt_segment $0 grey 255 TIMEWARRIOR_ICON 0 '' "${_p9k_timewarrior_tags//\%/%%}" - fi - return - fi - fi - if [[ ! -d $dir ]]; then - _p9k_timewarrior_clear - return - fi - _p9k_timewarrior_dir=$dir - if [[ $stat[1] != $_p9k_timewarrior_dir_mtime ]]; then - local -a files=($dir/<->-<->.data(.N)) - if (( ! $#files )); then - if (( $#stat )) || zstat -A stat +mtime -- $dir 2>/dev/null; then - _p9k_timewarrior_dir_mtime=$stat[1] - _p9k_timewarrior_file_mtime=$stat[1] - _p9k_timewarrior_file_name=$dir # sic - unset _p9k_timewarrior_tags - _p9k__state_dump_scheduled=1 - else - _p9k_timewarrior_clear - fi - return - fi - _p9k_timewarrior_file_name=${${(AO)files}[1]} - fi - if ! zstat -A stat +mtime -- $dir $_p9k_timewarrior_file_name 2>/dev/null; then - _p9k_timewarrior_clear - return - fi - _p9k_timewarrior_dir_mtime=$stat[1] - _p9k_timewarrior_file_mtime=$stat[2] - { local tail=${${(Af)"$(<$_p9k_timewarrior_file_name)"}[-1]} } 2>/dev/null - if [[ $tail == (#b)'inc '[^\ ]##(|\ #\#(*)) ]]; then - _p9k_timewarrior_tags=${${match[2]## #}%% #} - _p9k_prompt_segment $0 grey 255 TIMEWARRIOR_ICON 0 '' "${_p9k_timewarrior_tags//\%/%%}" - else - unset _p9k_timewarrior_tags - fi - _p9k__state_dump_scheduled=1 -} - -function _p9k_prompt_timewarrior_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[timew]' -} - -function _p9k_taskwarrior_check_meta() { - [[ -n $_p9k_taskwarrior_meta_sig ]] || return - [[ -z $^_p9k_taskwarrior_meta_non_files(#qN) ]] || return - local -a stat - if (( $#_p9k_taskwarrior_meta_files )); then - zstat -A stat +mtime -- $_p9k_taskwarrior_meta_files 2>/dev/null || return - fi - [[ $_p9k_taskwarrior_meta_sig == ${(pj:\0:)stat}$'\0'$TASKRC$'\0'$TASKDATA ]] || return -} - -function _p9k_taskwarrior_init_meta() { - local last_sig=$_p9k_taskwarrior_meta_sig - { - local cfg - cfg="$(command task show data.location rc.color=0 rc._forcecolor=0 </dev/null 2>/dev/null)" || return - local lines=(${(@M)${(f)cfg}:#data.location[[:space:]]##[^[:space:]]*}) - (( $#lines == 1 )) || return - local dir=${lines[1]##data.location[[:space:]]#} - : ${dir::=$~dir} # `task` can give us path with `~`` in it; expand it - - local -a stat files=(${TASKRC:-~/.taskrc}) - _p9k_taskwarrior_meta_files=($^files(N)) - _p9k_taskwarrior_meta_non_files=(${files:|_p9k_taskwarrior_meta_files}) - if (( $#_p9k_taskwarrior_meta_files )); then - zstat -A stat +mtime -- $_p9k_taskwarrior_meta_files 2>/dev/null || stat=(-1) - fi - _p9k_taskwarrior_meta_sig=${(pj:\0:)stat}$'\0'$TASKRC$'\0'$TASKDATA - _p9k_taskwarrior_data_dir=$dir - } always { - if (( $? == 0 )); then - _p9k__state_dump_scheduled=1 - return - fi - [[ -n $last_sig ]] && _p9k__state_dump_scheduled=1 - _p9k_taskwarrior_meta_files=() - _p9k_taskwarrior_meta_non_files=() - _p9k_taskwarrior_meta_sig= - _p9k_taskwarrior_data_dir= - _p9k__taskwarrior_functional= - } -} - -function _p9k_taskwarrior_check_data() { - [[ -n $_p9k_taskwarrior_data_sig ]] || return - [[ -z $^_p9k_taskwarrior_data_non_files(#qN) ]] || return - local -a stat - if (( $#_p9k_taskwarrior_data_files )); then - zstat -A stat +mtime -- $_p9k_taskwarrior_data_files 2>/dev/null || return - fi - [[ $_p9k_taskwarrior_data_sig == ${(pj:\0:)stat}$'\0'$TASKRC$'\0'$TASKDATA ]] || return - (( _p9k_taskwarrior_next_due == 0 || _p9k_taskwarrior_next_due > EPOCHSECONDS )) || return -} - -function _p9k_taskwarrior_init_data() { - local -a stat files=($_p9k_taskwarrior_data_dir/{pending,completed}.data) - _p9k_taskwarrior_data_files=($^files(N)) - _p9k_taskwarrior_data_non_files=(${files:|_p9k_taskwarrior_data_files}) - if (( $#_p9k_taskwarrior_data_files )); then - zstat -A stat +mtime -- $_p9k_taskwarrior_data_files 2>/dev/null || stat=(-1) - _p9k_taskwarrior_data_sig=${(pj:\0:)stat}$'\0' - else - _p9k_taskwarrior_data_sig= - fi - - _p9k_taskwarrior_data_files+=($_p9k_taskwarrior_meta_files) - _p9k_taskwarrior_data_non_files+=($_p9k_taskwarrior_meta_non_files) - _p9k_taskwarrior_data_sig+=$_p9k_taskwarrior_meta_sig - - local name val - for name in PENDING OVERDUE; do - val="$(command task +$name count rc.color=0 rc._forcecolor=0 </dev/null 2>/dev/null)" || continue - [[ $val == <1-> ]] || continue - _p9k_taskwarrior_counters[$name]=$val - done - - _p9k_taskwarrior_next_due=0 - - if (( _p9k_taskwarrior_counters[PENDING] > _p9k_taskwarrior_counters[OVERDUE] )); then - local -a ts - ts=($(command task +PENDING -OVERDUE list rc.verbose=nothing rc.color=0 rc._forcecolor=0 \ - rc.report.list.labels= rc.report.list.columns=due.epoch </dev/null 2>/dev/null)) || ts=() - if (( $#ts )); then - _p9k_taskwarrior_next_due=${${(on)ts}[1]} - (( _p9k_taskwarrior_next_due > EPOCHSECONDS )) || _p9k_taskwarrior_next_due=$((EPOCHSECONDS+60)) - fi - fi - - _p9k__state_dump_scheduled=1 -} - -function prompt_taskwarrior() { - unset P9K_TASKWARRIOR_PENDING_COUNT P9K_TASKWARRIOR_OVERDUE_COUNT - if ! _p9k_taskwarrior_check_data; then - _p9k_taskwarrior_data_files=() - _p9k_taskwarrior_data_non_files=() - _p9k_taskwarrior_data_sig= - _p9k_taskwarrior_counters=() - _p9k_taskwarrior_next_due=0 - _p9k_taskwarrior_check_meta || _p9k_taskwarrior_init_meta || return - _p9k_taskwarrior_init_data - fi - (( $#_p9k_taskwarrior_counters )) || return - local text c=$_p9k_taskwarrior_counters[OVERDUE] - if [[ -n $c ]]; then - typeset -g P9K_TASKWARRIOR_OVERDUE_COUNT=$c - text+="!$c" - fi - c=$_p9k_taskwarrior_counters[PENDING] - if [[ -n $c ]]; then - typeset -g P9K_TASKWARRIOR_PENDING_COUNT=$c - [[ -n $text ]] && text+='/' - text+=$c - fi - [[ -n $text ]] || return - _p9k_prompt_segment $0 6 $_p9k_color1 TASKWARRIOR_ICON 0 '' $text -} - -function _p9k_prompt_taskwarrior_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[task]:+$_p9k__taskwarrior_functional}' -} - -prompt_wifi() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 green $_p9k_color1 WIFI_ICON 1 '$_p9k__wifi_on' '$P9K_WIFI_LAST_TX_RATE Mbps' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_wifi_init() { - if [[ -x /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport || - -r /proc/net/wireless && -n $commands[iw] ]]; then - typeset -g _p9k__wifi_on= - typeset -g P9K_WIFI_LAST_TX_RATE= - typeset -g P9K_WIFI_SSID= - typeset -g P9K_WIFI_LINK_AUTH= - typeset -g P9K_WIFI_RSSI= - typeset -g P9K_WIFI_NOISE= - typeset -g P9K_WIFI_BARS= - _p9k__async_segments_compute+='_p9k_worker_invoke wifi _p9k_prompt_wifi_compute' - else - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${:-}' - fi -} - -_p9k_prompt_wifi_compute() { - _p9k_worker_async _p9k_prompt_wifi_async _p9k_prompt_wifi_sync -} - -_p9k_prompt_wifi_async() { - local airport=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport - local last_tx_rate ssid link_auth rssi noise bars on out line v state iface - { - if [[ -x $airport ]]; then - out="$($airport -I)" || return 0 - for line in ${${${(f)out}##[[:space:]]#}%%[[:space:]]#}; do - v=${line#*: } - case $line[1,-$#v-3] in - agrCtlRSSI) rssi=$v;; - agrCtlNoise) noise=$v;; - state) state=$v;; - lastTxRate) last_tx_rate=$v;; - link\ auth) link_auth=$v;; - SSID) ssid=$v;; - esac - done - [[ $state == running && $rssi == (0|-<->) && $noise == (0|-<->) ]] || return 0 - elif [[ -r /proc/net/wireless && -n $commands[iw] ]]; then - # Content example (https://github.com/romkatv/powerlevel10k/pull/973#issuecomment-680251804): - # - # Inter-| sta-| Quality | Discarded packets | Missed | WE - # face | tus | link level noise | nwid crypt frag retry misc | beacon | 22 - # wlp3s0: 0000 58. -52. -256 0 0 0 0 76 0 - local -a lines - lines=(${${(f)"$(</proc/net/wireless)"}:#*\|*}) || return 0 - (( $#lines == 1 )) || return 0 - local parts=(${=lines[1]}) - iface=${parts[1]%:} - state=${parts[2]} - rssi=${parts[4]%.*} - noise=${parts[5]%.*} - [[ -n $iface && $state == 0## && $rssi == (0|-<->) && $noise == (0|-<->) ]] || return 0 - # Output example (https://github.com/romkatv/powerlevel10k/pull/973#issuecomment-680251804): - # - # Connected to 74:83:c2:be:76:da (on wlp3s0) - # SSID: DailyGrindGuest1 - # freq: 5745 - # RX: 35192066 bytes (27041 packets) - # TX: 4090471 bytes (24287 packets) - # signal: -52 dBm - # rx bitrate: 243.0 MBit/s VHT-MCS 6 40MHz VHT-NSS 2 - # tx bitrate: 240.0 MBit/s VHT-MCS 5 40MHz short GI VHT-NSS 2 - # - # bss flags: short-slot-time - # dtim period: 1 - # beacon int: 100 - lines=(${(f)"$(command iw dev $iface link)"}) || return 0 - local -a match mbegin mend - for line in $lines; do - if [[ $line == (#b)[[:space:]]#SSID:[[:space:]]##(*) ]]; then - ssid=$match[1] - elif [[ $line == (#b)[[:space:]]#'tx bitrate:'[[:space:]]##([^[:space:]]##)' MBit/s'* ]]; then - last_tx_rate=$match[1] - [[ $last_tx_rate == <->.<-> ]] && last_tx_rate=${${last_tx_rate%%0#}%.} - fi - done - [[ -n $ssid && -n $last_tx_rate ]] || return 0 - else - return 0 - fi - # https://www.speedguide.net/faq/how-to-read-rssisignal-and-snrnoise-ratings-440 - # http://www.wireless-nets.com/resources/tutorials/define_SNR_values.html - local -i snr_margin='rssi - noise' - if (( snr_margin >= 40 )); then - bars=4 - elif (( snr_margin >= 25 )); then - bars=3 - elif (( snr_margin >= 15 )); then - bars=2 - elif (( snr_margin >= 10 )); then - bars=1 - else - bars=0 - fi - on=1 - } always { - if (( ! on )); then - rssi= - noise= - ssid= - last_tx_rate= - bars= - link_auth= - fi - if [[ $_p9k__wifi_on != $on || - $P9K_WIFI_LAST_TX_RATE != $last_tx_rate || - $P9K_WIFI_SSID != $ssid || - $P9K_WIFI_LINK_AUTH != $link_auth || - $P9K_WIFI_RSSI != $rssi || - $P9K_WIFI_NOISE != $noise || - $P9K_WIFI_BARS != $bars ]]; then - _p9k__wifi_on=$on - P9K_WIFI_LAST_TX_RATE=$last_tx_rate - P9K_WIFI_SSID=$ssid - P9K_WIFI_LINK_AUTH=$link_auth - P9K_WIFI_RSSI=$rssi - P9K_WIFI_NOISE=$noise - P9K_WIFI_BARS=$bars - _p9k_print_params \ - _p9k__wifi_on \ - P9K_WIFI_LAST_TX_RATE \ - P9K_WIFI_SSID \ - P9K_WIFI_LINK_AUTH \ - P9K_WIFI_RSSI \ - P9K_WIFI_NOISE \ - P9K_WIFI_BARS - echo -E - 'reset=1' - fi - } -} - -_p9k_prompt_wifi_sync() { - if [[ -n $REPLY ]]; then - eval $REPLY - _p9k_worker_reply $REPLY - fi -} - -function _p9k_asdf_check_meta() { - [[ -n $_p9k_asdf_meta_sig ]] || return - [[ -z $^_p9k_asdf_meta_non_files(#qN) ]] || return - local -a stat - if (( $#_p9k_asdf_meta_files )); then - zstat -A stat +mtime -- $_p9k_asdf_meta_files 2>/dev/null || return - fi - [[ $_p9k_asdf_meta_sig == $ASDF_CONFIG_FILE$'\0'$ASDF_DATA_DIR$'\0'${(pj:\0:)stat} ]] || return -} - -function _p9k_asdf_init_meta() { - local last_sig=$_p9k_asdf_meta_sig - { - local -a files - local -i legacy_enabled - - _p9k_asdf_plugins=() - _p9k_asdf_file_info=() - - local cfg=${ASDF_CONFIG_FILE:-~/.asdfrc} - files+=$cfg - if [[ -f $cfg && -r $cfg ]]; then - # Config parser in adsf is very strange. - # - # This gives "yes": - # - # legacy_version_file = yes = no - # - # This gives "no": - # - # legacy_version_file = yes - # legacy_version_file = yes - # - # We do the same. - local lines=(${(@M)${(@)${(f)"$(<$cfg)"}%$'\r'}:#[[:space:]]#legacy_version_file[[:space:]]#=*}) - if [[ $#lines == 1 && ${${(s:=:)lines[1]}[2]} == [[:space:]]#yes[[:space:]]# ]]; then - legacy_enabled=1 - fi - fi - - local root=${ASDF_DATA_DIR:-~/.asdf} - files+=$root/plugins - if [[ -d $root/plugins ]]; then - local plugin - for plugin in $root/plugins/[^[:space:]]##(/N); do - files+=$root/installs/${plugin:t} - local -aU installed=($root/installs/${plugin:t}/[^[:space:]]##(/N:t) system) - _p9k_asdf_plugins[${plugin:t}]=${(j:|:)${(@b)installed}} - (( legacy_enabled )) || continue - if [[ ! -e $plugin/bin ]]; then - files+=$plugin/bin - else - local list_names=$plugin/bin/list-legacy-filenames - files+=$list_names - if [[ -x $list_names ]]; then - local parse=$plugin/bin/parse-legacy-file - local -i has_parse=0 - files+=$parse - [[ -x $parse ]] && has_parse=1 - local name - for name in ${$($list_names 2>/dev/null)%$'\r'}; do - [[ $name == (*/*|.tool-versions) ]] && continue - _p9k_asdf_file_info[$name]+="${plugin:t} $has_parse " - done - fi - fi - done - fi - - _p9k_asdf_meta_files=($^files(N)) - _p9k_asdf_meta_non_files=(${files:|_p9k_asdf_meta_files}) - - local -a stat - if (( $#_p9k_asdf_meta_files )); then - zstat -A stat +mtime -- $_p9k_asdf_meta_files 2>/dev/null || return - fi - _p9k_asdf_meta_sig=$ASDF_CONFIG_FILE$'\0'$ASDF_DATA_DIR$'\0'${(pj:\0:)stat} - _p9k__asdf_dir2files=() - _p9k_asdf_file2versions=() - } always { - if (( $? == 0 )); then - _p9k__state_dump_scheduled=1 - return - fi - [[ -n $last_sig ]] && _p9k__state_dump_scheduled=1 - _p9k_asdf_meta_files=() - _p9k_asdf_meta_non_files=() - _p9k_asdf_meta_sig= - _p9k_asdf_plugins=() - _p9k_asdf_file_info=() - _p9k__asdf_dir2files=() - _p9k_asdf_file2versions=() - } -} - -# Usage: _p9k_asdf_parse_version_file <file> <is_legacy> -# -# Mutates `versions` on success. -function _p9k_asdf_parse_version_file() { - local file=$1 - local is_legacy=$2 - local -a stat - zstat -A stat +mtime $file 2>/dev/null || return - if (( is_legacy )); then - local plugin has_parse - for plugin has_parse in $=_p9k_asdf_file_info[$file:t]; do - local cached=$_p9k_asdf_file2versions[$plugin:$file] - if [[ $cached == $stat[1]:* ]]; then - local v=${cached#*:} - else - if (( has_parse )); then - local v=($(${ASDF_DATA_DIR:-~/.asdf}/plugins/$plugin/bin/parse-legacy-file $file 2>/dev/null)) - else - { local v=($(<$file)) } 2>/dev/null - fi - v=(${v%$'\r'}) - v=${v[(r)$_p9k_asdf_plugins[$plugin]]:-$v[1]} - _p9k_asdf_file2versions[$plugin:$file]=$stat[1]:"$v" - _p9k__state_dump_scheduled=1 - fi - [[ -n $v ]] && : ${versions[$plugin]="$v"} - done - else - local cached=$_p9k_asdf_file2versions[:$file] - if [[ $cached == $stat[1]:* ]]; then - local file_versions=(${(0)${cached#*:}}) - else - local file_versions=() - { local lines=(${(@)${(@)${(f)"$(<$file)"}%$'\r'}/\#*}) } 2>/dev/null - local line - for line in $lines; do - local words=($=line) - (( $#words > 1 )) || continue - local installed=$_p9k_asdf_plugins[$words[1]] - [[ -n $installed ]] || continue - file_versions+=($words[1] ${${words:1}[(r)$installed]:-$words[2]}) - done - _p9k_asdf_file2versions[:$file]=$stat[1]:${(pj:\0:)file_versions} - _p9k__state_dump_scheduled=1 - fi - local plugin version - for plugin version in $file_versions; do - : ${versions[$plugin]=$version} - done - fi - return 0 -} - -function prompt_asdf() { - _p9k_asdf_check_meta || _p9k_asdf_init_meta || return - - local -A versions - local -a stat - local -i has_global - local dirs=($_p9k__parent_dirs) - local mtimes=($_p9k__parent_mtimes) - if [[ $dirs[-1] != ~ ]]; then - zstat -A stat +mtime ~ 2>/dev/null || return - dirs+=(~) - mtimes+=($stat[1]) - fi - - local elem - for elem in ${(@)${:-{1..$#dirs}}/(#m)*/${${:-$MATCH:$_p9k__asdf_dir2files[$dirs[MATCH]]}#$MATCH:$mtimes[MATCH]:}}; do - if [[ $elem == *:* ]]; then - local dir=$dirs[${elem%%:*}] - zstat -A stat +mtime $dir 2>/dev/null || return - local files=($dir/.tool-versions(N) $dir/${(k)^_p9k_asdf_file_info}(N)) - _p9k__asdf_dir2files[$dir]=$stat[1]:${(pj:\0:)files} - else - local files=(${(0)elem}) - fi - if [[ ${files[1]:h} == ~ ]]; then - has_global=1 - local -A local_versions=(${(kv)versions}) - versions=() - fi - local file - for file in $files; do - [[ $file == */.tool-versions ]] - _p9k_asdf_parse_version_file $file $? || return - done - done - - if (( ! has_global )); then - has_global=1 - local -A local_versions=(${(kv)versions}) - versions=() - fi - - if [[ -r $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME ]]; then - _p9k_asdf_parse_version_file $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME 0 || return - fi - - local plugin - for plugin in ${(k)_p9k_asdf_plugins}; do - local upper=${${(U)plugin//-/_}//İ/I} - if (( $+parameters[_POWERLEVEL9K_ASDF_${upper}_SOURCES] )); then - local sources=(${(P)${:-_POWERLEVEL9K_ASDF_${upper}_SOURCES}}) - else - local sources=($_POWERLEVEL9K_ASDF_SOURCES) - fi - - local version="${(P)${:-ASDF_${upper}_VERSION}}" - if [[ -n $version ]]; then - (( $sources[(I)shell] )) || continue - else - version=$local_versions[$plugin] - if [[ -n $version ]]; then - (( $sources[(I)local] )) || continue - else - version=$versions[$plugin] - [[ -n $version ]] || continue - (( $sources[(I)global] )) || continue - fi - fi - - if [[ $version == $versions[$plugin] ]]; then - if (( $+parameters[_POWERLEVEL9K_ASDF_${upper}_PROMPT_ALWAYS_SHOW] )); then - (( _POWERLEVEL9K_ASDF_${upper}_PROMPT_ALWAYS_SHOW )) || continue - else - (( _POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW )) || continue - fi - fi - - if [[ $version == system ]]; then - if (( $+parameters[_POWERLEVEL9K_ASDF_${upper}_SHOW_SYSTEM] )); then - (( _POWERLEVEL9K_ASDF_${upper}_SHOW_SYSTEM )) || continue - else - (( _POWERLEVEL9K_ASDF_SHOW_SYSTEM )) || continue - fi - fi - - _p9k_get_icon $0_$upper ${upper}_ICON $plugin - _p9k_prompt_segment $0_$upper green $_p9k_color1 $'\1'$_p9k__ret 0 '' ${version//\%/%%} - done -} - -_p9k_prompt_asdf_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[asdf]:-${${+functions[asdf]}:#0}}' -} - -_p9k_haskell_stack_version() { - if ! _p9k_cache_stat_get $0 $1 ${STACK_ROOT:-~/.stack}/{pantry/pantry.sqlite3,stack.sqlite3}; then - local v - v="$(STACK_YAML=$1 stack \ - --silent \ - --no-install-ghc \ - --skip-ghc-check \ - --no-terminal \ - --color=never \ - --lock-file=read-only \ - query compiler actual)" || v= - _p9k_cache_stat_set "$v" - fi - _p9k__ret=$_p9k__cache_val[1] -} - -prompt_haskell_stack() { - if [[ -n $STACK_YAML ]]; then - (( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)shell]} )) || return - _p9k_haskell_stack_version $STACK_YAML - else - (( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)local|global]} )) || return - if _p9k_upglob stack.yaml; then - (( _POWERLEVEL9K_HASKELL_STACK_PROMPT_ALWAYS_SHOW )) || return - (( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)global]} )) || return - _p9k_haskell_stack_version ${STACK_ROOT:-~/.stack}/global-project/stack.yaml - else - local -i idx=$? - (( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)local]} )) || return - _p9k_haskell_stack_version $_p9k__parent_dirs[idx]/stack.yaml - fi - fi - - [[ -n $_p9k__ret ]] || return - - local v=$_p9k__ret - - if (( !_POWERLEVEL9K_HASKELL_STACK_PROMPT_ALWAYS_SHOW )); then - _p9k_haskell_stack_version ${STACK_ROOT:-~/.stack}/global-project/stack.yaml - [[ $v == $_p9k__ret ]] && return - fi - - _p9k_prompt_segment "$0" "yellow" "$_p9k_color1" 'HASKELL_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_haskell_stack_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[stack]' -} - -################################################################ -# CPU Architecture -prompt_cpu_arch() { - local -i len=$#_p9k__prompt _p9k__has_upglob - - local state text - if _p9k_cache_ephemeral_get $0; then - state=$_p9k__cache_val[1] - text=$_p9k__cache_val[2] - else - text=$(command arch) 2>/dev/null && [[ $text == [a-zA-Z][a-zA-Z0-9_]# ]] || text= - state=_${(U)text} - _p9k_cache_ephemeral_set "$state" "$text" - fi - if [[ -n $text ]]; then - _p9k_prompt_segment "$0$state" "yellow" "$_p9k_color1" 'ARCH_ICON' 0 '' "$text" - fi - - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_arch_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[arch]' -} - -# Use two preexec hooks to survive https://github.com/MichaelAquilina/zsh-you-should-use with -# YSU_HARDCORE=1. See https://github.com/romkatv/powerlevel10k/issues/427. -_p9k_preexec1() { - _p9k_restore_special_params - unset __p9k_trapint - trap - INT -} - -_p9k_preexec2() { - typeset -g _p9k__preexec_cmd=$2 - _p9k__timer_start=EPOCHREALTIME - P9K_TTY=old - (( ! $+_p9k__iterm_cmd )) || _p9k_iterm2_preexec -} - -function _p9k_prompt_net_iface_init() { - typeset -g _p9k__public_ip_vpn= - typeset -g _p9k__public_ip_not_vpn= - typeset -g P9K_IP_IP= - typeset -g P9K_IP_INTERFACE= - typeset -g P9K_IP_TX_BYTES= - typeset -g P9K_IP_RX_BYTES= - typeset -g P9K_IP_TX_BYTES_DELTA= - typeset -g P9K_IP_RX_BYTES_DELTA= - typeset -g P9K_IP_TX_RATE= - typeset -g P9K_IP_RX_RATE= - typeset -g _p9__ip_timestamp= - typeset -g _p9k__vpn_ip_ips=() - [[ -z $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]] && _p9k__public_ip_not_vpn=1 - _p9k__async_segments_compute+='_p9k_worker_invoke net_iface _p9k_prompt_net_iface_compute' -} - -# reads `iface2ip` and sets `ifaces` and `ips` -function _p9k_prompt_net_iface_match() { - local iface_regex="^($1)\$" iface ip - ips=() - ifaces=() - for iface ip in "${(@)iface2ip}"; do - [[ $iface =~ $iface_regex ]] || continue - ifaces+=$iface - ips+=$ip - done - return $(($#ips == 0)) -} - -function _p9k_prompt_net_iface_compute() { - _p9k_worker_async _p9k_prompt_net_iface_async _p9k_prompt_net_iface_sync -} - -function _p9k_prompt_net_iface_async() { - # netstat -inbI en0 - local iface ip line var - typeset -a iface2ip ips ifaces - if (( $+commands[ip] )); then - for line in ${(f)"$(command ip -4 a show 2>/dev/null)"}; do - if [[ $line == (#b)<->:[[:space:]]##([^:]##):[[:space:]]##\<([^\>]#)\>* ]]; then - [[ ,$match[2], == *,UP,* ]] && iface=$match[1] || iface= - elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then - iface2ip+=($iface $match[1]) - iface= - fi - done - elif (( $+commands[ifconfig] )); then - for line in ${(f)"$(command ifconfig 2>/dev/null)"}; do - if [[ $line == (#b)([^[:space:]]##):[[:space:]]##flags=([[:xdigit:]]##)'<'* ]]; then - [[ $match[2] == *[13579bdfBDF] ]] && iface=$match[1] || iface= - elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then - iface2ip+=($iface $match[1]) - iface= - fi - done - fi - - if _p9k_prompt_net_iface_match $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE; then - local public_ip_vpn=1 - local public_ip_not_vpn= - else - local public_ip_vpn= - local public_ip_not_vpn=1 - fi - if _p9k_prompt_net_iface_match $_POWERLEVEL9K_IP_INTERFACE; then - local ip_ip=$ips[1] ip_interface=$ifaces[1] ip_timestamp=$EPOCHREALTIME - local ip_tx_bytes ip_rx_bytes ip_tx_rate ip_rx_rate - if [[ $_p9k_os == (Linux|Android) ]]; then - if [[ -r /sys/class/net/$ifaces[1]/statistics/tx_bytes && - -r /sys/class/net/$ifaces[1]/statistics/rx_bytes ]]; then - _p9k_read_file /sys/class/net/$ifaces[1]/statistics/tx_bytes && - [[ $_p9k__ret == <-> ]] && ip_tx_bytes=$_p9k__ret && - _p9k_read_file /sys/class/net/$ifaces[1]/statistics/rx_bytes && - [[ $_p9k__ret == <-> ]] && ip_rx_bytes=$_p9k__ret || { ip_tx_bytes=; ip_rx_bytes=; } - fi - elif [[ $_p9k_os == (BSD|OSX) && $+commands[netstat] == 1 ]]; then - local -a lines - if lines=(${(f)"$(netstat -inbI $ifaces[1])"}); then - local header=($=lines[1]) - local -i rx_idx=$header[(Ie)Ibytes] - local -i tx_idx=$header[(Ie)Obytes] - if (( rx_idx && tx_idx )); then - ip_tx_bytes=0 - ip_rx_bytes=0 - for line in ${lines:1}; do - (( ip_rx_bytes += ${line[(w)rx_idx]} )) - (( ip_tx_bytes += ${line[(w)tx_idx]} )) - done - fi - fi - fi - if [[ -n $ip_rx_bytes ]]; then - if [[ $ip_ip == $P9K_IP_IP && $ifaces[1] == $P9K_IP_INTERFACE ]]; then - local -F t='ip_timestamp - _p9__ip_timestamp' - if (( t <= 0 )); then - ip_tx_rate=${P9K_IP_TX_RATE:-0 B/s} - ip_rx_rate=${P9K_IP_RX_RATE:-0 B/s} - else - _p9k_human_readable_bytes $(((ip_tx_bytes - P9K_IP_TX_BYTES) / t)) - [[ $_p9k__ret == *B ]] && ip_tx_rate="$_p9k__ret[1,-2] B/s" || ip_tx_rate="$_p9k__ret[1,-2] $_p9k__ret[-1]iB/s" - _p9k_human_readable_bytes $(((ip_rx_bytes - P9K_IP_RX_BYTES) / t)) - [[ $_p9k__ret == *B ]] && ip_rx_rate="$_p9k__ret[1,-2] B/s" || ip_rx_rate="$_p9k__ret[1,-2] $_p9k__ret[-1]iB/s" - fi - else - ip_tx_rate='0 B/s' - ip_rx_rate='0 B/s' - fi - fi - else - local ip_ip= ip_interface= ip_tx_bytes= ip_rx_bytes= ip_tx_rate= ip_rx_rate= ip_timestamp= - fi - if _p9k_prompt_net_iface_match $_POWERLEVEL9K_VPN_IP_INTERFACE; then - if (( _POWERLEVEL9K_VPN_IP_SHOW_ALL )); then - local vpn_ip_ips=($ips) - else - local vpn_ip_ips=($ips[1]) - fi - else - local vpn_ip_ips=() - fi - [[ $_p9k__public_ip_vpn == $public_ip_vpn && - $_p9k__public_ip_not_vpn == $public_ip_not_vpn && - $P9K_IP_IP == $ip_ip && - $P9K_IP_INTERFACE == $ip_interface && - $P9K_IP_TX_BYTES == $ip_tx_bytes && - $P9K_IP_RX_BYTES == $ip_rx_bytes && - $P9K_IP_TX_RATE == $ip_tx_rate && - $P9K_IP_RX_RATE == $ip_rx_rate && - "$_p9k__vpn_ip_ips" == "$vpn_ip_ips" ]] && return 1 - if [[ "$_p9k__vpn_ip_ips" == "$vpn_ip_ips" ]]; then - echo -n 0 - else - echo -n 1 - fi - _p9k__public_ip_vpn=$public_ip_vpn - _p9k__public_ip_not_vpn=$public_ip_not_vpn - P9K_IP_IP=$ip_ip - P9K_IP_INTERFACE=$ip_interface - if [[ -n $ip_tx_bytes && -n $P9K_IP_TX_BYTES ]]; then - P9K_IP_TX_BYTES_DELTA=$((ip_tx_bytes - P9K_IP_TX_BYTES)) - else - P9K_IP_TX_BYTES_DELTA= - fi - if [[ -n $ip_rx_bytes && -n $P9K_IP_RX_BYTES ]]; then - P9K_IP_RX_BYTES_DELTA=$((ip_rx_bytes - P9K_IP_RX_BYTES)) - else - P9K_IP_RX_BYTES_DELTA= - fi - P9K_IP_TX_BYTES=$ip_tx_bytes - P9K_IP_RX_BYTES=$ip_rx_bytes - P9K_IP_TX_RATE=$ip_tx_rate - P9K_IP_RX_RATE=$ip_rx_rate - _p9__ip_timestamp=$ip_timestamp - _p9k__vpn_ip_ips=($vpn_ip_ips) - _p9k_print_params \ - _p9k__public_ip_vpn \ - _p9k__public_ip_not_vpn \ - P9K_IP_IP \ - P9K_IP_INTERFACE \ - P9K_IP_TX_BYTES \ - P9K_IP_RX_BYTES \ - P9K_IP_TX_BYTES_DELTA \ - P9K_IP_RX_BYTES_DELTA \ - P9K_IP_TX_RATE \ - P9K_IP_RX_RATE \ - _p9__ip_timestamp \ - _p9k__vpn_ip_ips - echo -E - 'reset=1' -} - -_p9k_prompt_net_iface_sync() { - local -i vpn_ip_changed=$REPLY[1] - REPLY[1]="" - eval $REPLY - (( vpn_ip_changed )) && REPLY+='; _p9k_vpn_ip_render' - _p9k_worker_reply $REPLY -} - -function _p9k_set_prompt() { - local -i _p9k__vcs_called - - PROMPT= - RPROMPT= - [[ $1 == instant_ ]] || PROMPT+='${$((_p9k_on_expand()))+}%{${_p9k__raw_msg-}${_p9k__raw_msg::=}%}' - PROMPT+=$_p9k_prompt_prefix_left - - local -i _p9k__has_upglob - - local -i left_idx=1 right_idx=1 num_lines=$#_p9k_line_segments_left - for _p9k__line_index in {1..$num_lines}; do - local right= - if (( !_POWERLEVEL9K_DISABLE_RPROMPT )); then - _p9k__dir= - _p9k__prompt= - _p9k__segment_index=right_idx - _p9k__prompt_side=right - if [[ $1 == instant_ ]]; then - for _p9k__segment_name in ${${(0)_p9k_line_segments_right[_p9k__line_index]}%_joined}; do - if (( $+functions[instant_prompt_$_p9k__segment_name] )); then - local disabled=_POWERLEVEL9K_${${(U)_p9k__segment_name}//İ/I}_DISABLED_DIR_PATTERN - if [[ $_p9k__cwd != ${(P)~disabled} ]]; then - local -i len=$#_p9k__prompt - _p9k__non_hermetic_expansion=0 - instant_prompt_$_p9k__segment_name - if (( _p9k__non_hermetic_expansion )); then - _p9k__prompt[len+1,-1]= - fi - fi - fi - ((++_p9k__segment_index)) - done - else - for _p9k__segment_name in ${${(0)_p9k_line_segments_right[_p9k__line_index]}%_joined}; do - local cond=$_p9k__segment_cond_right[_p9k__segment_index] - if [[ -z $cond || -n ${(e)cond} ]]; then - local disabled=_POWERLEVEL9K_${${(U)_p9k__segment_name}//İ/I}_DISABLED_DIR_PATTERN - if [[ $_p9k__cwd != ${(P)~disabled} ]]; then - local val=$_p9k__segment_val_right[_p9k__segment_index] - if [[ -n $val ]]; then - _p9k__prompt+=$val - else - if [[ $_p9k__segment_name == custom_* ]]; then - _p9k_custom_prompt $_p9k__segment_name[8,-1] - elif (( $+functions[prompt_$_p9k__segment_name] )); then - prompt_$_p9k__segment_name - fi - fi - fi - fi - ((++_p9k__segment_index)) - done - fi - _p9k__prompt=${${_p9k__prompt//$' %{\b'/'%{%G'}//$' \b'} - right_idx=_p9k__segment_index - if [[ -n $_p9k__prompt || $_p9k_line_never_empty_right[_p9k__line_index] == 1 ]]; then - right=$_p9k_line_prefix_right[_p9k__line_index]$_p9k__prompt$_p9k_line_suffix_right[_p9k__line_index] - fi - fi - unset _p9k__dir - _p9k__prompt=$_p9k_line_prefix_left[_p9k__line_index] - _p9k__segment_index=left_idx - _p9k__prompt_side=left - if [[ $1 == instant_ ]]; then - for _p9k__segment_name in ${${(0)_p9k_line_segments_left[_p9k__line_index]}%_joined}; do - if (( $+functions[instant_prompt_$_p9k__segment_name] )); then - local disabled=_POWERLEVEL9K_${${(U)_p9k__segment_name}//İ/I}_DISABLED_DIR_PATTERN - if [[ $_p9k__cwd != ${(P)~disabled} ]]; then - local -i len=$#_p9k__prompt - _p9k__non_hermetic_expansion=0 - instant_prompt_$_p9k__segment_name - if (( _p9k__non_hermetic_expansion )); then - _p9k__prompt[len+1,-1]= - fi - fi - fi - ((++_p9k__segment_index)) - done - else - for _p9k__segment_name in ${${(0)_p9k_line_segments_left[_p9k__line_index]}%_joined}; do - local cond=$_p9k__segment_cond_left[_p9k__segment_index] - if [[ -z $cond || -n ${(e)cond} ]]; then - local disabled=_POWERLEVEL9K_${${(U)_p9k__segment_name}//İ/I}_DISABLED_DIR_PATTERN - if [[ $_p9k__cwd != ${(P)~disabled} ]]; then - local val=$_p9k__segment_val_left[_p9k__segment_index] - if [[ -n $val ]]; then - _p9k__prompt+=$val - else - if [[ $_p9k__segment_name == custom_* ]]; then - _p9k_custom_prompt $_p9k__segment_name[8,-1] - elif (( $+functions[prompt_$_p9k__segment_name] )); then - prompt_$_p9k__segment_name - fi - fi - fi - fi - ((++_p9k__segment_index)) - done - fi - _p9k__prompt=${${_p9k__prompt//$' %{\b'/'%{%G'}//$' \b'} - left_idx=_p9k__segment_index - _p9k__prompt+=$_p9k_line_suffix_left[_p9k__line_index] - if (( $+_p9k__dir || (_p9k__line_index != num_lines && $#right) )); then - _p9k__prompt='${${:-${_p9k__d::=0}${_p9k__rprompt::='$right'}${_p9k__lprompt::='$_p9k__prompt'}}+}' - _p9k__prompt+=$_p9k_gap_pre - if (( $+_p9k__dir )); then - if (( _p9k__line_index == num_lines && (_POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS > 0 || _POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT > 0) )); then - local a=$_POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS - local f=$((0.01*_POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT))'*_p9k__clm' - _p9k__prompt+="\${\${_p9k__h::=$((($a<$f)*$f+($a>=$f)*$a))}+}" - else - _p9k__prompt+='${${_p9k__h::=0}+}' - fi - if [[ $_POWERLEVEL9K_DIR_MAX_LENGTH == <->('%'|) ]]; then - local lim= - if [[ $_POWERLEVEL9K_DIR_MAX_LENGTH[-1] == '%' ]]; then - lim="$_p9k__dir_len-$((0.01*$_POWERLEVEL9K_DIR_MAX_LENGTH[1,-2]))*_p9k__clm" - else - lim=$((_p9k__dir_len-_POWERLEVEL9K_DIR_MAX_LENGTH)) - ((lim <= 0)) && lim= - fi - if [[ -n $lim ]]; then - _p9k__prompt+='${${${$((_p9k__h<_p9k__m+'$lim')):#1}:-${_p9k__h::=$((_p9k__m+'$lim'))}}+}' - fi - fi - _p9k__prompt+='${${_p9k__d::=$((_p9k__m-_p9k__h))}+}' - _p9k__prompt+='${_p9k__lprompt/\%\{d\%\}*\%\{d\%\}/${_p9k__'$_p9k__line_index'ldir-'$_p9k__dir'}}' - _p9k__prompt+='${${_p9k__m::=$((_p9k__d+_p9k__h))}+}' - else - _p9k__prompt+='${_p9k__lprompt}' - fi - ((_p9k__line_index != num_lines && $#right)) && _p9k__prompt+=$_p9k_line_gap_post[_p9k__line_index] - fi - if (( _p9k__line_index == num_lines )); then - [[ -n $right ]] && RPROMPT=$_p9k_prompt_prefix_right$right$_p9k_prompt_suffix_right - _p9k__prompt='${_p9k__'$_p9k__line_index'-'$_p9k__prompt'}'$_p9k_prompt_suffix_left - [[ $1 == instant_ ]] || PROMPT+=$_p9k__prompt - else - [[ -n $right ]] || _p9k__prompt+=$'\n' - PROMPT+='${_p9k__'$_p9k__line_index'-'$_p9k__prompt'}' - fi - done - - _p9k__prompt_side= - (( $#_p9k_cache < _POWERLEVEL9K_MAX_CACHE_SIZE )) || _p9k_cache=() - (( $#_p9k__cache_ephemeral < _POWERLEVEL9K_MAX_CACHE_SIZE )) || _p9k__cache_ephemeral=() - - [[ -n $RPROMPT ]] || unset RPROMPT -} - -_p9k_set_instant_prompt() { - local saved_prompt=$PROMPT - local saved_rprompt=$RPROMPT - _p9k_set_prompt instant_ - typeset -g _p9k__instant_prompt=$PROMPT$'\x1f'$_p9k__prompt$'\x1f'$RPROMPT - PROMPT=$saved_prompt - RPROMPT=$saved_rprompt - [[ -n $RPROMPT ]] || unset RPROMPT -} - -typeset -gri __p9k_instant_prompt_version=47 - -_p9k_dump_instant_prompt() { - local user=${(%):-%n} - local root_dir=${__p9k_dump_file:h} - local prompt_dir=${root_dir}/p10k-$user - local root_file=$root_dir/p10k-instant-prompt-$user.zsh - local prompt_file=$prompt_dir/prompt-${#_p9k__cwd} - [[ -d $prompt_dir ]] || mkdir -p $prompt_dir || return - [[ -w $root_dir && -w $prompt_dir ]] || return - - if [[ ! -e $root_file ]]; then - local tmp=$root_file.tmp.$$ - local -i fd - sysopen -a -m 600 -o creat,trunc -u fd -- $tmp || return - { - [[ $TERM == (screen*|tmux*) ]] && local screen='-n' || local screen='-z' - local -a display_v=("${_p9k__display_v[@]}") - local -i i - for ((i = 6; i <= $#display_v; i+=2)); do display_v[i]=show; done - display_v[2]=hide - display_v[4]=hide - local gitstatus_dir=${${_POWERLEVEL9K_GITSTATUS_DIR:A}:-${__p9k_root_dir}/gitstatus} - local gitstatus_header - if [[ -r $gitstatus_dir/install.info ]]; then - IFS= read -r gitstatus_header <$gitstatus_dir/install.info || return - fi - >&$fd print -r -- '[[ -t 0 && -t 1 && -t 2 && -o interactive && -o zle && -o no_xtrace ]] && - ! (( ${+__p9k_instant_prompt_disabled} || ZSH_SUBSHELL || ${+ZSH_SCRIPT} || ${+ZSH_EXECUTION_STRING} )) || return 0' - >&$fd print -r -- "() { - $__p9k_intro_no_locale - typeset -gi __p9k_instant_prompt_disabled=1 - [[ \$ZSH_VERSION == ${(q)ZSH_VERSION} && \$ZSH_PATCHLEVEL == ${(q)ZSH_PATCHLEVEL} && - $screen \${(M)TERM:#(screen*|tmux*)} && - \${#\${(M)VTE_VERSION:#(<1-4602>|4801)}} == "${#${(M)VTE_VERSION:#(<1-4602>|4801)}}" && - \$POWERLEVEL9K_DISABLE_INSTANT_PROMPT != 'true' && - \$POWERLEVEL9K_INSTANT_PROMPT != 'off' ]] || return - typeset -g __p9k_instant_prompt_param_sig=${(q+)_p9k__param_sig} - local gitstatus_dir=${(q)gitstatus_dir} - local gitstatus_header=${(q)gitstatus_header} - local -i ZLE_RPROMPT_INDENT=${ZLE_RPROMPT_INDENT:-1} - local PROMPT_EOL_MARK=${(q)PROMPT_EOL_MARK-%B%S%#%s%b} - [[ -n \$SSH_CLIENT || -n \$SSH_TTY || -n \$SSH_CONNECTION ]] && local ssh=1 || local ssh=0 - local cr=\$'\r' lf=\$'\n' esc=\$'\e[' rs=$'\x1e' us=$'\x1f' - local -i height=${_POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES-1} - local prompt_dir=${(q)prompt_dir}" - if (( ! ${+_POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES} )); then - >&$fd print -r -- ' - (( _z4h_can_save_restore_screen == 1 )) && height=0' - fi - >&$fd print -r -- ' - local real_gitstatus_header - if [[ -r $gitstatus_dir/install.info ]]; then - IFS= read -r real_gitstatus_header <$gitstatus_dir/install.info || real_gitstatus_header=borked - fi - [[ $real_gitstatus_header == $gitstatus_header ]] || return - zmodload zsh/langinfo zsh/terminfo zsh/system || return - if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]]; then - local loc_cmd=$commands[locale] - [[ -z $loc_cmd ]] && loc_cmd='${(q)commands[locale]}' - if [[ -x $loc_cmd ]]; then - local -a locs - if locs=(${(@M)$(locale -a 2>/dev/null):#*.(utf|UTF)(-|)8}) && (( $#locs )); then - local loc=${locs[(r)(#i)C.UTF(-|)8]:-${locs[(r)(#i)en_US.UTF(-|)8]:-$locs[1]}} - [[ -n $LC_ALL ]] && local LC_ALL=$loc || local LC_CTYPE=$loc - fi - fi - fi - (( terminfo[colors] == '${terminfo[colors]:-0}' )) || return - (( $+terminfo[cuu] && $+terminfo[cuf] && $+terminfo[ed] && $+terminfo[sc] && $+terminfo[rc] )) || return - local pwd=${(%):-%/} - [[ $pwd == /* ]] || return - local prompt_file=$prompt_dir/prompt-${#pwd} - local key=$pwd:$ssh:${(%):-%#} - local content - if [[ ! -e $prompt_file ]]; then - typeset -gi __p9k_instant_prompt_sourced='$__p9k_instant_prompt_version' - return 1 - fi - { content="$(<$prompt_file)" } 2>/dev/null || return - local tail=${content##*$rs$key$us} - if (( ${#tail} == ${#content} )); then - typeset -gi __p9k_instant_prompt_sourced='$__p9k_instant_prompt_version' - return 1 - fi - local _p9k__ipe - local P9K_PROMPT=instant - if [[ -z $P9K_TTY || $P9K_TTY == old && -n ${_P9K_TTY:#$TTY} ]]; then' - if (( _POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS < 0 )); then - >&$fd print -r -- ' typeset -gx P9K_TTY=new' - else - >&$fd print -r -- ' - typeset -gx P9K_TTY=old - zmodload -F zsh/stat b:zstat || return - zmodload zsh/datetime || return - local -a stat - if zstat -A stat +ctime -- $TTY 2>/dev/null && - (( EPOCHREALTIME - stat[1] < '$_POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS' )); then - P9K_TTY=new - fi' - fi - >&$fd print -r -- ' fi - typeset -gx _P9K_TTY=$TTY - local -i _p9k__empty_line_i=3 _p9k__ruler_i=3 - local -A _p9k_display_k=('${(j: :)${(@q)${(kv)_p9k_display_k}}}') - local -a _p9k__display_v=('${(j: :)${(@q)display_v}}') - function p10k() { - '$__p9k_intro' - [[ $1 == display ]] || return - shift - local -i k dump - local opt prev new pair list name var - while getopts ":ha" opt; do - case $opt in - a) dump=1;; - h) return 0;; - ?) return 1;; - esac - done - if (( dump )); then - reply=() - shift $((OPTIND-1)) - (( ARGC )) || set -- "*" - for opt; do - for k in ${(u@)_p9k_display_k[(I)$opt]:/(#m)*/$_p9k_display_k[$MATCH]}; do - reply+=($_p9k__display_v[k,k+1]) - done - done - return 0 - fi - for opt in "${@:$OPTIND}"; do - pair=(${(s:=:)opt}) - list=(${(s:,:)${pair[2]}}) - if [[ ${(b)pair[1]} == $pair[1] ]]; then - local ks=($_p9k_display_k[$pair[1]]) - else - local ks=(${(u@)_p9k_display_k[(I)$pair[1]]:/(#m)*/$_p9k_display_k[$MATCH]}) - fi - for k in $ks; do - if (( $#list == 1 )); then - [[ $_p9k__display_v[k+1] == $list[1] ]] && continue - new=$list[1] - else - new=${list[list[(I)$_p9k__display_v[k+1]]+1]:-$list[1]} - [[ $_p9k__display_v[k+1] == $new ]] && continue - fi - _p9k__display_v[k+1]=$new - name=$_p9k__display_v[k] - if [[ $name == (empty_line|ruler) ]]; then - var=_p9k__${name}_i - [[ $new == hide ]] && typeset -gi $var=3 || unset $var - elif [[ $name == (#b)(<->)(*) ]]; then - var=_p9k__${match[1]}${${${${match[2]//\/}/#left/l}/#right/r}/#gap/g} - [[ $new == hide ]] && typeset -g $var= || unset $var - fi - done - done - }' - if (( _POWERLEVEL9K_PROMPT_ADD_NEWLINE )); then - >&$fd print -r -- ' [[ $P9K_TTY == old ]] && { unset _p9k__empty_line_i; _p9k__display_v[2]=print }' - fi - if (( _POWERLEVEL9K_SHOW_RULER )); then - >&$fd print -r -- '[[ $P9K_TTY == old ]] && { unset _p9k__ruler_i; _p9k__display_v[4]=print }' - fi - if (( $+functions[p10k-on-init] )); then - >&$fd print -r -- ' - p10k-on-init() { '$functions[p10k-on-init]' }' - fi - if (( $+functions[p10k-on-pre-prompt] )); then - >&$fd print -r -- ' - p10k-on-pre-prompt() { '$functions[p10k-on-pre-prompt]' }' - fi - if (( $+functions[p10k-on-post-prompt] )); then - >&$fd print -r -- ' - p10k-on-post-prompt() { '$functions[p10k-on-post-prompt]' }' - fi - if (( $+functions[p10k-on-post-widget] )); then - >&$fd print -r -- ' - p10k-on-post-widget() { '$functions[p10k-on-post-widget]' }' - fi - if (( $+functions[p10k-on-init] )); then - >&$fd print -r -- ' - p10k-on-init' - fi - local pat idx var - for pat idx var in $_p9k_show_on_command; do - >&$fd print -r -- " - local $var= - _p9k__display_v[$idx]=hide" - done - if (( $+functions[p10k-on-pre-prompt] )); then - >&$fd print -r -- ' - p10k-on-pre-prompt' - fi - if (( $+functions[p10k-on-init] )); then - >&$fd print -r -- ' - unfunction p10k-on-init' - fi - if (( $+functions[p10k-on-pre-prompt] )); then - >&$fd print -r -- ' - unfunction p10k-on-pre-prompt' - fi - if (( $+functions[p10k-on-post-prompt] )); then - >&$fd print -r -- ' - unfunction p10k-on-post-prompt' - fi - if (( $+functions[p10k-on-post-widget] )); then - >&$fd print -r -- ' - unfunction p10k-on-post-widget' - fi - >&$fd print -r -- ' - () { -'$functions[_p9k_init_toolbox]' - } - trap "unset -m _p9k__\*; unfunction p10k" EXIT - local -a _p9k_t=("${(@ps:$us:)${tail%%$rs*}}") - if [[ $+VTE_VERSION == 1 || $TERM_PROGRAM == Hyper ]] && (( $+commands[stty] )); then - if [[ $TERM_PROGRAM == Hyper ]]; then - local bad_lines=40 bad_columns=100 - else - local bad_lines=24 bad_columns=80 - fi - if (( LINES == bad_lines && COLUMNS == bad_columns )); then - zmodload -F zsh/stat b:zstat || return - zmodload zsh/datetime || return - local -a tty_ctime - if ! zstat -A tty_ctime +ctime -- $TTY 2>/dev/null || (( tty_ctime[1] + 2 > EPOCHREALTIME )); then - local -F deadline=$((EPOCHREALTIME+0.025)) - local tty_size - while true; do - if (( EPOCHREALTIME > deadline )) || ! tty_size="$(command stty size 2>/dev/null)" || [[ $tty_size != <->" "<-> ]]; then - (( $+_p9k__ruler_i )) || local -i _p9k__ruler_i=1 - local _p9k__g= _p9k__'$#_p9k_line_segments_right'r= _p9k__'$#_p9k_line_segments_right'r_frame= - break - fi - if [[ $tty_size != "$bad_lines $bad_columns" ]]; then - local lines_columns=(${=tty_size}) - local LINES=$lines_columns[1] - local COLUMNS=$lines_columns[2] - break - fi - done - fi - fi - fi' - (( __p9k_ksh_arrays )) && >&$fd print -r -- ' setopt ksh_arrays' - (( __p9k_sh_glob )) && >&$fd print -r -- ' setopt sh_glob' - >&$fd print -r -- ' typeset -ga __p9k_used_instant_prompt=("${(@e)_p9k_t[-3,-1]}")' - (( __p9k_ksh_arrays )) && >&$fd print -r -- ' unsetopt ksh_arrays' - (( __p9k_sh_glob )) && >&$fd print -r -- ' unsetopt sh_glob' - >&$fd print -r -- ' - local -i prompt_height=${#${__p9k_used_instant_prompt[1]//[^$lf]}} - (( height += prompt_height )) - local _p9k__ret - function _p9k_prompt_length() { - local -i COLUMNS=1024 - local -i x y=${#1} m - if (( y )); then - while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do - x=y - (( y *= 2 )) - done - while (( y > x + 1 )); do - (( m = x + (y - x) / 2 )) - (( ${${(%):-$1%$m(l.x.y)}[-1]} = m )) - done - fi - typeset -g _p9k__ret=$x - } - local out=${(%):-%b%k%f%s%u} - if [[ $P9K_TTY == old && ( $+VTE_VERSION == 0 && $TERM_PROGRAM != Hyper || $+_p9k__g == 0 ) ]]; then - local mark=${(e)PROMPT_EOL_MARK} - [[ $mark == "%B%S%#%s%b" ]] && _p9k__ret=1 || _p9k_prompt_length $mark - local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0)) - out+="${(%):-$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}" - else - out+="${(%):-$cr%E}" - fi - if (( _z4h_can_save_restore_screen != 1 )); then - (( height )) && out+="${(pl.$height..$lf.)}$esc${height}A" - out+="$terminfo[sc]" - fi - out+=${(%):-"$__p9k_used_instant_prompt[1]$__p9k_used_instant_prompt[2]"} - if [[ -n $__p9k_used_instant_prompt[3] ]]; then - _p9k_prompt_length "$__p9k_used_instant_prompt[2]" - local -i left_len=_p9k__ret - _p9k_prompt_length "$__p9k_used_instant_prompt[3]" - if (( _p9k__ret )); then - local -i gap=$((COLUMNS - left_len - _p9k__ret - ZLE_RPROMPT_INDENT)) - if (( gap >= 40 )); then - out+="${(pl.$gap.. .)}${(%):-${__p9k_used_instant_prompt[3]}%b%k%f%s%u}$cr$esc${left_len}C" - fi - fi - fi - if (( _z4h_can_save_restore_screen == 1 )); then - if (( height )); then - out+="$cr${(pl:$((height-prompt_height))::\n:)}$esc${height}A$terminfo[sc]$out" - else - out+="$cr${(pl:$((height-prompt_height))::\n:)}$terminfo[sc]$out" - fi - fi - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - typeset -g __p9k_instant_prompt_output=$tmpdir/p10k-instant-prompt-output-${(%):-%n}-$$ - { : > $__p9k_instant_prompt_output } || return - print -rn -- "${out}${esc}?2004h" || return - if (( $+commands[stty] )); then - command stty -icanon 2>/dev/null - fi - local fd_null - sysopen -ru fd_null /dev/null || return - exec {__p9k_fd_0}<&0 {__p9k_fd_1}>&1 {__p9k_fd_2}>&2 0<&$fd_null 1>$__p9k_instant_prompt_output - exec 2>&1 {fd_null}>&- - typeset -gi __p9k_instant_prompt_active=1 - if (( _z4h_can_save_restore_screen == 1 )); then - typeset -g _z4h_saved_screen - -z4h-save-screen - fi - typeset -g __p9k_instant_prompt_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh - if builtin source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then - _p9k_preinit - fi - function _p9k_instant_prompt_cleanup() { - (( ZSH_SUBSHELL == 0 && ${+__p9k_instant_prompt_active} )) || return 0 - '$__p9k_intro_no_locale' - unset __p9k_instant_prompt_active - exec 0<&$__p9k_fd_0 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_0}>&- {__p9k_fd_1}>&- {__p9k_fd_2}>&- - unset __p9k_fd_0 __p9k_fd_1 __p9k_fd_2 - typeset -gi __p9k_instant_prompt_erased=1 - if (( _z4h_can_save_restore_screen == 1 && __p9k_instant_prompt_sourced >= 35 )); then - -z4h-restore-screen - unset _z4h_saved_screen - fi - print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed] - if [[ -s $__p9k_instant_prompt_output ]]; then - command cat $__p9k_instant_prompt_output 2>/dev/null - if (( $1 )); then - local _p9k__ret mark="${(e)${PROMPT_EOL_MARK-%B%S%#%s%b}}" - _p9k_prompt_length $mark - local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0)) - echo -nE - "${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}" - fi - fi - zshexit_functions=(${zshexit_functions:#_p9k_instant_prompt_cleanup}) - zmodload -F zsh/files b:zf_rm || return - local user=${(%):-%n} - local root_dir=${__p9k_instant_prompt_dump_file:h} - zf_rm -f -- $__p9k_instant_prompt_output $__p9k_instant_prompt_dump_file{,.zwc} $root_dir/p10k-instant-prompt-$user.zsh{,.zwc} $root_dir/p10k-$user/prompt-*(N) 2>/dev/null - } - function _p9k_instant_prompt_precmd_first() { - '$__p9k_intro' - function _p9k_instant_prompt_sched_last() { - (( ${+__p9k_instant_prompt_active} )) || return 0 - _p9k_instant_prompt_cleanup 1 - setopt no_local_options prompt_cr prompt_sp - } - zmodload zsh/sched - sched +0 _p9k_instant_prompt_sched_last - precmd_functions=(${(@)precmd_functions:#_p9k_instant_prompt_precmd_first}) - } - zshexit_functions=(_p9k_instant_prompt_cleanup $zshexit_functions) - precmd_functions=(_p9k_instant_prompt_precmd_first $precmd_functions) - DISABLE_UPDATE_PROMPT=true -} && unsetopt prompt_cr prompt_sp && typeset -gi __p9k_instant_prompt_sourced='$__p9k_instant_prompt_version' || - typeset -gi __p9k_instant_prompt_sourced=${__p9k_instant_prompt_sourced:-0}' - } always { - exec {fd}>&- - } - { - (( ! $? )) || return - # `zf_mv -f src dst` fails on NTFS if `dst` is not writable, hence `zf_rm`. - zf_rm -f -- $root_file.zwc || return - zf_mv -f -- $tmp $root_file || return - zcompile -R -- $tmp.zwc $root_file || return - zf_mv -f -- $tmp.zwc $root_file.zwc || return - } always { - (( $? )) && zf_rm -f -- $tmp $tmp.zwc 2>/dev/null - } - fi - - local tmp=$prompt_file.tmp.$$ - zf_mv -f -- $prompt_file $tmp 2>/dev/null - if [[ "$(<$tmp)" == *$'\x1e'$_p9k__instant_prompt_sig$'\x1f'* ]] 2>/dev/null; then - echo -n >$tmp || return - fi - - local -i fd - sysopen -a -m 600 -o creat -u fd -- $tmp || return - { - { - print -rnu $fd -- $'\x1e'$_p9k__instant_prompt_sig$'\x1f'${(pj:\x1f:)_p9k_t}$'\x1f'$_p9k__instant_prompt || return - } always { - exec {fd}>&- - } - zf_mv -f -- $tmp $prompt_file || return - } always { - (( $? )) && zf_rm -f -- $tmp 2>/dev/null - } -} - -typeset -gi __p9k_sh_glob -typeset -gi __p9k_ksh_arrays -typeset -gi __p9k_new_status -typeset -ga __p9k_new_pipestatus - -_p9k_save_status() { - local -i pipe - if (( !$+_p9k__line_finished )); then - : # SIGINT - elif (( !$+_p9k__preexec_cmd )); then - # Empty line, comment or parse error. - # - # This case is handled incorrectly: - # - # true | false - # | - # - # Here status=1 and pipestatus=(0 1). Ideally we should ignore pipestatus but we won't. - # - # This works though (unless pipefail is set): - # - # false | true - # | - # - # We get status=1 and pipestatus=(1 0) and correctly ignore pipestatus. - (( _p9k__status == __p9k_new_status )) && return - elif (( $__p9k_new_pipestatus[(I)$__p9k_new_status] )); then # just in case - local cmd=(${(z)_p9k__preexec_cmd}) - if [[ $#cmd != 0 && $cmd[1] != '!' && ${(Q)cmd[1]} != coproc ]]; then - local arg - for arg in ${(z)_p9k__preexec_cmd}; do - # '()' is for functions, *';' is for complex commands. - if [[ $arg == ('()'|'&&'|'||'|'&'|'&|'|'&!'|*';') ]]; then - pipe=0 - break - elif [[ $arg == *('|'|'|&')* ]]; then - pipe=1 - fi - done - fi - fi - _p9k__status=$__p9k_new_status - if (( pipe )); then - _p9k__pipestatus=($__p9k_new_pipestatus) - else - _p9k__pipestatus=($_p9k__status) - fi -} - -function _p9k_dump_state() { - local dir=${__p9k_dump_file:h} - [[ -d $dir ]] || mkdir -p -- $dir || return - [[ -w $dir ]] || return - local tmp=$__p9k_dump_file.tmp.$$ - local -i fd - sysopen -a -m 600 -o creat,trunc -u fd -- $tmp || return - { - { - typeset -g __p9k_cached_param_pat=$_p9k__param_pat - typeset -g __p9k_cached_param_sig=$_p9k__param_sig - typeset -pm __p9k_cached_param_pat __p9k_cached_param_sig >&$fd || return - unset __p9k_cached_param_pat __p9k_cached_param_sig - (( $+_p9k_preinit )) && { print -r -- $_p9k_preinit >&$fd || return } - print -r -- '_p9k_restore_state_impl() {' >&$fd || return - typeset -pm '_POWERLEVEL9K_*|_p9k_[^_]*|icons' >&$fd || return - print -r -- '}' >&$fd || return - } always { - exec {fd}>&- - } - # `zf_mv -f src dst` fails on NTFS if `dst` is not writable, hence `zf_rm`. - zf_rm -f -- $__p9k_dump_file.zwc || return - zf_mv -f -- $tmp $__p9k_dump_file || return - zcompile -R -- $tmp.zwc $__p9k_dump_file || return - zf_mv -f -- $tmp.zwc $__p9k_dump_file.zwc || return - } always { - (( $? )) && zf_rm -f -- $tmp $tmp.zwc 2>/dev/null - } -} - -function _p9k_delete_instant_prompt() { - local user=${(%):-%n} - local root_dir=${__p9k_dump_file:h} - zf_rm -f -- $root_dir/p10k-instant-prompt-$user.zsh{,.zwc} ${root_dir}/p10k-$user/prompt-*(N) 2>/dev/null -} - -function _p9k_restore_state() { - { - [[ $__p9k_cached_param_pat == $_p9k__param_pat && $__p9k_cached_param_sig == $_p9k__param_sig ]] || return - (( $+functions[_p9k_restore_state_impl] )) || return - _p9k_restore_state_impl - return 0 - } always { - if (( $? )); then - if (( $+functions[_p9k_preinit] )); then - unfunction _p9k_preinit - (( $+functions[gitstatus_stop_p9k_] )) && gitstatus_stop_p9k_ POWERLEVEL9K - fi - _p9k_delete_instant_prompt - zf_rm -f -- $__p9k_dump_file{,.zwc} 2>/dev/null - elif [[ $__p9k_instant_prompt_param_sig != $_p9k__param_sig ]]; then - _p9k_delete_instant_prompt - _p9k_dumped_instant_prompt_sigs=() - fi - unset __p9k_cached_param_sig - } -} - -function _p9k_clear_instant_prompt() { - if (( $+__p9k_fd_0 )); then - exec 0<&$__p9k_fd_0 {__p9k_fd_0}>&- - unset __p9k_fd_0 - fi - exec 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_1}>&- {__p9k_fd_2}>&- - unset __p9k_fd_1 __p9k_fd_2 - zshexit_functions=(${zshexit_functions:#_p9k_instant_prompt_cleanup}) - if (( _p9k__can_hide_cursor )); then - echoti civis - _p9k__cursor_hidden=1 - fi - if [[ -s $__p9k_instant_prompt_output ]]; then - { - local content - [[ $_POWERLEVEL9K_INSTANT_PROMPT == verbose ]] && content="$(<$__p9k_instant_prompt_output)" - local mark="${(e)${PROMPT_EOL_MARK-%B%S%#%s%b}}" - _p9k_prompt_length $mark - local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0)) - local cr=$'\r' - local sp="${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}" - if (( _z4h_can_save_restore_screen == 1 && __p9k_instant_prompt_sourced >= 35 )); then - -z4h-restore-screen - unset _z4h_saved_screen - fi - print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed] - local unexpected=${(S)${${content//$'\e[?'<->'c'}//$'\e['<->' q'}//$'\e'[^$'\a\e']#($'\a'|$'\e\\')} - # Visual Studio Code prints this garbage. - unexpected=${unexpected//$'\033[1;32mShell integration activated\033[0m\n'} - if [[ -n $unexpected ]]; then - local omz1='[Oh My Zsh] Would you like to update? [Y/n]: ' - local omz2='Updating Oh My Zsh' - local omz3='https://shop.planetargon.com/collections/oh-my-zsh' - local omz4='There was an error updating. Try again later?' - if [[ $unexpected != ($omz1|)$omz2*($omz3|$omz4)[^$'\n']#($'\n'|) ]]; then - echo -E - "" - echo -E - "${(%):-[%3FWARNING%f]: Console output during zsh initialization detected.}" - echo -E - "" - echo -E - "${(%):-When using Powerlevel10k with instant prompt, console output during zsh}" - echo -E - "${(%):-initialization may indicate issues.}" - echo -E - "" - echo -E - "${(%):-You can:}" - echo -E - "" - echo -E - "${(%):- - %BRecommended%b: Change %B$__p9k_zshrc_u%b so that it does not perform console I/O}" - echo -E - "${(%):- after the instant prompt preamble. See the link below for details.}" - echo -E - "" - echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - echo -E - "${(%):- * Zsh will start %Bquickly%b and prompt will update %Bsmoothly%b.}" - echo -E - "" - echo -E - "${(%):- - Suppress this warning either by running %Bp10k configure%b or by manually}" - echo -E - "${(%):- defining the following parameter:}" - echo -E - "" - echo -E - "${(%):- %3Ftypeset%f -g POWERLEVEL9K_INSTANT_PROMPT=quiet}" - echo -E - "" - echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - echo -E - "${(%):- * Zsh will start %Bquickly%b but prompt will %Bjump down%b after initialization.}" - echo -E - "" - echo -E - "${(%):- - Disable instant prompt either by running %Bp10k configure%b or by manually}" - echo -E - "${(%):- defining the following parameter:}" - echo -E - "" - echo -E - "${(%):- %3Ftypeset%f -g POWERLEVEL9K_INSTANT_PROMPT=off}" - echo -E - "" - echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - echo -E - "${(%):- * Zsh will start %Bslowly%b.}" - echo -E - "" - echo -E - "${(%):- - Do nothing.}" - echo -E - "" - echo -E - "${(%):- * You %Bwill%b see this error message every time you start zsh.}" - echo -E - "${(%):- * Zsh will start %Bquickly%b but prompt will %Bjump down%b after initialization.}" - echo -E - "" - echo -E - "${(%):-For details, see:}" - if (( _p9k_term_has_href )); then - echo - "${(%):-\e]8;;https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt\ahttps://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt\e]8;;\a}" - else - echo - "${(%):-https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt}" - fi - echo -E - "" - echo - "${(%):-%3F-- console output produced during zsh initialization follows --%f}" - echo -E - "" - fi - fi - command cat -- $__p9k_instant_prompt_output - echo -nE - $sp - zf_rm -f -- $__p9k_instant_prompt_output - } 2>/dev/null - else - zf_rm -f -- $__p9k_instant_prompt_output 2>/dev/null - if (( _z4h_can_save_restore_screen == 1 && __p9k_instant_prompt_sourced >= 35 )); then - -z4h-restore-screen - unset _z4h_saved_screen - fi - print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed] - fi - prompt_opts=(percent subst sp cr) - if [[ $_POWERLEVEL9K_DISABLE_INSTANT_PROMPT == 0 && $__p9k_instant_prompt_active == 2 ]]; then - >&2 echo -E - "" - >&2 echo -E - "${(%):-[%1FERROR%f]: When using Powerlevel10k with instant prompt, %Bprompt_cr%b must be unset.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):-You can:}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - %BRecommended%b: call %Bp10k finalize%b at the end of %B$__p9k_zshrc_u%b.}" - >&2 echo -E - "${(%):- You can do this by running the following command:}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- %2Fecho%f %3F'(( ! \${+functions[p10k]\} )) || p10k finalize'%f >>! $__p9k_zshrc_u}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - >&2 echo -E - "${(%):- * Zsh will start %Bquickly%b and %Bwithout%b prompt flickering.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - Find where %Bprompt_cr%b option gets sets in your zsh configs and stop setting it.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - >&2 echo -E - "${(%):- * Zsh will start %Bquickly%b and %Bwithout%b prompt flickering.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - Disable instant prompt either by running %Bp10k configure%b or by manually}" - >&2 echo -E - "${(%):- defining the following parameter:}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- %3Ftypeset%f -g POWERLEVEL9K_INSTANT_PROMPT=off}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - >&2 echo -E - "${(%):- * Zsh will start %Bslowly%b.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - Do nothing.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill%b see this error message every time you start zsh.}" - >&2 echo -E - "${(%):- * Zsh will start %Bquckly%b but %Bwith%b prompt flickering.}" - >&2 echo -E - "" - fi -} - -function _p9k_do_dump() { - eval "$__p9k_intro" - zle -F $1 - exec {1}>&- - (( _p9k__state_dump_fd )) || return - if (( ! _p9k__instant_prompt_disabled )); then - _p9k__instant_prompt_sig=$_p9k__cwd:$P9K_SSH:${(%):-%#} - _p9k_set_instant_prompt - _p9k_dump_instant_prompt - _p9k_dumped_instant_prompt_sigs[$_p9k__instant_prompt_sig]=1 - fi - _p9k_dump_state - _p9k__state_dump_scheduled=0 - _p9k__state_dump_fd=0 -} - -function _p9k_should_dump() { - (( __p9k_dumps_enabled && ! _p9k__state_dump_fd )) || return - (( _p9k__state_dump_scheduled || _p9k__prompt_idx == 1 )) && return - _p9k__instant_prompt_sig=$_p9k__cwd:$P9K_SSH:${(%):-%#} - (( ! $+_p9k_dumped_instant_prompt_sigs[$_p9k__instant_prompt_sig] )) -} - -# Must not run under `eval "$__p9k_intro_locale"`. Safe to run with any options. -function _p9k_restore_special_params() { - (( ! ${+_p9k__real_zle_rprompt_indent} )) || { - [[ -n "$_p9k__real_zle_rprompt_indent" ]] && - ZLE_RPROMPT_INDENT="$_p9k__real_zle_rprompt_indent" || - unset ZLE_RPROMPT_INDENT - unset _p9k__real_zle_rprompt_indent - } - (( ! ${+_p9k__real_lc_ctype} )) || { - LC_CTYPE="$_p9k__real_lc_ctype" - unset _p9k__real_lc_ctype - } - (( ! ${+_p9k__real_lc_all} )) || { - LC_ALL="$_p9k__real_lc_all" - unset _p9k__real_lc_all - } -} - -function _p9k_on_expand() { - (( _p9k__expanded && ! ${+__p9k_instant_prompt_active} )) && [[ "${langinfo[CODESET]}" == (utf|UTF)(-|)8 ]] && return - - eval "$__p9k_intro_no_locale" - - if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]]; then - _p9k_restore_special_params - if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]] && _p9k_init_locale; then - if [[ -n $LC_ALL ]]; then - _p9k__real_lc_all=$LC_ALL - LC_ALL=$__p9k_locale - else - _p9k__real_lc_ctype=$LC_CTYPE - LC_CTYPE=$__p9k_locale - fi - fi - fi - - (( _p9k__expanded && ! $+__p9k_instant_prompt_active )) && return - - eval "$__p9k_intro_locale" - - if (( ! _p9k__expanded )); then - if _p9k_should_dump; then - sysopen -o cloexec -ru _p9k__state_dump_fd /dev/null - zle -F $_p9k__state_dump_fd _p9k_do_dump - fi - - if [[ -z $P9K_TTY || $P9K_TTY == old && -n ${_P9K_TTY:#$TTY} ]]; then - typeset -gx P9K_TTY=old - if (( _POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS < 0 )); then - P9K_TTY=new - else - local -a stat - if zstat -A stat +ctime -- $TTY 2>/dev/null && - (( EPOCHREALTIME - stat[1] < _POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS )); then - P9K_TTY=new - fi - fi - fi - - typeset -gx _P9K_TTY=$TTY - - __p9k_reset_state=1 - - if (( _POWERLEVEL9K_PROMPT_ADD_NEWLINE )); then - if [[ $P9K_TTY == new ]]; then - _p9k__empty_line_i=3 - _p9k__display_v[2]=hide - elif [[ -z $_p9k_transient_prompt && $+functions[p10k-on-post-prompt] == 0 ]]; then - _p9k__empty_line_i=3 - _p9k__display_v[2]=print - else - unset _p9k__empty_line_i - _p9k__display_v[2]=show - fi - fi - - if (( _POWERLEVEL9K_SHOW_RULER )); then - if [[ $P9K_TTY == new ]]; then - _p9k__ruler_i=3 - _p9k__display_v[4]=hide - elif [[ -z $_p9k_transient_prompt && $+functions[p10k-on-post-prompt] == 0 ]]; then - _p9k__ruler_i=3 - _p9k__display_v[4]=print - else - unset _p9k__ruler_i - _p9k__display_v[4]=show - fi - fi - - (( _p9k__fully_initialized )) || _p9k_wrap_widgets - fi - - if (( $+__p9k_instant_prompt_active )); then - _p9k_clear_instant_prompt - unset __p9k_instant_prompt_active - fi - - if (( ! _p9k__expanded )); then - _p9k__expanded=1 - - (( _p9k__fully_initialized || ! $+functions[p10k-on-init] )) || p10k-on-init - - local pat idx var - for pat idx var in $_p9k_show_on_command; do - _p9k_display_segment $idx $var hide - done - - (( $+functions[p10k-on-pre-prompt] )) && p10k-on-pre-prompt - - if zle; then - local -a P9K_COMMANDS=($_p9k__last_commands) - local pat idx var - for pat idx var in $_p9k_show_on_command; do - if (( $P9K_COMMANDS[(I)$pat] )); then - _p9k_display_segment $idx $var show - else - _p9k_display_segment $idx $var hide - fi - done - if (( $+functions[p10k-on-post-widget] )); then - local -h WIDGET - unset WIDGET - p10k-on-post-widget - fi - else - if [[ $_p9k__display_v[2] == print && -n $_p9k_t[_p9k_empty_line_idx] ]]; then - print -rnP -- '%b%k%f%E'$_p9k_t[_p9k_empty_line_idx] - fi - if [[ $_p9k__display_v[4] == print ]]; then - () { - local ruler=$_p9k_t[_p9k_ruler_idx] - local -i _p9k__clm=COLUMNS _p9k__ind=${ZLE_RPROMPT_INDENT:-1} - (( __p9k_ksh_arrays )) && setopt ksh_arrays - (( __p9k_sh_glob )) && setopt sh_glob - setopt prompt_subst - print -rnP -- '%b%k%f%E'$ruler - } - fi - fi - - __p9k_reset_state=0 - _p9k__fully_initialized=1 - fi -} -functions -M _p9k_on_expand - -_p9k_precmd_impl() { - eval "$__p9k_intro" - - (( __p9k_enabled )) || return - - if ! zle || [[ -z $_p9k__param_sig ]]; then - if zle; then - __p9k_new_status=0 - __p9k_new_pipestatus=(0) - else - _p9k__must_restore_prompt=0 - fi - - if _p9k_must_init; then - local -i instant_prompt_disabled - if (( !__p9k_configured )); then - __p9k_configured=1 - if [[ -z "${parameters[(I)POWERLEVEL9K_*~POWERLEVEL9K_(MODE|CONFIG_FILE|GITSTATUS_DIR)]}" ]]; then - _p9k_can_configure -q - local -i ret=$? - if (( ret == 2 && $+__p9k_instant_prompt_active )); then - _p9k_clear_instant_prompt - unset __p9k_instant_prompt_active - _p9k_delete_instant_prompt - zf_rm -f -- $__p9k_dump_file{,.zwc} 2>/dev/null - () { - local key - while true; do - [[ -t 2 ]] - read -t0 -k key || break - done 2>/dev/null - } - _p9k_can_configure -q - ret=$? - fi - if (( ret == 0 )); then - if (( $+commands[git] )); then - ( - local -i pid - { - { /bin/sh "$__p9k_root_dir"/gitstatus/install </dev/null &>/dev/null & } && pid=$! - ( builtin source "$__p9k_root_dir"/internal/wizard.zsh ) - } always { - if (( pid )); then - kill -- $pid 2>/dev/null - wait -- $pid 2>/dev/null - fi - } - ) - else - ( builtin source "$__p9k_root_dir"/internal/wizard.zsh ) - fi - if (( $? )); then - instant_prompt_disabled=1 - else - builtin source "$__p9k_cfg_path" - _p9k__force_must_init=1 - _p9k_must_init - fi - fi - fi - fi - typeset -gi _p9k__instant_prompt_disabled=instant_prompt_disabled - _p9k_init - fi - - if (( _p9k__timer_start )); then - typeset -gF P9K_COMMAND_DURATION_SECONDS=$((EPOCHREALTIME - _p9k__timer_start)) - else - unset P9K_COMMAND_DURATION_SECONDS - fi - _p9k_save_status - - if [[ $_p9k__preexec_cmd == [[:space:]]#(clear([[:space:]]##-(|x)(|T[a-zA-Z0-9-_\'\"]#))#|reset)[[:space:]]# && - $_p9k__status == 0 ]]; then - P9K_TTY=new - elif [[ $P9K_TTY == new && $_p9k__fully_initialized == 1 ]] && ! zle; then - P9K_TTY=old - fi - - _p9k__timer_start=0 - _p9k__region_active=0 - - unset _p9k__line_finished _p9k__preexec_cmd - _p9k__keymap=main - _p9k__zle_state=insert - - (( ++_p9k__prompt_idx )) - - if (( $+_p9k__iterm_cmd )); then - _p9k_iterm2_precmd $__p9k_new_status - fi - fi - - _p9k_fetch_cwd - - _p9k__refresh_reason=precmd - __p9k_reset_state=1 - - local -i fast_vcs - if (( _p9k_vcs_index && $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )); then - if [[ $_p9k__cwd != $~_POWERLEVEL9K_VCS_DISABLED_DIR_PATTERN ]]; then - local -F start_time=EPOCHREALTIME - unset _p9k__vcs - unset _p9k__vcs_timeout - local -i _p9k__vcs_called - _p9k_vcs_gitstatus - local -i fast_vcs=1 - fi - fi - - (( $+functions[_p9k_async_segments_compute] )) && _p9k_async_segments_compute - - _p9k__expanded=0 - - _p9k_set_prompt - - _p9k__refresh_reason='' - - if [[ $precmd_functions[1] != _p9k_do_nothing && $precmd_functions[(I)_p9k_do_nothing] != 0 ]]; then - precmd_functions=(_p9k_do_nothing ${(@)precmd_functions:#_p9k_do_nothing}) - fi - if [[ $precmd_functions[-1] != _p9k_precmd && $precmd_functions[(I)_p9k_precmd] != 0 ]]; then - precmd_functions=(${(@)precmd_functions:#_p9k_precmd} _p9k_precmd) - fi - if [[ $preexec_functions[1] != _p9k_preexec1 && $preexec_functions[(I)_p9k_preexec1] != 0 ]]; then - preexec_functions=(_p9k_preexec1 ${(@)preexec_functions:#_p9k_preexec1}) - fi - if [[ $preexec_functions[-1] != _p9k_preexec2 && $preexec_functions[(I)_p9k_preexec2] != 0 ]]; then - preexec_functions=(${(@)preexec_functions:#_p9k_preexec2} _p9k_preexec2) - fi - - if (( fast_vcs && _p9k_vcs_index && $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )); then - if (( $+_p9k__vcs_timeout )); then - (( _p9k__vcs_timeout = _POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS + start_time - EPOCHREALTIME )) - (( _p9k__vcs_timeout >= 0 )) || (( _p9k__vcs_timeout = 0 )) - gitstatus_process_results_p9k_ -t $_p9k__vcs_timeout POWERLEVEL9K - fi - if (( ! $+_p9k__vcs )); then - local _p9k__prompt _p9k__prompt_side=$_p9k_vcs_side _p9k__segment_name=vcs - local -i _p9k__has_upglob _p9k__segment_index=_p9k_vcs_index _p9k__line_index=_p9k_vcs_line_index - _p9k_vcs_render - typeset -g _p9k__vcs=$_p9k__prompt - fi - fi - - _p9k_worker_receive - __p9k_reset_state=0 -} - -_p9k_trapint() { - if (( __p9k_enabled )); then - eval "$__p9k_intro" - _p9k_deschedule_redraw - zle && _p9k_on_widget_zle-line-finish int - fi - return 0 -} - -_p9k_precmd() { - __p9k_new_status=$? - __p9k_new_pipestatus=($pipestatus) - - trap ":" INT - - [[ -o ksh_arrays ]] && __p9k_ksh_arrays=1 || __p9k_ksh_arrays=0 - [[ -o sh_glob ]] && __p9k_sh_glob=1 || __p9k_sh_glob=0 - _p9k_restore_special_params - - _p9k_precmd_impl - - [[ ${+__p9k_instant_prompt_active} == 0 || -o no_prompt_cr ]] || __p9k_instant_prompt_active=2 - setopt no_local_options no_prompt_bang prompt_percent prompt_subst prompt_cr prompt_sp - - # See https://www.zsh.org/mla/workers/2020/msg00612.html for the reason behind __p9k_trapint. - typeset -g __p9k_trapint='_p9k_trapint; return 130' - trap "$__p9k_trapint" INT - - : ${(%):-%b%k%s%u} -} - -function _p9k_reset_prompt() { - if (( __p9k_reset_state != 1 )) && zle && [[ -z $_p9k__line_finished ]]; then - __p9k_reset_state=0 - setopt prompt_subst - (( __p9k_ksh_arrays )) && setopt ksh_arrays - (( __p9k_sh_glob )) && setopt sh_glob - { - (( _p9k__can_hide_cursor )) && echoti civis - zle .reset-prompt - (( ${+functions[z4h]} )) || zle -R - } always { - (( _p9k__can_hide_cursor )) && print -rn -- $_p9k__cnorm - _p9k__cursor_hidden=0 - } - fi -} - -# Does ZSH have a certain off-by-one bug that triggers when PROMPT overflows to a new line? -# -# Bug: https://github.com/zsh-users/zsh/commit/d8d9fee137a5aa2cf9bf8314b06895bfc2a05518. -# ZSH_PATCHLEVEL=zsh-5.4.2-159-gd8d9fee13. Released in 5.5. -# -# Fix: https://github.com/zsh-users/zsh/commit/64d13738357c9b9c212adbe17f271716abbcf6ea. -# ZSH_PATCHLEVEL=zsh-5.7.1-50-g64d137383. Released in 5.7.2. -# -# Test: PROMPT="${(pl:$((COLUMNS))::-:)}<%1(l.%2(l.FAIL.PASS).FAIL)> " zsh -dfis <<<exit -# Workaround: PROMPT="${(pl:$((COLUMNS))::-:)}%{%G%}<%1(l.%2(l.FAIL.PASS).FAIL)> " zsh -dfis <<<exit -function _p9k_prompt_overflow_bug() { - [[ $ZSH_PATCHLEVEL =~ '^zsh-5\.4\.2-([0-9]+)-' ]] && return $(( match[1] < 159 )) - [[ $ZSH_PATCHLEVEL =~ '^zsh-5\.7\.1-([0-9]+)-' ]] && return $(( match[1] >= 50 )) - [[ $ZSH_VERSION == 5.<5-7>* && $ZSH_VERSION != 5.7.<2->* ]] -} - -typeset -g _p9k__param_pat -typeset -g _p9k__param_sig - -_p9k_init_vars() { - typeset -gF _p9k__gcloud_last_fetch_ts - typeset -g _p9k_gcloud_configuration - typeset -g _p9k_gcloud_account - typeset -g _p9k_gcloud_project_id - typeset -g _p9k_gcloud_project_name - - typeset -gi _p9k_term_has_href - - typeset -gi _p9k_vcs_index - typeset -gi _p9k_vcs_line_index - typeset -g _p9k_vcs_side - - typeset -ga _p9k_taskwarrior_meta_files - typeset -ga _p9k_taskwarrior_meta_non_files - typeset -g _p9k_taskwarrior_meta_sig - typeset -g _p9k_taskwarrior_data_dir - typeset -g _p9k__taskwarrior_functional=1 - typeset -ga _p9k_taskwarrior_data_files - typeset -ga _p9k_taskwarrior_data_non_files - typeset -g _p9k_taskwarrior_data_sig - typeset -gA _p9k_taskwarrior_counters - typeset -gF _p9k_taskwarrior_next_due - - typeset -ga _p9k_asdf_meta_files - typeset -ga _p9k_asdf_meta_non_files - typeset -g _p9k_asdf_meta_sig - - # plugin => installed_version_pattern - # example: (ruby '2.7.0|2.6.3|system' lua 'system' chubaka '1.0.0|system') - typeset -gA _p9k_asdf_plugins - - # example: (.ruby-version "ruby 1 chubaka 0") - # - # - "1" means parse-legacy-file is present - # - "chubaka" is another plugin that claims to be able to parse .ruby-version - typeset -gA _p9k_asdf_file_info - - # dir => mtime ':' ${(pj:\0:)files} - typeset -gA _p9k__asdf_dir2files - - # :file => mtime ':' ${(pj:\0:)tool_versions} - # plugin:file => mtime ':' version - typeset -gA _p9k_asdf_file2versions - - # filepath => mtime ':' word - typeset -gA _p9k__read_word_cache - # filepath:prefix => mtime ':' versions - typeset -gA _p9k__read_pyenv_like_version_file_cache - - # _p9k__parent_dirs and _p9k__parent_mtimes are parallel arrays. They are updated - # together with _p9k__cwd. _p9k__parent_mtimes[i] is mtime for _p9k__parent_dirs[i]. - # - # When _p9k__cwd is / or ~, both arrays are empty. When _p9k__cwd is ~/foo/bar, - # _p9k__parent_dirs is (/home/user/foo/bar /home/user/foo). When _p9k__cwd is - # /foo/bar, it's (/foo/bar /foo). - # - # $_p9k__parent_mtimes_i[i] == "$i:$_p9k__parent_mtimes[i]" - # $_p9k__parent_mtimes_s == "$_p9k__parent_mtimes_i". - typeset -ga _p9k__parent_dirs - typeset -ga _p9k__parent_mtimes - typeset -ga _p9k__parent_mtimes_i - typeset -g _p9k__parent_mtimes_s - - typeset -g _p9k__cwd - typeset -g _p9k__cwd_a - - # dir/pattern => dir mtime ':' num_matches - typeset -gA _p9k__glob_cache - - # dir/pattern => space-separated parent dir mtimes ' :' the first matching parent dir - # Note: ' :' is indeed the delimiter. - typeset -gA _p9k__upsearch_cache - - typeset -g _p9k_timewarrior_dir - typeset -gi _p9k_timewarrior_dir_mtime - typeset -gi _p9k_timewarrior_file_mtime - typeset -g _p9k_timewarrior_file_name - typeset -gA _p9k__prompt_char_saved - typeset -g _p9k__worker_pid - typeset -g _p9k__worker_req_fd - typeset -g _p9k__worker_resp_fd - typeset -g _p9k__worker_shell_pid - typeset -g _p9k__worker_file_prefix - typeset -gA _p9k__worker_request_map - typeset -ga _p9k__segment_cond_left - typeset -ga _p9k__segment_cond_right - typeset -ga _p9k__segment_val_left - typeset -ga _p9k__segment_val_right - typeset -ga _p9k_show_on_command - typeset -g _p9k__last_buffer - typeset -ga _p9k__last_commands - typeset -gi _p9k__fully_initialized - typeset -gi _p9k__must_restore_prompt - typeset -gi _p9k__restore_prompt_fd - typeset -gi _p9k__redraw_fd - typeset -gi _p9k__can_hide_cursor=$(( $+terminfo[civis] && $+terminfo[cnorm] )) - if (( _p9k__can_hide_cursor )); then - # See https://github.com/romkatv/powerlevel10k/issues/1699 - if [[ $terminfo[cnorm] == *$'\e[?25h'(|'\e'*) ]]; then - typeset -g _p9k__cnorm=$'\e[?25h' - else - typeset -g _p9k__cnorm=$terminfo[cnorm] - fi - fi - typeset -gi _p9k__cursor_hidden - typeset -gi _p9k__non_hermetic_expansion - typeset -g _p9k__time - typeset -g _p9k__date - typeset -gA _p9k_dumped_instant_prompt_sigs - typeset -g _p9k__instant_prompt_sig - typeset -g _p9k__instant_prompt - typeset -gi _p9k__state_dump_scheduled - typeset -gi _p9k__state_dump_fd - typeset -gi _p9k__prompt_idx - typeset -gi _p9k_reset_on_line_finish - typeset -gF _p9k__timer_start - typeset -gi _p9k__status - typeset -ga _p9k__pipestatus - typeset -g _p9k__ret - typeset -g _p9k__cache_key - typeset -ga _p9k__cache_val - typeset -g _p9k__cache_stat_meta - typeset -g _p9k__cache_stat_fprint - typeset -g _p9k__cache_fprint_key - typeset -gA _p9k_cache - typeset -gA _p9k__cache_ephemeral - typeset -ga _p9k_t - typeset -g _p9k__n - typeset -gi _p9k__i - typeset -g _p9k__bg - typeset -ga _p9k_left_join - typeset -ga _p9k_right_join - typeset -g _p9k__public_ip - typeset -g _p9k__todo_command - typeset -g _p9k__todo_file - typeset -g _p9k__git_dir - # git workdir => 1 if gitstatus is slow on it, 0 if it's fast. - typeset -gA _p9k_git_slow - # git workdir => the last state we've seen for it - typeset -gA _p9k__gitstatus_last - typeset -gF _p9k__gitstatus_start_time - typeset -g _p9k__prompt - typeset -g _p9k__rprompt - typeset -g _p9k__lprompt - typeset -g _p9k__prompt_side - typeset -g _p9k__segment_name - typeset -gi _p9k__segment_index - typeset -gi _p9k__line_index - typeset -g _p9k__refresh_reason - typeset -gi _p9k__region_active - typeset -ga _p9k_line_segments_left - typeset -ga _p9k_line_segments_right - typeset -ga _p9k_line_prefix_left - typeset -ga _p9k_line_prefix_right - typeset -ga _p9k_line_suffix_left - typeset -ga _p9k_line_suffix_right - typeset -ga _p9k_line_never_empty_right - typeset -ga _p9k_line_gap_post - typeset -g _p9k__xy - typeset -g _p9k__clm - typeset -g _p9k__p - typeset -gi _p9k__x - typeset -gi _p9k__y - typeset -gi _p9k__m - typeset -gi _p9k__d - typeset -gi _p9k__h - typeset -gi _p9k__ind - typeset -g _p9k_gap_pre - typeset -gi _p9k__ruler_i=3 - typeset -gi _p9k_ruler_idx - typeset -gi _p9k__empty_line_i=3 - typeset -gi _p9k_empty_line_idx - typeset -g _p9k_prompt_prefix_left - typeset -g _p9k_prompt_prefix_right - typeset -g _p9k_prompt_suffix_left - typeset -g _p9k_prompt_suffix_right - typeset -gi _p9k_emulate_zero_rprompt_indent - typeset -gA _p9k_battery_states - typeset -g _p9k_os - typeset -g _p9k_os_icon - typeset -g _p9k_color1 - typeset -g _p9k_color2 - typeset -g _p9k__s - typeset -g _p9k__ss - typeset -g _p9k__sss - typeset -g _p9k__v - typeset -g _p9k__c - typeset -g _p9k__e - typeset -g _p9k__w - typeset -gi _p9k__dir_len - typeset -gi _p9k_num_cpus - typeset -g _p9k__keymap - typeset -g _p9k__zle_state - typeset -g _p9k_uname - typeset -g _p9k_uname_o - typeset -g _p9k_uname_m - typeset -g _p9k_transient_prompt - typeset -g _p9k__last_prompt_pwd - typeset -gA _p9k_display_k - typeset -ga _p9k__display_v - - typeset -gA _p9k__dotnet_stat_cache - typeset -gA _p9k__dir_stat_cache - typeset -gi _p9k__expanded - typeset -gi _p9k__force_must_init - - typeset -g P9K_VISUAL_IDENTIFIER - typeset -g P9K_CONTENT - typeset -g P9K_GAP - typeset -g P9K_PROMPT=regular -} - -_p9k_init_params() { - _p9k_declare -F POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS 60 - - # invarint: _POWERLEVEL9K_INSTANT_PROMPT == (verbose|quiet|off) - # invariant: [[ ($_POWERLEVEL9K_INSTANT_PROMPT == off) == $_POWERLEVEL9K_DISABLE_INSTANT_PROMPT ]] - _p9k_declare -s POWERLEVEL9K_INSTANT_PROMPT # verbose, quiet, off - if [[ $_POWERLEVEL9K_INSTANT_PROMPT == off ]]; then - typeset -gi _POWERLEVEL9K_DISABLE_INSTANT_PROMPT=1 - else - _p9k_declare -b POWERLEVEL9K_DISABLE_INSTANT_PROMPT 0 - if (( _POWERLEVEL9K_DISABLE_INSTANT_PROMPT )); then - _POWERLEVEL9K_INSTANT_PROMPT=off - elif [[ $_POWERLEVEL9K_INSTANT_PROMPT != quiet ]]; then - _POWERLEVEL9K_INSTANT_PROMPT=verbose - fi - fi - - (( _POWERLEVEL9K_DISABLE_INSTANT_PROMPT )) && _p9k__instant_prompt_disabled=1 - - _p9k_declare -s POWERLEVEL9K_TRANSIENT_PROMPT off - [[ $_POWERLEVEL9K_TRANSIENT_PROMPT == (off|always|same-dir) ]] || _POWERLEVEL9K_TRANSIENT_PROMPT=off - - _p9k_declare -b POWERLEVEL9K_TERM_SHELL_INTEGRATION 0 - if [[ __p9k_force_term_shell_integration -eq 1 || $ITERM_SHELL_INTEGRATION_INSTALLED == Yes ]]; then - _POWERLEVEL9K_TERM_SHELL_INTEGRATION=1 - fi - - _p9k_declare -s POWERLEVEL9K_WORKER_LOG_LEVEL - _p9k_declare -i POWERLEVEL9K_COMMANDS_MAX_TOKEN_COUNT 64 - _p9k_declare -a POWERLEVEL9K_HOOK_WIDGETS -- - _p9k_declare -b POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL 0 - _p9k_declare -b POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED 0 - _p9k_declare -b POWERLEVEL9K_DISABLE_HOT_RELOAD 0 - _p9k_declare -F POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS 5 - _p9k_declare -i POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES - _p9k_declare -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS -- context dir vcs - _p9k_declare -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS -- status root_indicator background_jobs history time - _p9k_declare -b POWERLEVEL9K_DISABLE_RPROMPT 0 - _p9k_declare -b POWERLEVEL9K_PROMPT_ADD_NEWLINE 0 - _p9k_declare -b POWERLEVEL9K_PROMPT_ON_NEWLINE 0 - _p9k_declare -b POWERLEVEL9K_RPROMPT_ON_NEWLINE 0 - _p9k_declare -b POWERLEVEL9K_SHOW_RULER 0 - _p9k_declare -i POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT 1 - _p9k_declare -s POWERLEVEL9K_COLOR_SCHEME dark - _p9k_declare -s POWERLEVEL9K_GITSTATUS_DIR "" - _p9k_declare -s POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN - _p9k_declare -b POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY 0 - _p9k_declare -i POWERLEVEL9K_VCS_SHORTEN_LENGTH - _p9k_declare -i POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH - _p9k_declare -s POWERLEVEL9K_VCS_SHORTEN_STRATEGY - if [[ $langinfo[CODESET] == (utf|UTF)(-|)8 ]]; then - _p9k_declare -e POWERLEVEL9K_VCS_SHORTEN_DELIMITER '\u2026' - else - _p9k_declare -e POWERLEVEL9K_VCS_SHORTEN_DELIMITER '..' - fi - _p9k_declare -b POWERLEVEL9K_VCS_CONFLICTED_STATE 0 - _p9k_declare -b POWERLEVEL9K_HIDE_BRANCH_ICON 0 - _p9k_declare -b POWERLEVEL9K_VCS_HIDE_TAGS 0 - _p9k_declare -i POWERLEVEL9K_CHANGESET_HASH_LENGTH 8 - # Specifies the maximum number of elements in the cache. When the cache grows over this limit, - # it gets cleared. This is meant to avoid memory leaks when a rogue prompt is filling the cache - # with data. - _p9k_declare -i POWERLEVEL9K_MAX_CACHE_SIZE 10000 - _p9k_declare -e POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" - _p9k_declare -e POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" - _p9k_declare -b POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION 1 - _p9k_declare -b POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE 1 - _p9k_declare -b POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS 0 - _p9k_declare -b POWERLEVEL9K_DISK_USAGE_ONLY_WARNING 0 - _p9k_declare -i POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 - _p9k_declare -i POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95 - _p9k_declare -i POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10 - _p9k_declare -i POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD 999 - _p9k_declare -b POWERLEVEL9K_BATTERY_VERBOSE 1 - _p9k_declare -a POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND -- - _p9k_declare -a POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND -- - case $parameters[POWERLEVEL9K_BATTERY_STAGES] in - scalar*) typeset -ga _POWERLEVEL9K_BATTERY_STAGES=("${(@s::)${(g::)POWERLEVEL9K_BATTERY_STAGES}}");; - array*) typeset -ga _POWERLEVEL9K_BATTERY_STAGES=("${(@g::)POWERLEVEL9K_BATTERY_STAGES}");; - *) typeset -ga _POWERLEVEL9K_BATTERY_STAGES=();; - esac - local state - for state in CHARGED CHARGING LOW DISCONNECTED; do - _p9k_declare -i POWERLEVEL9K_BATTERY_${state}_HIDE_ABOVE_THRESHOLD $_POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD - local var=POWERLEVEL9K_BATTERY_${state}_STAGES - case $parameters[$var] in - scalar*) eval "typeset -ga _$var=(${(@qq)${(@s::)${(g::)${(P)var}}}})";; - array*) eval "typeset -ga _$var=(${(@qq)${(@g::)${(@P)var}}})";; - *) eval "typeset -ga _$var=(${(@qq)_POWERLEVEL9K_BATTERY_STAGES})";; - esac - local var=POWERLEVEL9K_BATTERY_${state}_LEVEL_BACKGROUND - case $parameters[$var] in - array*) eval "typeset -ga _$var=(${(@qq)${(@P)var}})";; - *) eval "typeset -ga _$var=(${(@qq)_POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND})";; - esac - local var=POWERLEVEL9K_BATTERY_${state}_LEVEL_FOREGROUND - case $parameters[$var] in - array*) eval "typeset -ga _$var=(${(@qq)${(@P)var}})";; - *) eval "typeset -ga _$var=(${(@qq)_POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND})";; - esac - done - _p9k_declare -F POWERLEVEL9K_PUBLIC_IP_TIMEOUT 300 - _p9k_declare -a POWERLEVEL9K_PUBLIC_IP_METHODS -- dig curl wget - _p9k_declare -e POWERLEVEL9K_PUBLIC_IP_NONE "" - _p9k_declare -s POWERLEVEL9K_PUBLIC_IP_HOST "https://v4.ident.me/" - _p9k_declare -s POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE "" - _p9k_segment_in_use public_ip || _POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE= - _p9k_declare -b POWERLEVEL9K_ALWAYS_SHOW_CONTEXT 0 - _p9k_declare -b POWERLEVEL9K_ALWAYS_SHOW_USER 0 - _p9k_declare -e POWERLEVEL9K_CONTEXT_TEMPLATE "%n@%m" - _p9k_declare -e POWERLEVEL9K_USER_TEMPLATE "%n" - _p9k_declare -e POWERLEVEL9K_HOST_TEMPLATE "%m" - _p9k_declare -F POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3 - _p9k_declare -i POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION 2 - # Other options: "d h m s". - _p9k_declare -s POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT "H:M:S" - _p9k_declare -e POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" - _p9k_declare -b POWERLEVEL9K_DIR_PATH_ABSOLUTE 0 - _p9k_declare -s POWERLEVEL9K_DIR_SHOW_WRITABLE '' - case $_POWERLEVEL9K_DIR_SHOW_WRITABLE in - true) _POWERLEVEL9K_DIR_SHOW_WRITABLE=1;; - v2) _POWERLEVEL9K_DIR_SHOW_WRITABLE=2;; - v3) _POWERLEVEL9K_DIR_SHOW_WRITABLE=3;; - *) _POWERLEVEL9K_DIR_SHOW_WRITABLE=0;; - esac - typeset -gi _POWERLEVEL9K_DIR_SHOW_WRITABLE - _p9k_declare -b POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER 0 - _p9k_declare -b POWERLEVEL9K_DIR_HYPERLINK 0 - _p9k_declare -s POWERLEVEL9K_SHORTEN_STRATEGY "" - local markers=( - .bzr - .citc - .git - .hg - .node-version - .python-version - .ruby-version - .shorten_folder_marker - .svn - .terraform - CVS - Cargo.toml - composer.json - go.mod - package.json - ) - _p9k_declare -s POWERLEVEL9K_SHORTEN_FOLDER_MARKER "(${(j:|:)markers})" - # Shorten directory if it's longer than this even if there is space for it. - # The value can be either absolute (e.g., '80') or a percentage of terminal - # width (e.g, '50%'). If empty, directory will be shortened only when prompt - # doesn't fit. Applies only when POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique. - _p9k_declare -s POWERLEVEL9K_DIR_MAX_LENGTH 0 - # Individual elements are patterns. They are expanded with the options set - # by `emulate zsh && setopt extended_glob`. - _p9k_declare -a POWERLEVEL9K_DIR_PACKAGE_FILES -- package.json composer.json - # When dir is on the last prompt line, try to shorten it enough to leave at least this many - # columns for typing commands. Applies only when POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique. - _p9k_declare -i POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS 40 - # When dir is on the last prompt line, try to shorten it enough to leave at least - # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. Applies - # only when POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique. - _p9k_declare -F POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT 50 - # POWERLEVEL9K_DIR_CLASSES allow you to specify custom styling and icons for different - # directories. - # - # POWERLEVEL9K_DIR_CLASSES must be an array with 3 * N elements. Each triplet consists of: - # - # 1. A pattern against which the current directory is matched. Matching is done with - # extended_glob option enabled. - # 2. Directory class for the purpose of styling. - # 3. Icon. - # - # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. If there are no - # matches, there will be no icon and the styling is done according to POWERLEVEL9K_DIR_BACKGROUND, - # POWERLEVEL9K_DIR_FOREGROUND, etc. - # - # Example: - # - # POWERLEVEL9K_DIR_CLASSES=( - # '~/work(/*)#' WORK '(╯°□°)╯︵ ┻━┻' - # '~(/*)#' HOME '⌂' - # '*' DEFAULT '') - # - # POWERLEVEL9K_DIR_WORK_BACKGROUND=red - # POWERLEVEL9K_DIR_HOME_BACKGROUND=blue - # POWERLEVEL9K_DIR_DEFAULT_BACKGROUND=yellow - # - # With these settings, the current directory in the prompt may look like this: - # - # (╯°□°)╯︵ ┻━┻ ~/work/projects/important/urgent - # - # ⌂ ~/best/powerlevel10k - _p9k_declare -a POWERLEVEL9K_DIR_CLASSES - _p9k_declare -i POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH - _p9k_declare -e POWERLEVEL9K_SHORTEN_DELIMITER - _p9k_declare -s POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER '' - case $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER in - first|last) _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER+=:0;; - (first|last):(|-)<->);; - *) _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=;; - esac - [[ -z $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER ]] && _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER= - _p9k_declare -i POWERLEVEL9K_SHORTEN_DIR_LENGTH - _p9k_declare -s POWERLEVEL9K_IP_INTERFACE "" - : ${_POWERLEVEL9K_IP_INTERFACE:='.*'} - _p9k_segment_in_use ip || _POWERLEVEL9K_IP_INTERFACE= - _p9k_declare -s POWERLEVEL9K_VPN_IP_INTERFACE "(gpd|wg|(.*tun)|tailscale)[0-9]*)|(zt.*)" - : ${_POWERLEVEL9K_VPN_IP_INTERFACE:='.*'} - _p9k_segment_in_use vpn_ip || _POWERLEVEL9K_VPN_IP_INTERFACE= - _p9k_declare -b POWERLEVEL9K_VPN_IP_SHOW_ALL 0 - _p9k_declare -i POWERLEVEL9K_LOAD_WHICH 5 - case $_POWERLEVEL9K_LOAD_WHICH in - 1) _POWERLEVEL9K_LOAD_WHICH=1;; - 15) _POWERLEVEL9K_LOAD_WHICH=3;; - *) _POWERLEVEL9K_LOAD_WHICH=2;; - esac - _p9k_declare -F POWERLEVEL9K_LOAD_WARNING_PCT 50 - _p9k_declare -F POWERLEVEL9K_LOAD_CRITICAL_PCT 70 - _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 - _p9k_declare -b POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY 0 - _p9k_declare -b POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY 1 - _p9k_declare -b POWERLEVEL9K_GO_VERSION_PROJECT_ONLY 1 - _p9k_declare -b POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY 1 - _p9k_declare -b POWERLEVEL9K_PERLBREW_PROJECT_ONLY 1 - _p9k_declare -b POWERLEVEL9K_PERLBREW_SHOW_PREFIX 0 - _p9k_declare -b POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY 0 - _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -a POWERLEVEL9K_NODENV_SOURCES -- shell local global - _p9k_declare -b POWERLEVEL9K_NODENV_SHOW_SYSTEM 1 - _p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -a POWERLEVEL9K_RBENV_SOURCES -- shell local global - _p9k_declare -b POWERLEVEL9K_RBENV_SHOW_SYSTEM 1 - _p9k_declare -b POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -a POWERLEVEL9K_SCALAENV_SOURCES -- shell local global - _p9k_declare -b POWERLEVEL9K_SCALAENV_SHOW_SYSTEM 1 - _p9k_declare -b POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -a POWERLEVEL9K_PHPENV_SOURCES -- shell local global - _p9k_declare -b POWERLEVEL9K_PHPENV_SHOW_SYSTEM 1 - _p9k_declare -b POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -a POWERLEVEL9K_LUAENV_SOURCES -- shell local global - _p9k_declare -b POWERLEVEL9K_LUAENV_SHOW_SYSTEM 1 - _p9k_declare -b POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -a POWERLEVEL9K_JENV_SOURCES -- shell local global - _p9k_declare -b POWERLEVEL9K_JENV_SHOW_SYSTEM 1 - _p9k_declare -b POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -a POWERLEVEL9K_PLENV_SOURCES -- shell local global - _p9k_declare -b POWERLEVEL9K_PLENV_SHOW_SYSTEM 1 - _p9k_declare -b POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -b POWERLEVEL9K_PYENV_SHOW_SYSTEM 1 - _p9k_declare -a POWERLEVEL9K_PYENV_SOURCES -- shell local global - _p9k_declare -b POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -a POWERLEVEL9K_GOENV_SOURCES -- shell local global - _p9k_declare -b POWERLEVEL9K_GOENV_SHOW_SYSTEM 1 - _p9k_declare -b POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -b POWERLEVEL9K_ASDF_SHOW_SYSTEM 1 - _p9k_declare -a POWERLEVEL9K_ASDF_SOURCES -- shell local global - local var - for var in ${parameters[(I)POWERLEVEL9K_ASDF_*_PROMPT_ALWAYS_SHOW]}; do - _p9k_declare -b $var $_POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW - done - for var in ${parameters[(I)POWERLEVEL9K_ASDF_*_SHOW_SYSTEM]}; do - _p9k_declare -b $var $_POWERLEVEL9K_ASDF_SHOW_SYSTEM - done - for var in ${parameters[(I)POWERLEVEL9K_ASDF_*_SOURCES]}; do - _p9k_declare -a $var -- $_POWERLEVEL9K_ASDF_SOURCES - done - _p9k_declare -b POWERLEVEL9K_HASKELL_STACK_PROMPT_ALWAYS_SHOW 1 - _p9k_declare -a POWERLEVEL9K_HASKELL_STACK_SOURCES -- shell local - _p9k_declare -b POWERLEVEL9K_RVM_SHOW_GEMSET 0 - _p9k_declare -b POWERLEVEL9K_RVM_SHOW_PREFIX 0 - _p9k_declare -b POWERLEVEL9K_CHRUBY_SHOW_VERSION 1 - _p9k_declare -b POWERLEVEL9K_CHRUBY_SHOW_ENGINE 1 - _p9k_declare -s POWERLEVEL9K_CHRUBY_SHOW_ENGINE_PATTERN - if (( _POWERLEVEL9K_CHRUBY_SHOW_ENGINE )); then - : ${_POWERLEVEL9K_CHRUBY_SHOW_ENGINE_PATTERN=*} - fi - _p9k_declare -b POWERLEVEL9K_STATUS_CROSS 0 - _p9k_declare -b POWERLEVEL9K_STATUS_OK 1 - _p9k_declare -b POWERLEVEL9K_STATUS_OK_PIPE 1 - _p9k_declare -b POWERLEVEL9K_STATUS_ERROR 1 - _p9k_declare -b POWERLEVEL9K_STATUS_ERROR_PIPE 1 - _p9k_declare -b POWERLEVEL9K_STATUS_ERROR_SIGNAL 1 - _p9k_declare -b POWERLEVEL9K_STATUS_SHOW_PIPESTATUS 1 - _p9k_declare -b POWERLEVEL9K_STATUS_HIDE_SIGNAME 0 - _p9k_declare -b POWERLEVEL9K_STATUS_VERBOSE_SIGNAME 1 - _p9k_declare -b POWERLEVEL9K_STATUS_EXTENDED_STATES 0 - _p9k_declare -b POWERLEVEL9K_STATUS_VERBOSE 1 - _p9k_declare -b POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE 0 - _p9k_declare -e POWERLEVEL9K_DATE_FORMAT "%D{%d.%m.%y}" - _p9k_declare -s POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND 1 - _p9k_declare -b POWERLEVEL9K_SHOW_CHANGESET 0 - _p9k_declare -e POWERLEVEL9K_VCS_LOADING_TEXT loading - _p9k_declare -a POWERLEVEL9K_VCS_GIT_HOOKS -- vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname - _p9k_declare -a POWERLEVEL9K_VCS_HG_HOOKS -- vcs-detect-changes - _p9k_declare -a POWERLEVEL9K_VCS_SVN_HOOKS -- vcs-detect-changes svn-detect-changes - # If it takes longer than this to fetch git repo status, display the prompt with a greyed out - # vcs segment and fix it asynchronously when the results come it. - _p9k_declare -F POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS 0.01 - (( POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS >= 0 )) || (( POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS = 0 )) - _p9k_declare -a POWERLEVEL9K_VCS_BACKENDS -- git - (( $+commands[git] )) || _POWERLEVEL9K_VCS_BACKENDS=(${_POWERLEVEL9K_VCS_BACKENDS:#git}) - _p9k_declare -b POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING 0 - _p9k_declare -i POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY -1 - _p9k_declare -i POWERLEVEL9K_VCS_STAGED_MAX_NUM 1 - _p9k_declare -i POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM 1 - _p9k_declare -i POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM 1 - _p9k_declare -i POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM 1 - _p9k_declare -i POWERLEVEL9K_VCS_COMMITS_AHEAD_MAX_NUM -1 - _p9k_declare -i POWERLEVEL9K_VCS_COMMITS_BEHIND_MAX_NUM -1 - _p9k_declare -b POWERLEVEL9K_VCS_RECURSE_UNTRACKED_DIRS 0 - _p9k_declare -b POWERLEVEL9K_DISABLE_GITSTATUS 0 - _p9k_declare -e POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT" - _p9k_declare -e POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" - # VISUAL mode is shown as NORMAL unless POWERLEVEL9K_VI_VISUAL_MODE_STRING is explicitly set. - _p9k_declare -e POWERLEVEL9K_VI_VISUAL_MODE_STRING - # OVERWRITE mode is shown as INSERT unless POWERLEVEL9K_VI_OVERWRITE_MODE_STRING is explicitly set. - _p9k_declare -e POWERLEVEL9K_VI_OVERWRITE_MODE_STRING - _p9k_declare -s POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV true - _p9k_declare -b POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION 1 - _p9k_declare -e POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER "(" - _p9k_declare -e POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER ")" - _p9k_declare -a POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES -- virtualenv venv .venv env - _POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES="${(j.|.)_POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES}" - _p9k_declare -b POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION 1 - _p9k_declare -e POWERLEVEL9K_NODEENV_LEFT_DELIMITER "[" - _p9k_declare -e POWERLEVEL9K_NODEENV_RIGHT_DELIMITER "]" - _p9k_declare -b POWERLEVEL9K_KUBECONTEXT_SHOW_DEFAULT_NAMESPACE 1 - _p9k_declare -a POWERLEVEL9K_KUBECONTEXT_SHORTEN -- - # Defines context classes for the purpose of applying different styling to different contexts. - # - # POWERLEVEL9K_KUBECONTEXT_CLASSES must be an array with even number of elements. The first - # element in each pair defines a pattern against which the current context (in the format it is - # displayed in the prompt) gets matched. The second element defines context class. Patterns are - # tried in order. The first match wins. - # - # If a non-empty class <C> is assigned to a context, the segment is styled with - # POWERLEVEL9K_KUBECONTEXT_<U>_BACKGROUND and POWERLEVEL9K_KUBECONTEXT_<U>_FOREGROUND where <U> is - # uppercased <C>. Otherwise with POWERLEVEL9K_KUBECONTEXT_BACKGROUND and - # POWERLEVEL9K_KUBECONTEXT_FOREGROUND. - # - # Example: Use red background for contexts containing "prod", green for "testing" and yellow for - # everything else. - # - # POWERLEVEL9K_KUBECONTEXT_CLASSES=( - # '*prod*' prod - # '*testing*' testing - # '*' other) - # - # POWERLEVEL9K_KUBECONTEXT_PROD_BACKGROUND=red - # POWERLEVEL9K_KUBECONTEXT_TESTING_BACKGROUND=green - # POWERLEVEL9K_KUBECONTEXT_OTHER_BACKGROUND=yellow - _p9k_declare -a POWERLEVEL9K_KUBECONTEXT_CLASSES -- - _p9k_declare -a POWERLEVEL9K_AWS_CLASSES -- - _p9k_declare -a POWERLEVEL9K_AZURE_CLASSES -- - _p9k_declare -a POWERLEVEL9K_TERRAFORM_CLASSES -- - _p9k_declare -b POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT 0 - _p9k_declare -a POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES -- 'service_account:*' SERVICE_ACCOUNT - # Specifies the format of java version. - # - # POWERLEVEL9K_JAVA_VERSION_FULL=true => 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03 - # POWERLEVEL9K_JAVA_VERSION_FULL=false => 1.8.0_212 - # - # These correspond to `java -fullversion` and `java -version` respectively. - _p9k_declare -b POWERLEVEL9K_JAVA_VERSION_FULL 1 - _p9k_declare -b POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE 0 - - # Format for the current time: 09:51:02. See `man 3 strftime`. - _p9k_declare -e POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}" - # If set to true, time will update when you hit enter. This way prompts for the past - # commands will contain the start times of their commands as opposed to the default - # behavior where they contain the end times of their preceding commands. - _p9k_declare -b POWERLEVEL9K_TIME_UPDATE_ON_COMMAND 0 - # If set to true, time will update every second. - _p9k_declare -b POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME 0 - - local -i i=1 - while (( i <= $#_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS )); do - local segment=${${(U)_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[i]}//İ/I} - local var=POWERLEVEL9K_${segment}_LEFT_DISABLED - (( $+parameters[$var] )) || var=POWERLEVEL9K_${segment}_DISABLED - if [[ ${(P)var} == true ]]; then - _POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[i,i]=() - else - (( ++i )) - fi - done - - local -i i=1 - while (( i <= $#_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS )); do - local segment=${${(U)_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[i]}//İ/I} - local var=POWERLEVEL9K_${segment}_RIGHT_DISABLED - (( $+parameters[$var] )) || var=POWERLEVEL9K_${segment}_DISABLED - if [[ ${(P)var} == true ]]; then - _POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[i,i]=() - else - (( ++i )) - fi - done - - local var - for var in ${(@)${parameters[(I)POWERLEVEL9K_*]}/(#m)*/${(M)${parameters[_$MATCH]-$MATCH}:#$MATCH}}; do - case $parameters[$var] in - (scalar|integer|float)*) typeset -g _$var=${(P)var};; - array*) eval 'typeset -ga '_$var'=("${'$var'[@]}")';; - esac - done -} - -function _p9k_on_widget_zle-keymap-select() { _p9k_check_visual_mode; __p9k_reset_state=2; } -function _p9k_on_widget_overwrite-mode() { _p9k_check_visual_mode; __p9k_reset_state=2; } -function _p9k_on_widget_vi-replace() { _p9k_check_visual_mode; __p9k_reset_state=2; } - -if [[ $ZSH_VERSION == (5.<3->*|<6->.*) ]]; then - function _p9k_check_visual_mode() { - [[ ${KEYMAP:-} == vicmd ]] || return 0 - local region=${${REGION_ACTIVE:-0}/2/1} - [[ $region != $_p9k__region_active ]] || return 0 - _p9k__region_active=$region - __p9k_reset_state=2 - } -else - function _p9k_check_visual_mode() {} -fi - -function _p9k_on_widget_visual-mode() { _p9k_check_visual_mode; } -function _p9k_on_widget_visual-line-mode() { _p9k_check_visual_mode; } -function _p9k_on_widget_deactivate-region() { _p9k_check_visual_mode; } - -function _p9k_on_widget_zle-line-init() { - (( _p9k__cursor_hidden )) || return 0 - _p9k__cursor_hidden=0 - print -rn -- $_p9k__cnorm -} - -function _p9k_on_widget_zle-line-finish() { - (( $+_p9k__line_finished )) && return - - local P9K_PROMPT=transient - - _p9k__line_finished= - (( _p9k_reset_on_line_finish )) && __p9k_reset_state=2 - (( $+functions[p10k-on-post-prompt] )) && p10k-on-post-prompt - - local -i optimized - - if [[ -n $_p9k_transient_prompt ]]; then - if [[ $_POWERLEVEL9K_TRANSIENT_PROMPT == always || $_p9k__cwd == $_p9k__last_prompt_pwd ]]; then - optimized=1 - __p9k_reset_state=2 - else - _p9k__last_prompt_pwd=$_p9k__cwd - fi - fi - - if [[ $1 == int ]]; then - _p9k__must_restore_prompt=1 - if (( !_p9k__restore_prompt_fd )); then - sysopen -o cloexec -ru _p9k__restore_prompt_fd /dev/null - zle -F $_p9k__restore_prompt_fd _p9k_restore_prompt - fi - fi - - if (( __p9k_reset_state == 2 )); then - if (( optimized )); then - RPROMPT= PROMPT=$_p9k_transient_prompt _p9k_reset_prompt - else - _p9k_reset_prompt - fi - fi - - _p9k__line_finished='%{%}' -} - -function _p9k_on_widget_send-break() { - _p9k_on_widget_zle-line-finish int -} - -# Usage example: _p9k_display_segment 58 _p9k__1rkubecontext hide -function _p9k_display_segment() { - [[ $_p9k__display_v[$1] == $3 ]] && return - _p9k__display_v[$1]=$3 - [[ $3 == hide ]] && typeset -g $2= || unset $2 - __p9k_reset_state=2 -} - -function _p9k_redraw() { - zle -F $1 - exec {1}>&- - _p9k__redraw_fd=0 - - () { - local -h WIDGET=zle-line-pre-redraw - _p9k_widget_hook '' - } -} - -function _p9k_deschedule_redraw() { - (( _p9k__redraw_fd )) || return - zle -F $_p9k__redraw_fd - exec {_p9k__redraw_fd}>&- - _p9k__redraw_fd=0 -} - -function _p9k_widget_hook() { - _p9k_deschedule_redraw - - if (( ${+functions[p10k-on-post-widget]} || ${#_p9k_show_on_command} )); then - local -a P9K_COMMANDS - if [[ "$_p9k__last_buffer" == "$PREBUFFER$BUFFER" ]]; then - P9K_COMMANDS=(${_p9k__last_commands[@]}) - else - _p9k__last_buffer="$PREBUFFER$BUFFER" - if [[ -n "$_p9k__last_buffer" ]]; then - # this must run with user options - _p9k_parse_buffer "$_p9k__last_buffer" $_POWERLEVEL9K_COMMANDS_MAX_TOKEN_COUNT - fi - _p9k__last_commands=(${P9K_COMMANDS[@]}) - fi - fi - - eval "$__p9k_intro" - (( _p9k__restore_prompt_fd )) && _p9k_restore_prompt $_p9k__restore_prompt_fd - if [[ $1 == (clear-screen|z4h-clear-screen-*-top) ]]; then - P9K_TTY=new - _p9k__expanded=0 - _p9k_reset_prompt - fi - __p9k_reset_state=1 - _p9k_check_visual_mode - local pat idx var - for pat idx var in $_p9k_show_on_command; do - if (( $P9K_COMMANDS[(I)$pat] )); then - _p9k_display_segment $idx $var show - else - _p9k_display_segment $idx $var hide - fi - done - (( $+functions[p10k-on-post-widget] )) && p10k-on-post-widget "${@:2}" - (( $+functions[_p9k_on_widget_$1] )) && _p9k_on_widget_$1 - (( __p9k_reset_state == 2 )) && _p9k_reset_prompt - __p9k_reset_state=0 -} - -function _p9k_widget() { - local f=${widgets[._p9k_orig_$1]:-} - local -i res - [[ -z $f ]] || { - [[ $f == user:-z4h-* ]] && { - "${f#user:}" "${@:2}" - res=$? - } || { - zle ._p9k_orig_$1 -- "${@:2}" - res=$? - } - } - (( ! __p9k_enabled )) || [[ $CONTEXT != start ]] || _p9k_widget_hook "$@" - return res -} - -function _p9k_widget_zle-line-pre-redraw-impl() { - (( __p9k_enabled )) && [[ $CONTEXT == start ]] || return 0 - ! (( ${+functions[p10k-on-post-widget]} || ${#_p9k_show_on_command} || _p9k__restore_prompt_fd || _p9k__redraw_fd )) && - [[ ${KEYMAP:-} != vicmd ]] && - return - (( PENDING || KEYS_QUEUED_COUNT )) && { - (( _p9k__redraw_fd )) || { - sysopen -o cloexec -ru _p9k__redraw_fd /dev/null - zle -F $_p9k__redraw_fd _p9k_redraw - } - return - } - _p9k_widget_hook zle-line-pre-redraw -} - -function _p9k_widget_send-break() { - (( ! __p9k_enabled )) || [[ $CONTEXT != start ]] || { - _p9k_widget_hook send-break "$@" - } - local f=${widgets[._p9k_orig_send-break]:-} - [[ -z $f ]] || zle ._p9k_orig_send-break -- "$@" -} - -typeset -gi __p9k_widgets_wrapped=0 - -function _p9k_wrap_widgets() { - (( __p9k_widgets_wrapped )) && return - - typeset -gir __p9k_widgets_wrapped=1 - local -a widget_list - if [[ $ZSH_VERSION == (5.<3->*|<6->.*) ]]; then - local -aU widget_list=( - zle-line-pre-redraw - zle-line-init - zle-line-finish - zle-keymap-select - overwrite-mode - vi-replace - visual-mode - visual-line-mode - deactivate-region - clear-screen - z4h-clear-screen-soft-top - z4h-clear-screen-hard-top - send-break - $_POWERLEVEL9K_HOOK_WIDGETS - ) - else - # There is no zle-line-pre-redraw in zsh < 5.3, so we have to wrap all widgets - # with key bindings. This costs extra 3ms: 1.5ms to fetch the list of widgets and - # another 1.5ms to wrap them. - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - local keymap tmp=$tmpdir/p10k.bindings.$sysparams[pid] - { - for keymap in $keymaps; do bindkey -M $keymap; done >$tmp - local -aU widget_list=( - zle-isearch-exit - zle-isearch-update - zle-line-init - zle-line-finish - zle-history-line-set - zle-keymap-select - send-break - $_POWERLEVEL9K_HOOK_WIDGETS - ${${${(f)"$(<$tmp)"}##* }:#(*\"|.*)} - ) - } always { - zf_rm -f -- $tmp - } - fi - - local widget - for widget in $widget_list; do - if (( ! $+functions[_p9k_widget_$widget] )); then - functions[_p9k_widget_$widget]='_p9k_widget '${(q)widget}' "$@"' - fi - if [[ $widget == zle-* && - $widgets[$widget] == user:azhw:* && - $functions[add-zle-hook-widget] ]]; then - add-zle-hook-widget $widget _p9k_widget_$widget - else - # The leading dot is to work around bugs in zsh-syntax-highlighting. - zle -A $widget ._p9k_orig_$widget - zle -N $widget _p9k_widget_$widget - fi - done 2>/dev/null # `zle -A` fails for inexisting widgets and complains to stderr - - case ${widgets[._p9k_orig_zle-line-pre-redraw]:-} in - user:-z4h-zle-line-pre-redraw) - function _p9k_widget_zle-line-pre-redraw() { - -z4h-zle-line-pre-redraw "$@" - _p9k_widget_zle-line-pre-redraw-impl - } - ;; - ?*) - function _p9k_widget_zle-line-pre-redraw() { - zle ._p9k_orig_zle-line-pre-redraw -- "$@" - local -i res=$? - _p9k_widget_zle-line-pre-redraw-impl - return res - } - ;; - '') - function _p9k_widget_zle-line-pre-redraw() { - _p9k_widget_zle-line-pre-redraw-impl - } - ;; - esac -} - -function _p9k_restore_prompt() { - eval "$__p9k_intro" - zle -F $1 - exec {1}>&- - _p9k__restore_prompt_fd=0 - - (( _p9k__must_restore_prompt )) || return 0 - _p9k__must_restore_prompt=0 - - unset _p9k__line_finished - _p9k__refresh_reason=restore - _p9k_set_prompt - _p9k__refresh_reason= - - _p9k__expanded=0 - _p9k_reset_prompt -} - -prompt__p9k_internal_nothing() { _p9k__prompt+='${_p9k__sss::=}'; } -instant_prompt__p9k_internal_nothing() { prompt__p9k_internal_nothing; } - -# _p9k_build_gap_post line_number -_p9k_build_gap_post() { - if [[ $1 == 1 ]]; then - local kind_l=first kind_u=FIRST - else - local kind_l=newline kind_u=NEWLINE - fi - _p9k_get_icon '' MULTILINE_${kind_u}_PROMPT_GAP_CHAR - local char=${_p9k__ret:- } - _p9k_prompt_length $char - if (( _p9k__ret != 1 || $#char != 1 )); then - >&2 print -rP -- "%F{red}WARNING!%f %BMULTILINE_${kind_u}_PROMPT_GAP_CHAR%b is not one character long. Will use ' '." - >&2 print -rP -- "Either change the value of %BPOWERLEVEL9K_MULTILINE_${kind_u}_PROMPT_GAP_CHAR%b or remove it." - char=' ' - fi - local style - _p9k_color prompt_multiline_${kind_l}_prompt_gap BACKGROUND "" - [[ -n $_p9k__ret ]] && _p9k_background $_p9k__ret - style+=$_p9k__ret - _p9k_color prompt_multiline_${kind_l}_prompt_gap FOREGROUND "" - [[ -n $_p9k__ret ]] && _p9k_foreground $_p9k__ret - style+=$_p9k__ret - _p9k_escape_style $style - style=$_p9k__ret - local exp=_POWERLEVEL9K_MULTILINE_${kind_u}_PROMPT_GAP_EXPANSION - (( $+parameters[$exp] )) && exp=${(P)exp} || exp='${P9K_GAP}' - [[ $char == '.' ]] && local s=',' || local s='.' - _p9k__ret=$'${${_p9k__g+\n}:-'$style'${${${_p9k__m:#-*}:+' - _p9k__ret+='${${_p9k__'$1'g+${(pl.$((_p9k__m+1)).. .)}}:-' - if [[ $exp == '${P9K_GAP}' ]]; then - _p9k__ret+='${(pl'$s'$((_p9k__m+1))'$s$s$char$s')}' - else - _p9k__ret+='${${P9K_GAP::=${(pl'$s'$((_p9k__m+1))'$s$s$char$s')}}+}' - _p9k__ret+='${:-"'$exp'"}' - style=1 - fi - _p9k__ret+='}' - if (( __p9k_ksh_arrays )); then - _p9k__ret+=$'$_p9k__rprompt${_p9k_t[$((!_p9k__ind))]}}:-\n}' - else - _p9k__ret+=$'$_p9k__rprompt${_p9k_t[$((1+!_p9k__ind))]}}:-\n}' - fi - [[ -n $style ]] && _p9k__ret+='%b%k%f' - _p9k__ret+='}' -} - -_p9k_init_lines() { - local -a left_segments=($_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS) - local -a right_segments=($_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) - - if (( _POWERLEVEL9K_PROMPT_ON_NEWLINE )); then - left_segments+=(newline _p9k_internal_nothing) - fi - - local -i num_left_lines=$((1 + ${#${(@M)left_segments:#newline}})) - local -i num_right_lines=$((1 + ${#${(@M)right_segments:#newline}})) - if (( num_right_lines > num_left_lines )); then - repeat $((num_right_lines - num_left_lines)) left_segments=(newline $left_segments) - local -i num_lines=num_right_lines - else - if (( _POWERLEVEL9K_RPROMPT_ON_NEWLINE )); then - repeat $((num_left_lines - num_right_lines)) right_segments=(newline $right_segments) - else - repeat $((num_left_lines - num_right_lines)) right_segments+=newline - fi - local -i num_lines=num_left_lines - fi - - local -i i - for i in {1..$num_lines}; do - local -i left_end=${left_segments[(i)newline]} - local -i right_end=${right_segments[(i)newline]} - _p9k_line_segments_left+="${(pj:\0:)left_segments[1,left_end-1]}" - _p9k_line_segments_right+="${(pj:\0:)right_segments[1,right_end-1]}" - (( left_end > $#left_segments )) && left_segments=() || shift left_end left_segments - (( right_end > $#right_segments )) && right_segments=() || shift right_end right_segments - - _p9k_get_icon '' LEFT_SEGMENT_SEPARATOR - _p9k_get_icon 'prompt_empty_line' LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL $_p9k__ret - _p9k_escape $_p9k__ret - _p9k_line_prefix_left+='${_p9k__'$i'l-${${:-${_p9k__bg::=NONE}${_p9k__i::=0}${_p9k__sss::=%f'$_p9k__ret'}}+}' - _p9k_line_suffix_left+='%b%k$_p9k__sss%b%k%f' - - _p9k_escape ${(g::)_POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL} - [[ -n $_p9k__ret ]] && _p9k_line_never_empty_right+=1 || _p9k_line_never_empty_right+=0 - _p9k_line_prefix_right+='${_p9k__'$i'r-${${:-${_p9k__bg::=NONE}${_p9k__i::=0}${_p9k__sss::='$_p9k__ret'}}+}' - _p9k_line_suffix_right+='$_p9k__sss%b%k%f}' # gets overridden for _p9k_emulate_zero_rprompt_indent - if (( i == num_lines )); then - # it's safe to use _p9k_prompt_length on the last line because it cannot have prompt connection - _p9k_prompt_length ${(e)_p9k__ret} - (( _p9k__ret )) || _p9k_line_never_empty_right[-1]=0 - fi - done - - _p9k_get_icon '' LEFT_SEGMENT_END_SEPARATOR - if [[ -n $_p9k__ret ]]; then - _p9k__ret+=%b%k%f - # Not escaped for historical reasons. - _p9k__ret='${:-"'$_p9k__ret'"}' - if (( _POWERLEVEL9K_PROMPT_ON_NEWLINE )); then - _p9k_line_suffix_left[-2]+=$_p9k__ret - else - _p9k_line_suffix_left[-1]+=$_p9k__ret - fi - fi - - for i in {1..$num_lines}; do _p9k_line_suffix_left[i]+='}'; done - - if (( num_lines > 1 )); then - for i in {1..$((num_lines-1))}; do - _p9k_build_gap_post $i - _p9k_line_gap_post+=$_p9k__ret - done - - if [[ $+_POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX == 1 || $_POWERLEVEL9K_PROMPT_ON_NEWLINE == 1 ]]; then - _p9k_get_icon '' MULTILINE_FIRST_PROMPT_PREFIX - if [[ -n $_p9k__ret ]]; then - [[ _p9k__ret == *%* ]] && _p9k__ret+=%b%k%f - # Not escaped for historical reasons. - _p9k__ret='${_p9k__1l_frame-"'$_p9k__ret'"}' - _p9k_line_prefix_left[1]=$_p9k__ret$_p9k_line_prefix_left[1] - fi - fi - - if [[ $+_POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX == 1 || $_POWERLEVEL9K_PROMPT_ON_NEWLINE == 1 ]]; then - _p9k_get_icon '' MULTILINE_LAST_PROMPT_PREFIX - if [[ -n $_p9k__ret ]]; then - [[ _p9k__ret == *%* ]] && _p9k__ret+=%b%k%f - # Not escaped for historical reasons. - _p9k__ret='${_p9k__'$num_lines'l_frame-"'$_p9k__ret'"}' - _p9k_line_prefix_left[-1]=$_p9k__ret$_p9k_line_prefix_left[-1] - fi - fi - - _p9k_get_icon '' MULTILINE_FIRST_PROMPT_SUFFIX - if [[ -n $_p9k__ret ]]; then - [[ _p9k__ret == *%* ]] && _p9k__ret+=%b%k%f - _p9k_line_suffix_right[1]+='${_p9k__1r_frame-'${(qqq)_p9k__ret}'}' - _p9k_line_never_empty_right[1]=1 - fi - - _p9k_get_icon '' MULTILINE_LAST_PROMPT_SUFFIX - if [[ -n $_p9k__ret ]]; then - [[ _p9k__ret == *%* ]] && _p9k__ret+=%b%k%f - _p9k_line_suffix_right[-1]+='${_p9k__'$num_lines'r_frame-'${(qqq)_p9k__ret}'}' - # it's safe to use _p9k_prompt_length on the last line because it cannot have prompt connection - _p9k_prompt_length $_p9k__ret - (( _p9k__ret )) && _p9k_line_never_empty_right[-1]=1 - fi - - if (( num_lines > 2 )); then - if [[ $+_POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX == 1 || $_POWERLEVEL9K_PROMPT_ON_NEWLINE == 1 ]]; then - _p9k_get_icon '' MULTILINE_NEWLINE_PROMPT_PREFIX - if [[ -n $_p9k__ret ]]; then - [[ _p9k__ret == *%* ]] && _p9k__ret+=%b%k%f - for i in {2..$((num_lines-1))}; do - # Not escaped for historical reasons. - _p9k_line_prefix_left[i]='${_p9k__'$i'l_frame-"'$_p9k__ret'"}'$_p9k_line_prefix_left[i] - done - fi - fi - - _p9k_get_icon '' MULTILINE_NEWLINE_PROMPT_SUFFIX - if [[ -n $_p9k__ret ]]; then - [[ _p9k__ret == *%* ]] && _p9k__ret+=%b%k%f - for i in {2..$((num_lines-1))}; do - _p9k_line_suffix_right[i]+='${_p9k__'$i'r_frame-'${(qqq)_p9k__ret}'}' - done - _p9k_line_never_empty_right[2,-2]=${(@)_p9k_line_never_empty_right[2,-2]/0/1} - fi - fi - fi -} - -_p9k_all_params_eq() { - local key - for key in ${parameters[(I)${~1}]}; do - [[ ${(P)key} == $2 ]] || return - done -} - -_p9k_init_display() { - _p9k_display_k=(empty_line 1 ruler 3) - local -i n=3 i - local name - for i in {1..$#_p9k_line_segments_left}; do - local -i j=$((-$#_p9k_line_segments_left+i-1)) - _p9k_display_k+=( - $i $((n+=2)) $j $n - $i/left_frame $((n+=2)) $j/left_frame $n - $i/right_frame $((n+=2)) $j/right_frame $n - $i/left $((n+=2)) $j/left $n - $i/right $((n+=2)) $j/right $n - $i/gap $((n+=2)) $j/gap $n) - for name in ${${(@0)_p9k_line_segments_left[i]}%_joined}; do - _p9k_display_k+=($i/left/$name $((n+=2)) $j/left/$name $n) - done - for name in ${${(@0)_p9k_line_segments_right[i]}%_joined}; do - _p9k_display_k+=($i/right/$name $((n+=2)) $j/right/$name $n) - done - done -} - -_p9k_init_prompt() { - _p9k_t=($'\n' $'%{\n%}' '') - _p9k_prompt_overflow_bug && _p9k_t[2]=$'%{%G\n%}' - - _p9k_init_lines - - _p9k_gap_pre='${${:-${_p9k__x::=0}${_p9k__y::=1024}${_p9k__p::=$_p9k__lprompt$_p9k__rprompt}' - repeat 10; do - _p9k_gap_pre+='${_p9k__m::=$(((_p9k__x+_p9k__y)/2))}' - _p9k_gap_pre+='${_p9k__xy::=${${(%):-$_p9k__p%$_p9k__m(l./$_p9k__m;$_p9k__y./$_p9k__x;$_p9k__m)}##*/}}' - _p9k_gap_pre+='${_p9k__x::=${_p9k__xy%;*}}' - _p9k_gap_pre+='${_p9k__y::=${_p9k__xy#*;}}' - done - _p9k_gap_pre+='${_p9k__m::=$((_p9k__clm-_p9k__x-_p9k__ind-1))}' - _p9k_gap_pre+='}+}' - - _p9k_prompt_prefix_left='${${_p9k__clm::=$COLUMNS}+}${${COLUMNS::=1024}+}' - _p9k_prompt_prefix_right='${_p9k__'$#_p9k_line_segments_left'-${${_p9k__clm::=$COLUMNS}+}${${COLUMNS::=1024}+}' - _p9k_prompt_suffix_left='${${COLUMNS::=$_p9k__clm}+}' - _p9k_prompt_suffix_right='${${COLUMNS::=$_p9k__clm}+}}' - - if _p9k_segment_in_use vi_mode || _p9k_segment_in_use prompt_char; then - _p9k_prompt_prefix_left+='${${_p9k__keymap::=${KEYMAP:-$_p9k__keymap}}+}' - fi - if { _p9k_segment_in_use vi_mode && (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )) } || - { _p9k_segment_in_use prompt_char && (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )) }; then - _p9k_prompt_prefix_left+='${${_p9k__zle_state::=${ZLE_STATE:-$_p9k__zle_state}}+}' - fi - _p9k_prompt_prefix_left+='%b%k%f' - - # Bug fixed in: https://github.com/zsh-users/zsh/commit/3eea35d0853bddae13fa6f122669935a01618bf9. - # If affects most terminals when RPROMPT is non-empty and ZLE_RPROMPT_INDENT is zero. - # We can work around it as long as RPROMPT ends with a space. - if [[ -n $_p9k_line_segments_right[-1] && $_p9k_line_never_empty_right[-1] == 0 && - $ZLE_RPROMPT_INDENT == 0 ]] && - _p9k_all_params_eq '_POWERLEVEL9K_*WHITESPACE_BETWEEN_RIGHT_SEGMENTS' ' ' && - _p9k_all_params_eq '_POWERLEVEL9K_*RIGHT_RIGHT_WHITESPACE' ' ' && - _p9k_all_params_eq '_POWERLEVEL9K_*RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL' '' && - [[ $ZSH_VERSION != (5.7.<2->*|5.<8->*|<6->.*) ]]; then - _p9k_emulate_zero_rprompt_indent=1 - _p9k_prompt_prefix_left+='${${:-${_p9k__real_zle_rprompt_indent:=$ZLE_RPROMPT_INDENT}${ZLE_RPROMPT_INDENT::=1}${_p9k__ind::=0}}+}' - _p9k_line_suffix_right[-1]='${_p9k__sss:+${_p9k__sss% }%E}}' - else - _p9k_emulate_zero_rprompt_indent=0 - _p9k_prompt_prefix_left+='${${_p9k__ind::=${${ZLE_RPROMPT_INDENT:-1}/#-*/0}}+}' - fi - - if (( _POWERLEVEL9K_TERM_SHELL_INTEGRATION )); then - _p9k_prompt_prefix_left+=$'%{\e]133;A\a%}' - _p9k_prompt_suffix_left+=$'%{\e]133;B\a%}' - if (( $+_z4h_iterm_cmd && _z4h_can_save_restore_screen == 1 )); then - _p9k_prompt_prefix_left+=$'%{\ePtmux;\e\e]133;A\a\e\\%}' - _p9k_prompt_suffix_left+=$'%{\ePtmux;\e\e]133;B\a\e\\%}' - fi - fi - - if (( _POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT > 0 )); then - _p9k_t+=${(pl.$_POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT..\n.)} - else - _p9k_t+='' - fi - _p9k_empty_line_idx=$#_p9k_t - if (( __p9k_ksh_arrays )); then - _p9k_prompt_prefix_left+='${_p9k_t[${_p9k__empty_line_i:-'$#_p9k_t'}-1]}' - else - _p9k_prompt_prefix_left+='${_p9k_t[${_p9k__empty_line_i:-'$#_p9k_t'}]}' - fi - - local -i num_lines=$#_p9k_line_segments_left - if (( $+terminfo[cuu1] )); then - _p9k_escape $terminfo[cuu1] - if (( __p9k_ksh_arrays )); then - local scroll=$'${_p9k_t[${_p9k__ruler_i:-1}-1]:+\n'$_p9k__ret'}' - else - local scroll=$'${_p9k_t[${_p9k__ruler_i:-1}]:+\n'$_p9k__ret'}' - fi - if (( num_lines > 1 )); then - local -i line_index= - for line_index in {1..$((num_lines-1))}; do - scroll='${_p9k__'$line_index-$'\n}'$scroll'${_p9k__'$line_index-$_p9k__ret'}' - done - fi - _p9k_prompt_prefix_left+='%{${_p9k__ipe-'$scroll'}%}' - fi - - _p9k_get_icon '' RULER_CHAR - local ruler_char=$_p9k__ret - _p9k_prompt_length $ruler_char - (( _p9k__ret == 1 && $#ruler_char == 1 )) || ruler_char=' ' - _p9k_color prompt_ruler BACKGROUND "" - if [[ -z $_p9k__ret && $ruler_char == ' ' ]]; then - local ruler=$'\n' - else - _p9k_background $_p9k__ret - local ruler=%b$_p9k__ret - _p9k_color prompt_ruler FOREGROUND "" - _p9k_foreground $_p9k__ret - ruler+=$_p9k__ret - [[ $ruler_char == '.' ]] && local sep=',' || local sep='.' - ruler+='${(pl'$sep'${$((_p9k__clm-_p9k__ind))/#-*/0}'$sep$sep$ruler_char$sep')}%k%f' - if (( __p9k_ksh_arrays )); then - ruler+='${_p9k_t[$((!_p9k__ind))]}' - else - ruler+='${_p9k_t[$((1+!_p9k__ind))]}' - fi - fi - _p9k_t+=$ruler - _p9k_ruler_idx=$#_p9k_t - if (( __p9k_ksh_arrays )); then - _p9k_prompt_prefix_left+='${(e)_p9k_t[${_p9k__ruler_i:-'$#_p9k_t'}-1]}' - else - _p9k_prompt_prefix_left+='${(e)_p9k_t[${_p9k__ruler_i:-'$#_p9k_t'}]}' - fi - - ( _p9k_segment_in_use time && (( _POWERLEVEL9K_TIME_UPDATE_ON_COMMAND )) ) - _p9k_reset_on_line_finish=$((!$?)) - - _p9k_t+=$_p9k_gap_pre - _p9k_gap_pre='${(e)_p9k_t['$(($#_p9k_t - __p9k_ksh_arrays))']}' - _p9k_t+=$_p9k_prompt_prefix_left - _p9k_prompt_prefix_left='${(e)_p9k_t['$(($#_p9k_t - __p9k_ksh_arrays))']}' -} - -_p9k_init_ssh() { - # The following code is based on Pure: - # https://github.com/sindresorhus/pure/blob/e8abf9d37185ec9b7b4398ca9c5eba555a1028eb/pure.zsh. - # - # License: https://github.com/sindresorhus/pure/blob/e8abf9d37185ec9b7b4398ca9c5eba555a1028eb/license. - - [[ -n $P9K_SSH ]] && return - typeset -gix P9K_SSH=0 - if [[ -n $SSH_CLIENT || -n $SSH_TTY || -n $SSH_CONNECTION ]]; then - P9K_SSH=1 - return 0 - fi - - # When changing user on a remote system, the $SSH_CONNECTION environment variable can be lost. - # Attempt detection via `who`. - (( $+commands[who] )) || return - - local ipv6='(([0-9a-fA-F]+:)|:){2,}[0-9a-fA-F]+' # Simplified, only checks partial pattern. - local ipv4='([0-9]{1,3}\.){3}[0-9]+' # Simplified, allows invalid ranges. - # Assume two non-consecutive periods represents a hostname. Matches `x.y.z`, but not `x.y`. - local hostname='([.][^. ]+){2}' - - local w - w="$(who -m 2>/dev/null)" || w=${(@M)${(f)"$(who 2>/dev/null)"}:#*[[:space:]]${TTY#/dev/}[[:space:]]*} - - # Usually the remote address is surrounded by parenthesis but not on all systems (e.g., Busybox). - [[ $w =~ "\(?($ipv4|$ipv6|$hostname)\)?\$" ]] && P9K_SSH=1 -} - -_p9k_init_toolbox() { - [[ -z $P9K_TOOLBOX_NAME ]] || return 0 - if [[ -f /run/.containerenv && -r /run/.containerenv ]]; then - local name=(${(Q)${${(@M)${(f)"$(</run/.containerenv)"}:#name=*}#name=}}) - [[ ${#name} -eq 1 && -n ${name[1]} ]] || return 0 - typeset -g P9K_TOOLBOX_NAME=${name[1]} - elif [[ -n $DISTROBOX_ENTER_PATH ]]; then - local name=${(%):-%m} - # $NAME can be empty, see https://github.com/romkatv/powerlevel10k/pull/1916. - if [[ -n $name && $name == $NAME* ]]; then - typeset -g P9K_TOOLBOX_NAME=$name - fi - fi -} - -_p9k_must_init() { - (( _POWERLEVEL9K_DISABLE_HOT_RELOAD && !_p9k__force_must_init )) && return 1 - _p9k__force_must_init=0 - local IFS sig - if [[ -n $_p9k__param_sig ]]; then - IFS=$'\2' sig="${(e)_p9k__param_pat}" - [[ $sig == $_p9k__param_sig ]] && return 1 - _p9k_deinit - fi - _p9k__param_pat=$'v137\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1' - _p9k__param_pat+=$__p9k_force_term_shell_integration$'\1' - _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' - _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' - _p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1' - _p9k__param_pat+=$'$__p9k_sh_glob\1$__p9k_ksh_arrays\1$ITERM_SHELL_INTEGRATION_INSTALLED\1' - _p9k__param_pat+=$'${PROMPT_EOL_MARK-%B%S%#%s%b}\1$+commands[locale]\1$langinfo[CODESET]\1' - _p9k__param_pat+=$'${(M)VTE_VERSION:#(<1-4602>|4801)}\1$DEFAULT_USER\1$P9K_SSH\1$+commands[uname]\1' - _p9k__param_pat+=$'$__p9k_root_dir\1$functions[p10k-on-init]\1$functions[p10k-on-pre-prompt]\1' - _p9k__param_pat+=$'$functions[p10k-on-post-widget]\1$functions[p10k-on-post-prompt]\1' - _p9k__param_pat+=$'$+commands[git]\1$terminfo[colors]\1${+_z4h_iterm_cmd}\1' - _p9k__param_pat+=$'$_z4h_can_save_restore_screen' - local MATCH - IFS=$'\1' _p9k__param_pat+="${(@)${(@o)parameters[(I)POWERLEVEL9K_*]}:/(#m)*/\${${(q)MATCH}-$IFS\}}" - IFS=$'\2' _p9k__param_sig="${(e)_p9k__param_pat}" -} - -function _p9k_set_os() { - _p9k_os=$1 - _p9k_get_icon prompt_os_icon $2 - _p9k_os_icon=$_p9k__ret -} - -function _p9k_init_cacheable() { - _p9k_init_icons - _p9k_init_params - _p9k_init_prompt - _p9k_init_display - - # https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#backward-compatibility - if [[ $VTE_VERSION != (<1-4602>|4801) ]]; then - _p9k_term_has_href=1 - fi - - local elem func - local -i i=0 - - for i in {1..$#_p9k_line_segments_left}; do - for elem in ${${${(@0)_p9k_line_segments_left[i]}%_joined}//-/_}; do - local var=POWERLEVEL9K_${${(U)elem}//İ/I}_SHOW_ON_COMMAND - (( $+parameters[$var] )) || continue - _p9k_show_on_command+=( - $'(|*[/\0])('${(j.|.)${(P)var}}')' - $((1+_p9k_display_k[$i/left/$elem])) - _p9k__${i}l$elem) - done - for elem in ${${${(@0)_p9k_line_segments_right[i]}%_joined}//-/_}; do - local var=POWERLEVEL9K_${${(U)elem}//İ/I}_SHOW_ON_COMMAND - (( $+parameters[$var] )) || continue - local cmds=(${(P)var}) - _p9k_show_on_command+=( - $'(|*[/\0])('${(j.|.)${(P)var}}')' - $((1+$_p9k_display_k[$i/right/$elem])) - _p9k__${i}r$elem) - done - done - - if [[ $_POWERLEVEL9K_TRANSIENT_PROMPT != off ]]; then - local sep=$'\1' - _p9k_transient_prompt='%b%k%s%u%(?'$sep - _p9k_color prompt_prompt_char_OK_VIINS FOREGROUND 76 - _p9k_foreground $_p9k__ret - _p9k_transient_prompt+=$_p9k__ret - _p9k_transient_prompt+='${${P9K_CONTENT::="❯"}+}' - _p9k_param prompt_prompt_char_OK_VIINS CONTENT_EXPANSION '${P9K_CONTENT}' - _p9k_transient_prompt+='${:-"'$_p9k__ret'"}' - _p9k_transient_prompt+=$sep - _p9k_color prompt_prompt_char_ERROR_VIINS FOREGROUND 196 - _p9k_foreground $_p9k__ret - _p9k_transient_prompt+=$_p9k__ret - _p9k_transient_prompt+='${${P9K_CONTENT::="❯"}+}' - _p9k_param prompt_prompt_char_ERROR_VIINS CONTENT_EXPANSION '${P9K_CONTENT}' - _p9k_transient_prompt+='${:-"'$_p9k__ret'"}' - _p9k_transient_prompt+=')%b%k%f%s%u ' - if (( _POWERLEVEL9K_TERM_SHELL_INTEGRATION )); then - _p9k_transient_prompt=$'%{\e]133;A\a%}'$_p9k_transient_prompt$'%{\e]133;B\a%}' - if (( $+_z4h_iterm_cmd && _z4h_can_save_restore_screen == 1 )); then - _p9k_transient_prompt=$'%{\ePtmux;\e\e]133;A\a\e\\%}'$_p9k_transient_prompt$'%{\ePtmux;\e\e]133;B\a\e\\%}' - fi - fi - fi - - _p9k_uname="$(uname)" - [[ $_p9k_uname == Linux ]] && _p9k_uname_o="$(uname -o 2>/dev/null)" - _p9k_uname_m="$(uname -m)" - - if [[ $_p9k_uname == Linux && $_p9k_uname_o == Android ]]; then - _p9k_set_os Android ANDROID_ICON - else - case $_p9k_uname in - SunOS) _p9k_set_os Solaris SUNOS_ICON;; - Darwin) _p9k_set_os OSX APPLE_ICON;; - CYGWIN*|MSYS*|MINGW*) _p9k_set_os Windows WINDOWS_ICON;; - FreeBSD|OpenBSD|DragonFly) _p9k_set_os BSD FREEBSD_ICON;; - Linux) - _p9k_os='Linux' - local os_release_id - if [[ -r /etc/os-release ]]; then - local lines=(${(f)"$(</etc/os-release)"}) - lines=(${(@M)lines:#ID=*}) - (( $#lines == 1 )) && os_release_id=${lines[1]#ID=} - elif [[ -e /etc/artix-release ]]; then - os_release_id=artix - fi - case $os_release_id in - *arch*) _p9k_set_os Linux LINUX_ARCH_ICON;; - *debian*) _p9k_set_os Linux LINUX_DEBIAN_ICON;; - *raspbian*) _p9k_set_os Linux LINUX_RASPBIAN_ICON;; - *ubuntu*) _p9k_set_os Linux LINUX_UBUNTU_ICON;; - *elementary*) _p9k_set_os Linux LINUX_ELEMENTARY_ICON;; - *fedora*) _p9k_set_os Linux LINUX_FEDORA_ICON;; - *coreos*) _p9k_set_os Linux LINUX_COREOS_ICON;; - *gentoo*) _p9k_set_os Linux LINUX_GENTOO_ICON;; - *mageia*) _p9k_set_os Linux LINUX_MAGEIA_ICON;; - *centos*) _p9k_set_os Linux LINUX_CENTOS_ICON;; - *opensuse*|*tumbleweed*) _p9k_set_os Linux LINUX_OPENSUSE_ICON;; - *sabayon*) _p9k_set_os Linux LINUX_SABAYON_ICON;; - *slackware*) _p9k_set_os Linux LINUX_SLACKWARE_ICON;; - *linuxmint*) _p9k_set_os Linux LINUX_MINT_ICON;; - *alpine*) _p9k_set_os Linux LINUX_ALPINE_ICON;; - *aosc*) _p9k_set_os Linux LINUX_AOSC_ICON;; - *nixos*) _p9k_set_os Linux LINUX_NIXOS_ICON;; - *devuan*) _p9k_set_os Linux LINUX_DEVUAN_ICON;; - *manjaro*) _p9k_set_os Linux LINUX_MANJARO_ICON;; - *void*) _p9k_set_os Linux LINUX_VOID_ICON;; - *artix*) _p9k_set_os Linux LINUX_ARTIX_ICON;; - *rhel*) _p9k_set_os Linux LINUX_RHEL_ICON;; - amzn) _p9k_set_os Linux LINUX_AMZN_ICON;; - *) _p9k_set_os Linux LINUX_ICON;; - esac - ;; - esac - fi - - if [[ $_POWERLEVEL9K_COLOR_SCHEME == light ]]; then - _p9k_color1=7 - _p9k_color2=0 - else - _p9k_color1=0 - _p9k_color2=7 - fi - - _p9k_battery_states=( - 'LOW' 'red' - 'CHARGING' 'yellow' - 'CHARGED' 'green' - 'DISCONNECTED' "$_p9k_color2" - ) - - # This simpler construct doesn't work on zsh-5.1 with multi-line prompt: - # - # ${(@0)_p9k_line_segments_left[@]} - local -a left_segments=(${(@0)${(pj:\0:)_p9k_line_segments_left}}) - _p9k_left_join=(1) - for ((i = 2; i <= $#left_segments; ++i)); do - elem=$left_segments[i] - if [[ $elem == *_joined ]]; then - _p9k_left_join+=$_p9k_left_join[((i-1))] - else - _p9k_left_join+=$i - fi - done - - local -a right_segments=(${(@0)${(pj:\0:)_p9k_line_segments_right}}) - _p9k_right_join=(1) - for ((i = 2; i <= $#right_segments; ++i)); do - elem=$right_segments[i] - if [[ $elem == *_joined ]]; then - _p9k_right_join+=$_p9k_right_join[((i-1))] - else - _p9k_right_join+=$i - fi - done - - case $_p9k_os in - OSX) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.logicalcpu 2>/dev/null)";; - BSD) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.ncpu 2>/dev/null)";; - *) (( $+commands[nproc] )) && _p9k_num_cpus="$(nproc 2>/dev/null)";; - esac - (( _p9k_num_cpus )) || _p9k_num_cpus=1 - - if _p9k_segment_in_use dir; then - if (( $+_POWERLEVEL9K_DIR_CLASSES )); then - local -i i=3 - for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do - _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} - done - else - typeset -ga _POWERLEVEL9K_DIR_CLASSES=() - _p9k_get_icon prompt_dir_ETC ETC_ICON - _POWERLEVEL9K_DIR_CLASSES+=('/etc|/etc/*' ETC "$_p9k__ret") - _p9k_get_icon prompt_dir_HOME HOME_ICON - _POWERLEVEL9K_DIR_CLASSES+=('~' HOME "$_p9k__ret") - _p9k_get_icon prompt_dir_HOME_SUBFOLDER HOME_SUB_ICON - _POWERLEVEL9K_DIR_CLASSES+=('~/*' HOME_SUBFOLDER "$_p9k__ret") - _p9k_get_icon prompt_dir_DEFAULT FOLDER_ICON - _POWERLEVEL9K_DIR_CLASSES+=('*' DEFAULT "$_p9k__ret") - fi - fi - - if _p9k_segment_in_use status; then - typeset -g _p9k_exitcode2str=({0..255}) - local -i i=2 - if (( !_POWERLEVEL9K_STATUS_HIDE_SIGNAME )); then - for ((; i <= $#signals; ++i)); do - local sig=$signals[i] - (( _POWERLEVEL9K_STATUS_VERBOSE_SIGNAME )) && sig="SIG${sig}($((i-1)))" - _p9k_exitcode2str[$((128+i))]=$sig - done - fi - fi - - if [[ $#_POWERLEVEL9K_VCS_BACKENDS == 1 && $_POWERLEVEL9K_VCS_BACKENDS[1] == git ]]; then - local elem line - local -i i=0 line_idx=0 - for line in $_p9k_line_segments_left; do - (( ++line_idx )) - for elem in ${${(0)line}%_joined}; do - (( ++i )) - if [[ $elem == vcs ]]; then - if (( _p9k_vcs_index )); then - _p9k_vcs_index=-1 - else - _p9k_vcs_index=i - _p9k_vcs_line_index=line_idx - _p9k_vcs_side=left - fi - fi - done - done - i=0 - line_idx=0 - for line in $_p9k_line_segments_right; do - (( ++line_idx )) - for elem in ${${(0)line}%_joined}; do - (( ++i )) - if [[ $elem == vcs ]]; then - if (( _p9k_vcs_index )); then - _p9k_vcs_index=-1 - else - _p9k_vcs_index=i - _p9k_vcs_line_index=line_idx - _p9k_vcs_side=right - fi - fi - done - done - if (( _p9k_vcs_index > 0 )); then - local state - for state in ${(k)__p9k_vcs_states}; do - _p9k_param prompt_vcs_$state CONTENT_EXPANSION x - if [[ -z $_p9k__ret ]]; then - _p9k_vcs_index=-1 - break - fi - done - fi - if (( _p9k_vcs_index == -1 )); then - _p9k_vcs_index=0 - _p9k_vcs_line_index=0 - _p9k_vcs_side= - fi - fi -} - -_p9k_init_vcs() { - if ! _p9k_segment_in_use vcs || (( ! $#_POWERLEVEL9K_VCS_BACKENDS )); then - (( $+functions[gitstatus_stop_p9k_] )) && gitstatus_stop_p9k_ POWERLEVEL9K - unset _p9k_preinit - return - fi - - _p9k_vcs_info_init - if (( $+functions[_p9k_preinit] )); then - if (( $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )); then - () { - trap 'return 130' INT - { - gitstatus_start_p9k_ POWERLEVEL9K - } always { - trap ':' INT - } - } - fi - (( $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )) || _p9k__instant_prompt_disabled=1 - return 0 - fi - (( _POWERLEVEL9K_DISABLE_GITSTATUS )) && return - (( $_POWERLEVEL9K_VCS_BACKENDS[(I)git] )) || return - - local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} - - typeset -g _p9k_preinit="function _p9k_preinit() { - (( $+commands[git] )) || { unfunction _p9k_preinit; return 1 } - [[ \$ZSH_VERSION == ${(q)ZSH_VERSION} ]] || return - [[ -r ${(q)gitstatus_dir}/gitstatus.plugin.zsh ]] || return - builtin source ${(q)gitstatus_dir}/gitstatus.plugin.zsh _p9k_ || return - GITSTATUS_AUTO_INSTALL=${(q)GITSTATUS_AUTO_INSTALL} \ - GITSTATUS_DAEMON=${(q)GITSTATUS_DAEMON} \ - GITSTATUS_CACHE_DIR=${(q)GITSTATUS_CACHE_DIR} \ - GITSTATUS_NUM_THREADS=${(q)GITSTATUS_NUM_THREADS} \ - GITSTATUS_LOG_LEVEL=${(q)GITSTATUS_LOG_LEVEL} \ - GITSTATUS_ENABLE_LOGGING=${(q)GITSTATUS_ENABLE_LOGGING} \ - gitstatus_start_p9k_ \ - -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ - -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ - -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ - -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ - -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ - ${${_POWERLEVEL9K_VCS_RECURSE_UNTRACKED_DIRS:#0}:+-e} \ - -a POWERLEVEL9K - }" - builtin source $gitstatus_dir/gitstatus.plugin.zsh _p9k_ || return - () { - trap 'return 130' INT - { - gitstatus_start_p9k_ \ - -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ - -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ - -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ - -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ - -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ - ${${_POWERLEVEL9K_VCS_RECURSE_UNTRACKED_DIRS:#0}:+-e} \ - POWERLEVEL9K - } always { - trap ':' INT - } - } - (( $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )) || _p9k__instant_prompt_disabled=1 -} - -function _p9k_iterm2_precmd() { - builtin zle && return - if (( _p9k__iterm_cmd )) && [[ -t 1 ]]; then - (( _p9k__iterm_cmd == 1 )) && builtin print -n '\e]133;C;\a' - builtin printf '\e]133;D;%s\a' $1 - fi - typeset -gi _p9k__iterm_cmd=1 -} - -function _p9k_iterm2_preexec() { - [[ -t 1 ]] && builtin print -n '\e]133;C;\a' - typeset -gi _p9k__iterm_cmd=2 -} - -_p9k_init() { - _p9k_init_vars - _p9k_restore_state || _p9k_init_cacheable - - typeset -g P9K_OS_ICON=$_p9k_os_icon - - local -a _p9k__async_segments_compute - - local -i i - local elem - - _p9k__prompt_side=left - _p9k__segment_index=1 - for i in {1..$#_p9k_line_segments_left}; do - for elem in ${${(@0)_p9k_line_segments_left[i]}%_joined}; do - local f_init=_p9k_prompt_${elem}_init - (( $+functions[$f_init] )) && $f_init - (( ++_p9k__segment_index )) - done - done - - _p9k__prompt_side=right - _p9k__segment_index=1 - for i in {1..$#_p9k_line_segments_right}; do - for elem in ${${(@0)_p9k_line_segments_right[i]}%_joined}; do - local f_init=_p9k_prompt_${elem}_init - (( $+functions[$f_init] )) && $f_init - (( ++_p9k__segment_index )) - done - done - - if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE || - -n $_POWERLEVEL9K_IP_INTERFACE || - -n $_POWERLEVEL9K_VPN_IP_INTERFACE ]]; then - _p9k_prompt_net_iface_init - fi - - if [[ -n $_p9k__async_segments_compute ]]; then - functions[_p9k_async_segments_compute]=${(pj:\n:)_p9k__async_segments_compute} - _p9k_worker_start - fi - - local k v - for k v in ${(kv)_p9k_display_k}; do - [[ $k == -* ]] && continue - _p9k__display_v[v]=$k - _p9k__display_v[v+1]=show - done - _p9k__display_v[2]=hide - _p9k__display_v[4]=hide - - if (( $+functions[iterm2_decorate_prompt] )); then - _p9k__iterm2_decorate_prompt=$functions[iterm2_decorate_prompt] - function iterm2_decorate_prompt() { - typeset -g ITERM2_PRECMD_PS1=$PROMPT - typeset -g ITERM2_SHOULD_DECORATE_PROMPT= - } - fi - if (( $+functions[iterm2_precmd] )); then - _p9k__iterm2_precmd=$functions[iterm2_precmd] - functions[iterm2_precmd]='local _p9k_status=$?; zle && return; () { return $_p9k_status; }; '$_p9k__iterm2_precmd - fi - - if (( _POWERLEVEL9K_TERM_SHELL_INTEGRATION && - ! $+_z4h_iterm_cmd && - ! $+functions[iterm2_decorate_prompt] && - ! $+functions[iterm2_precmd] )); then - typeset -gi _p9k__iterm_cmd=0 - fi - - if _p9k_segment_in_use todo; then - if [[ -n ${_p9k__todo_command::=${commands[todo.sh]}} ]]; then - local todo_global=/etc/todo/config - elif [[ -n ${_p9k__todo_command::=${commands[todo-txt]}} ]]; then - local todo_global=/etc/todo-txt/config - fi - if [[ -n $_p9k__todo_command ]]; then - _p9k__todo_file="$(exec -a $_p9k__todo_command ${commands[bash]:-:} 3>&1 &>/dev/null -c " - [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/.todo/config - [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/todo.cfg - [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/.todo.cfg - [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\${XDG_CONFIG_HOME:-\$HOME/.config}/todo/config - [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=${(qqq)_p9k__todo_command:h}/todo.cfg - [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\${TODOTXT_GLOBAL_CFG_FILE:-${(qqq)todo_global}} - [ -r \"\$TODOTXT_CFG_FILE\" ] || exit - source \"\$TODOTXT_CFG_FILE\" - printf "%s" \"\$TODO_FILE\" >&3")" - fi - fi - - if _p9k_segment_in_use dir && - [[ $_POWERLEVEL9K_SHORTEN_STRATEGY == truncate_with_package_name && $+commands[jq] == 0 ]]; then - print -rP -- '%F{yellow}WARNING!%f %BPOWERLEVEL9K_SHORTEN_STRATEGY=truncate_with_package_name%b requires %F{green}jq%f.' - print -rP -- 'Either install %F{green}jq%f or change the value of %BPOWERLEVEL9K_SHORTEN_STRATEGY%b.' - fi - - _p9k_init_vcs - - if (( _p9k__instant_prompt_disabled )); then - (( _POWERLEVEL9K_DISABLE_INSTANT_PROMPT )) && unset __p9k_instant_prompt_erased - _p9k_delete_instant_prompt - _p9k_dumped_instant_prompt_sigs=() - fi - - if (( $+__p9k_instant_prompt_sourced && __p9k_instant_prompt_sourced != __p9k_instant_prompt_version )); then - _p9k_delete_instant_prompt - _p9k_dumped_instant_prompt_sigs=() - fi - - if (( $+__p9k_instant_prompt_erased )); then - unset __p9k_instant_prompt_erased - if [[ -w $TTY ]]; then - local tty=$TTY - elif [[ -w /dev/tty ]]; then - local tty=/dev/tty - else - local tty=/dev/null - fi - { - >&2 echo -E - "" - >&2 echo -E - "${(%):-[%1FERROR%f]: When using instant prompt, Powerlevel10k must be loaded before the first prompt.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):-You can:}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - %BRecommended%b: Change the way Powerlevel10k is loaded from %B$__p9k_zshrc_u%b.}" - if (( _p9k_term_has_href )); then - >&2 echo - "${(%):- See \e]8;;https://github.com/romkatv/powerlevel10k/blob/master/README.md#installation\ahttps://github.com/romkatv/powerlevel10k/blob/master/README.md#installation\e]8;;\a.}" - else - >&2 echo - "${(%):- See https://github.com/romkatv/powerlevel10k/blob/master/README.md#installation.}" - fi - if (( $+zsh_defer_options )); then - >&2 echo -E - "" - >&2 echo -E - "${(%):- NOTE: Do not use %1Fzsh-defer%f to load %Upowerlevel10k.zsh-theme%u.}" - elif (( $+functions[zinit] )); then - >&2 echo -E - "" - >&2 echo -E - "${(%):- NOTE: If using %2Fzinit%f to load %3F'romkatv/powerlevel10k'%f, %Bdo not apply%b %1Fice wait%f.}" - elif (( $+functions[zplugin] )); then - >&2 echo -E - "" - >&2 echo -E - "${(%):- NOTE: If using %2Fzplugin%f to load %3F'romkatv/powerlevel10k'%f, %Bdo not apply%b %1Fice wait%f.}" - fi - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - >&2 echo -E - "${(%):- * Zsh will start %Bquickly%b.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - Disable instant prompt either by running %Bp10k configure%b or by manually}" - >&2 echo -E - "${(%):- defining the following parameter:}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- %3Ftypeset%f -g POWERLEVEL9K_INSTANT_PROMPT=off}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - >&2 echo -E - "${(%):- * Zsh will start %Bslowly%b.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - Do nothing.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill%b see this error message every time you start zsh.}" - >&2 echo -E - "${(%):- * Zsh will start %Bslowly%b.}" - >&2 echo -E - "" - } 2>>$tty - fi -} - -_p9k_deinit() { - (( $+functions[_p9k_preinit] )) && unfunction _p9k_preinit - (( $+functions[gitstatus_stop_p9k_] )) && gitstatus_stop_p9k_ POWERLEVEL9K - _p9k_worker_stop - if (( _p9k__state_dump_fd )); then - zle -F $_p9k__state_dump_fd - exec {_p9k__state_dump_fd}>&- - fi - if (( _p9k__restore_prompt_fd )); then - zle -F $_p9k__restore_prompt_fd - exec {_p9k__restore_prompt_fd}>&- - fi - if (( _p9k__redraw_fd )); then - zle -F $_p9k__redraw_fd - exec {_p9k__redraw_fd}>&- - fi - (( $+_p9k__iterm2_precmd )) && functions[iterm2_precmd]=$_p9k__iterm2_precmd - (( $+_p9k__iterm2_decorate_prompt )) && functions[iterm2_decorate_prompt]=$_p9k__iterm2_decorate_prompt - unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*~(P9K_SSH|P9K_TOOLBOX_NAME|P9K_TTY|_P9K_TTY)' - [[ -n $__p9k_locale ]] || unset __p9k_locale -} - -typeset -gi __p9k_enabled=0 -typeset -gi __p9k_configured=0 -typeset -gri __p9k_instant_prompt_disabled=1 - -# `typeset -g` doesn't roundtrip in zsh prior to 5.4. -if [[ $ZSH_VERSION == (5.<4->*|<6->.*) ]]; then - typeset -gri __p9k_dumps_enabled=1 -else - typeset -gri __p9k_dumps_enabled=0 -fi - -_p9k_do_nothing() { true; } - -_p9k_precmd_first() { - eval "$__p9k_intro" - if [[ -n $KITTY_SHELL_INTEGRATION && KITTY_SHELL_INTEGRATION[(wIe)no-prompt-mark] -eq 0 ]]; then - KITTY_SHELL_INTEGRATION+=' no-prompt-mark' - (( $+__p9k_force_term_shell_integration )) || typeset -gri __p9k_force_term_shell_integration=1 - fi - typeset -ga precmd_functions=(${precmd_functions:#_p9k_precmd_first}) -} - -_p9k_setup() { - (( __p9k_enabled )) && return - - prompt_opts=(percent subst) - if (( ! $+__p9k_instant_prompt_active )); then - prompt_opts+=sp - prompt_opts+=cr - fi - - prompt_powerlevel9k_teardown - __p9k_enabled=1 - typeset -ga preexec_functions=(_p9k_preexec1 $preexec_functions _p9k_preexec2) - typeset -ga precmd_functions=(_p9k_do_nothing _p9k_precmd_first $precmd_functions _p9k_precmd) -} - -prompt_powerlevel9k_setup() { - _p9k_restore_special_params - eval "$__p9k_intro" - _p9k_setup -} - -prompt_powerlevel9k_teardown() { - _p9k_restore_special_params - eval "$__p9k_intro" - add-zsh-hook -D precmd '(_p9k_|powerlevel9k_)*' - add-zsh-hook -D preexec '(_p9k_|powerlevel9k_)*' - PROMPT='%m%# ' - RPROMPT= - if (( __p9k_enabled )); then - _p9k_deinit - __p9k_enabled=0 - fi -} - -typeset -gr __p9k_p10k_usage="Usage: %2Fp10k%f %Bcommand%b [options] - -Commands: - - %Bconfigure%b run interactive configuration wizard - %Breload%b reload configuration - %Bsegment%b print a user-defined prompt segment - %Bdisplay%b show, hide or toggle prompt parts - %Bhelp%b print this help message - -Print help for a specific command: - - %2Fp10k%f %Bhelp%b command" - -typeset -gr __p9k_p10k_segment_usage="Usage: %2Fp10k%f %Bsegment%b [-h] [{+|-}re] [-s state] [-b bg] [-f fg] [-i icon] [-c cond] [-t text] - -Print a user-defined prompt segment. Can be called only during prompt rendering. - -Options: - -t text segment's main content; will undergo prompt expansion: '%%F{blue}%%*%%f' will - show as %F{blue}%*%f; default is empty - -i icon segment's icon; default is empty - -r icon is a symbolic reference that needs to be resolved; for example, 'LOCK_ICON' - +r icon is already resolved and should be printed literally; for example, '⭐'; - this is the default; you can also use \$'\u2B50' if you don't want to have - non-ascii characters in source code - -b bg background color; for example, 'blue', '4', or '#0000ff'; empty value means - transparent background, as in '%%k'; default is black - -f fg foreground color; for example, 'blue', '4', or '#0000ff'; empty value means - default foreground color, as in '%%f'; default is empty - -s state segment's state for the purpose of applying styling options; if you want to - to be able to use POWERLEVEL9K parameters to specify different colors or icons - depending on some property, use different states for different values of that - property - -c condition; if empty after parameter expansion and process substitution, the - segment is hidden; this is an advanced feature, use with caution; default is '1' - -e segment's main content will undergo parameter expansion and process - substitution; the content will be surrounded with double quotes and thus - should quote its own double quotes; this is an advanced feature, use with - caution - +e segment's main content should not undergo parameter expansion and process - substitution; this is the default - -h print this help message - -Example: 'core' segment tells you if there is a file name 'core' in the current directory. - -- Segment's icon is '⭐'. -- Segment's text is the file's size in bytes. -- If you have permissions to delete the file, state is DELETABLE. If not, it's PROTECTED. - - zmodload -F zsh/stat b:zstat - - function prompt_core() { - local size=() - if ! zstat -A size +size core 2>/dev/null; then - # No 'core' file in the current directory. - return - fi - if [[ -w . ]]; then - local state=DELETABLE - else - local state=PROTECTED - fi - p10k segment -s \$state -i '⭐' -f blue -t \${size[1]}b - } - -To enable this segment, add 'core' to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or -POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. - -Example customizations: - - # Override default foreground. - POWERLEVEL9K_CORE_FOREGROUND=red - - # Override foreground when DELETABLE. - POWERLEVEL9K_CORE_DELETABLE_BACKGROUND=green - - # Override icon when PROTECTED. - POWERLEVEL9K_CORE_PROTECTED_VISUAL_IDENTIFIER_EXPANSION='❎' - - # Don't show file size when PROTECTED. - POWERLEVEL9K_CORE_PROTECTED_CONTENT_EXPANSION=''" - -typeset -gr __p9k_p10k_configure_usage="Usage: %2Fp10k%f %Bconfigure%b - -Run interactive configuration wizard." - -typeset -gr __p9k_p10k_reload_usage="Usage: %2Fp10k%f %Breload%b - -Reload configuration." - -typeset -gr __p9k_p10k_finalize_usage="Usage: %2Fp10k%f %Bfinalize%b - -Perform the final stage of initialization. Must be called at the very end of zshrc." - -typeset -gr __p9k_p10k_display_usage="Usage: %2Fp10k%f %Bdisplay%b part-pattern=state-list... - - Show, hide or toggle prompt parts. If called from zle, the current - prompt is refreshed. - -Usage: %2Fp10k%f %Bdisplay%b -a [part-pattern]... - - Populate array \`reply\` with states of prompt parts matching the patterns. - If no patterns are supplied, assume \`*\`. - -Usage: %2Fp10k%f %Bdisplay%b -r - - Redisplay prompt. - -Parts: - empty_line empty line (duh) - ruler ruler; if POWERLEVEL9K_RULER_CHAR=' ', it's essentially another - new_line - N prompt line number N, 1-based; counting from the top if positive, - from the bottom if negative - N/left_frame left frame on the Nth line - N/left left prompt on the Nth line - N/gap gap between left and right prompts on the Nth line - N/right right prompt on the Nth line - N/right_frame right frame on the Nth line - N/left/S segment S within N/left (dir, time, etc.) - N/right/S segment S within N/right (dir, time, etc.) - -Part States: - show the part is displayed - hide the part is not displayed - print the part is printed in precmd; only applicable to empty_line and - ruler; unlike show, the effects of print cannot be undone with hide; - print used to look better after \`clear\` but this is no longer the - case; it's best to avoid it unless you know what you are doing - -part-pattern is a glob pattern for parts. Examples: - - */kubecontext all kubecontext prompt segments, regardless of where - they are - 1/(right|right_frame) all prompt segments and frame from the right side of - the first line - -state-list is a comma-separated list of states. Must have at least one element. -If more than one, states will rotate. - -Example: Bind Ctrl+P to toggle right prompt. - - function toggle-right-prompt() { p10k display '*/right'=hide,show; } - zle -N toggle-right-prompt - bindkey '^P' toggle-right-prompt - -Example: Print the current state of all prompt parts: - - typeset -A reply - p10k display -a '*' - printf '%%-32s = %%q\n' \${(@kv)reply} | sort -" - -# 0 -- reset-prompt not blocked -# 1 -- reset-prompt blocked and not needed -# 2 -- reset-prompt blocked and needed -typeset -gi __p9k_reset_state - -function p10k() { - [[ $# != 1 || $1 != finalize ]] || { p10k-instant-prompt-finalize; return 0 } - - eval "$__p9k_intro_no_reply" - - if (( !ARGC )); then - print -rP -- $__p9k_p10k_usage >&2 - return 1 - fi - - case $1 in - segment) - local REPLY - local -a reply - shift - local -i OPTIND - local OPTARG opt state bg=0 fg icon cond text ref=0 expand=0 - while getopts ':s:b:f:i:c:t:reh' opt; do - case $opt in - s) state=$OPTARG;; - b) bg=$OPTARG;; - f) fg=$OPTARG;; - i) icon=$OPTARG;; - c) cond=${OPTARG:-'${:-}'};; - t) text=$OPTARG;; - r) ref=1;; - e) expand=1;; - +r) ref=0;; - +e) expand=0;; - h) print -rP -- $__p9k_p10k_segment_usage; return 0;; - ?) print -rP -- $__p9k_p10k_segment_usage >&2; return 1;; - esac - done - if (( OPTIND <= ARGC )); then - print -rP -- $__p9k_p10k_segment_usage >&2 - return 1 - fi - if [[ -z $_p9k__prompt_side ]]; then - print -rP -- "%1F[ERROR]%f %Bp10k segment%b: can be called only during prompt rendering." >&2 - if (( !ARGC )); then - print -rP -- "" - print -rP -- "For help, type:" >&2 - print -rP -- "" - print -rP -- " %2Fp10k%f %Bhelp%b %Bsegment%b" >&2 - fi - return 1 - fi - (( ref )) || icon=$'\1'$icon - typeset -i _p9k__has_upglob - "_p9k_${_p9k__prompt_side}_prompt_segment" "prompt_${_p9k__segment_name}${state:+_${${(U)state}//İ/I}}" \ - "$bg" "${fg:-$_p9k_color1}" "$icon" "$expand" "$cond" "$text" - return 0 - ;; - display) - if (( ARGC == 1 )); then - print -rP -- $__p9k_p10k_display_usage >&2 - return 1 - fi - shift - local -i k dump - local opt prev new pair list name var - while getopts ':har' opt; do - case $opt in - r) - if (( __p9k_reset_state > 0 )); then - __p9k_reset_state=2 - else - __p9k_reset_state=-1 - fi - ;; - a) dump=1;; - h) print -rP -- $__p9k_p10k_display_usage; return 0;; - ?) print -rP -- $__p9k_p10k_display_usage >&2; return 1;; - esac - done - if (( dump )); then - reply=() - shift $((OPTIND-1)) - (( ARGC )) || set -- '*' - for opt; do - for k in ${(u@)_p9k_display_k[(I)$opt]:/(#m)*/$_p9k_display_k[$MATCH]}; do - reply+=($_p9k__display_v[k,k+1]) - done - done - if (( __p9k_reset_state == -1 )); then - _p9k_reset_prompt - fi - return 0 - fi - local REPLY - local -a reply - for opt in "${@:$OPTIND}"; do - pair=(${(s:=:)opt}) - list=(${(s:,:)${pair[2]}}) - if [[ ${(b)pair[1]} == $pair[1] ]]; then # this branch is purely for optimization - local ks=($_p9k_display_k[$pair[1]]) - else - local ks=(${(u@)_p9k_display_k[(I)$pair[1]]:/(#m)*/$_p9k_display_k[$MATCH]}) - fi - for k in $ks; do - if (( $#list == 1 )); then # this branch is purely for optimization - [[ $_p9k__display_v[k+1] == $list[1] ]] && continue - new=$list[1] - else - new=${list[list[(I)$_p9k__display_v[k+1]]+1]:-$list[1]} - [[ $_p9k__display_v[k+1] == $new ]] && continue - fi - _p9k__display_v[k+1]=$new - name=$_p9k__display_v[k] - if [[ $name == (empty_line|ruler) ]]; then - var=_p9k__${name}_i - [[ $new == show ]] && unset $var || typeset -gi $var=3 - elif [[ $name == (#b)(<->)(*) ]]; then - var=_p9k__${match[1]}${${${${match[2]//\/}/#left/l}/#right/r}/#gap/g} - [[ $new == hide ]] && typeset -g $var= || unset $var - fi - if (( __p9k_reset_state > 0 )); then - __p9k_reset_state=2 - else - __p9k_reset_state=-1 - fi - done - done - if (( __p9k_reset_state == -1 )); then - _p9k_reset_prompt - fi - ;; - configure) - if (( ARGC > 1 )); then - print -rP -- $__p9k_p10k_configure_usage >&2 - return 1 - fi - local REPLY - local -a reply - p9k_configure "$@" || return - ;; - reload) - if (( ARGC > 1 )); then - print -rP -- $__p9k_p10k_reload_usage >&2 - return 1 - fi - (( $+_p9k__force_must_init )) || return 0 - _p9k__force_must_init=1 - ;; - help) - local var=__p9k_p10k_$2_usage - if (( $+parameters[$var] )); then - print -rP -- ${(P)var} - return 0 - elif (( ARGC == 1 )); then - print -rP -- $__p9k_p10k_usage - return 0 - else - print -rP -- $__p9k_p10k_usage >&2 - return 1 - fi - ;; - finalize) - print -rP -- $__p9k_p10k_finalize_usage >&2 - return 1 - ;; - clear-instant-prompt) - if (( $+__p9k_instant_prompt_active )); then - _p9k_clear_instant_prompt - unset __p9k_instant_prompt_active - fi - return 0 - ;; - *) - print -rP -- $__p9k_p10k_usage >&2 - return 1 - ;; - esac -} - -# Hook for zplugin. -powerlevel10k_plugin_unload() { prompt_powerlevel9k_teardown; } - -function p10k-instant-prompt-finalize() { - unsetopt local_options - (( ${+__p9k_instant_prompt_active} )) && unsetopt prompt_cr prompt_sp || setopt prompt_cr prompt_sp -} - -autoload -Uz add-zsh-hook - -zmodload zsh/datetime -zmodload zsh/mathfunc -zmodload zsh/parameter 2>/dev/null # https://github.com/romkatv/gitstatus/issues/58#issuecomment-553407177 -zmodload zsh/system -zmodload zsh/termcap -zmodload zsh/terminfo -zmodload zsh/zleparameter -zmodload -F zsh/stat b:zstat -zmodload -F zsh/net/socket b:zsocket -zmodload -F zsh/files b:zf_mv b:zf_rm - -if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_prompt_dump_file ]]; then - _p9k_delete_instant_prompt - zf_rm -f -- $__p9k_dump_file{,.zwc} 2>/dev/null - zf_rm -f -- $__p9k_instant_prompt_dump_file{,.zwc} 2>/dev/null -fi - -unset VSCODE_SHELL_INTEGRATION - -_p9k_init_ssh -_p9k_init_toolbox -prompt_powerlevel9k_setup diff --git a/.zsh/themes/powerlevel10k/internal/parser.zsh b/.zsh/themes/powerlevel10k/internal/parser.zsh deleted file mode 100644 index 6c16adc..0000000 --- a/.zsh/themes/powerlevel10k/internal/parser.zsh +++ /dev/null @@ -1,382 +0,0 @@ -typeset -grA __p9k_pb_cmd_skip=( - '}' 'always' # handled specially - '{' '' - '{' '' - '|' '' - '||' '' - '&' '' - '&&' '' - '|&' '' - '&!' '' - '&|' '' - ')' '' - '(' '' - '()' '' - '!' '' - ';' '' - 'if' '' - 'fi' '' - 'elif' '' - 'else' '' - 'then' '' - 'while' '' - 'until' '' - 'do' '' - 'done' '' - 'esac' '' - 'end' '' - 'coproc' '' - 'nocorrect' '' - 'noglob' '' - 'time' '' - '[[' '\]\]' - '((' '\)\)' - 'case' '\)|esac' - ';;' '\)|esac' - ';&' '\)|esac' - ';|' '\)|esac' - 'foreach' '\(*\)' -) - -typeset -grA __p9k_pb_precommand=( - '-' '' - 'builtin' '' - 'command' '' - 'exec' '-[^a]#[a]' - 'nohup' '' - 'setsid' '' - 'eatmydata' '' - 'catchsegv' '' - 'pkexec' '--user' - 'doas' '-[^aCu]#[acU]' - 'nice' '-[^n]#[n]|--adjustment' - 'stdbuf' '-[^ioe]#[ioe]|--(input|output|error)' - 'sudo' '-[^aghpuUCcrtT]#[aghpuUCcrtT]|--(close-from|group|host|prompt|role|type|other-user|command-timeout|user)' - 'ssh-agent' '-[^aEPt]#[aEPt]' - 'tabbed' '-[^gnprtTuU]#[gnprtTuU]' - 'chronic' '' - 'ifne' '' -) - -typeset -grA __p9k_pb_redirect=( - '&>' '' - '>' '' - '>&' '' - '<' '' - '<&' '' - '<>' '' - '&>|' '' - '>|' '' - '&>>' '' - '>>' '' - '>>&' '' - '&>>|' '' - '>>|' '' - '<<<' '' -) - -typeset -grA __p9k_pb_term=( - '|' '' - '||' '' - ';' '' - '&' '' - '&&' '' - '|&' '' - '&!' '' - '&|' '' - ';;' '' - ';&' '' - ';|' '' - '(' '' - ')' '' - '()' '' # handled specially - '}' '' # handled specially -) - -typeset -grA __p9k_pb_term_skip=( - '(' '\)' - ';;' '\)|esac' - ';&' '\)|esac' - ';|' '\)|esac' -) - -# Usage: _p9k_parse_buffer <buffer> [token-limit] -# -# Parses the specified command line buffer and pupulates array P9K_COMMANDS -# with commands from it. Terminates early and returns 1 if there are more -# tokens than the specified limit. -# -# Broken: -# -# --------------- -# : $(x) -# --------------- -# : `x` -# --------------- -# ${x/} -# --------------- -# - -- x -# --------------- -# command -p -p x -# --------------- -# * -# --------------- -# x=$y; $x -# --------------- -# alias x=y; y -# --------------- -# x <<END -# ; END -# END -# --------------- -# Setup: -# setopt interactive_comments -# alias x='#' -# Punchline: -# x; y -# --------------- -# -# More brokenness with non-standard options (ignore_braces, ignore_close_braces, etc.). -function _p9k_parse_buffer() { - [[ ${2:-0} == <-> ]] || return 2 - - local rcquotes - [[ -o rcquotes ]] && rcquotes=rcquotes - - eval "$__p9k_intro" - setopt no_nomatch $rcquotes - - typeset -ga P9K_COMMANDS=() - - local -r id='(<->|[[:alpha:]_][[:IDENT:]]#)' - local -r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\"" - - local -i e ic c=${2:-'1 << 62'} - local skip n s r state token cmd prev - local -a aln alp alf v - - if [[ -o interactive_comments ]]; then - ic=1 - local tokens=(${(Z+C+)1}) - else - local tokens=(${(z)1}) - fi - - { - while (( $#tokens )); do - (( e = $#state )) - - while (( $#tokens == alp[-1] )); do - aln[-1]=() - alp[-1]=() - if (( $#tokens == alf[-1] )); then - alf[-1]=() - (( e = 0 )) - fi - done - - while (( c-- > 0 )) || return; do - token=$tokens[1] - tokens[1]=() - if (( $+galiases[$token] )); then - (( $aln[(eI)p$token] )) && break - s=$galiases[$token] - n=p$token - elif (( e )); then - break - elif (( $+aliases[$token] )); then - (( $aln[(eI)p$token] )) && break - s=$aliases[$token] - n=p$token - elif [[ $token == ?*.?* ]] && (( $+saliases[${token##*.}] )); then - r=${token##*.} - (( $aln[(eI)s$r] )) && break - s=${saliases[$r]%% #} - n=s$r - else - break - fi - aln+=$n - alp+=$#tokens - [[ $s == *' ' ]] && alf+=$#tokens - (( ic )) && tokens[1,0]=(${(Z+C+)s}) || tokens[1,0]=(${(z)s}) - done - - case $token in - '<<'(|-)) - state=h - continue - ;; - *('`'|['<>=$']'(')*) - if [[ $token == ('`'[^'`']##'`'|'"`'[^'`']##'`"'|'$('[^')']##')'|'"$('[^')']##')"'|['<>=']'('[^')']##')') ]]; then - s=${${token##('"'|)(['$<>']|)?}%%?('"'|)} - (( ic )) && tokens+=(';' ${(Z+C+)s}) || tokens+=(';' ${(z)s}) - fi - ;; - esac - - case $state in - *r) - state[-1]= - continue - ;; - a) - if [[ $token == $skip ]]; then - if [[ $token == '{' ]]; then - P9K_COMMANDS+=$cmd - cmd= - state= - else - skip='{' - fi - continue - else - state=t - fi - ;& # fall through - t|p*) - if (( $+__p9k_pb_term[$token] )); then - if [[ $token == '()' ]]; then - state= - else - P9K_COMMANDS+=$cmd - if [[ $token == '}' ]]; then - state=a - skip=always - else - skip=$__p9k_pb_term_skip[$token] - state=${skip:+s} - fi - fi - cmd= - continue - elif [[ $state == t ]]; then - continue - elif [[ $state == *x ]]; then - if (( $+__p9k_pb_redirect[$token] )); then - prev= - state[-1]=r - continue - else - state[-1]= - fi - fi - ;; - s) - if [[ $token == $~skip ]]; then - state= - fi - continue - ;; - h) - while (( $#tokens )); do - (( e = ${tokens[(i)${(Q)token}]} )) - if [[ $tokens[e-1] == ';' && $tokens[e+1] == ';' ]]; then - tokens[1,e]=() - break - else - tokens[1,e]=() - fi - done - while (( $#alp && alp[-1] >= $#tokens )); do - aln[-1]=() - alp[-1]=() - done - state=t - continue - ;; - esac - - if (( $+__p9k_pb_redirect[${token#<0-255>}] )); then - state+=r - continue - fi - - if [[ $token == *'$'* ]]; then - if [[ $token == $~var ]]; then - n=${${token##[^[:IDENT:]]}%%[^[:IDENT:]]} - [[ $token == *'"' ]] && v=("${(P)n}") || v=(${(P)n}) - tokens[1,0]=(${(@qq)v}) - continue - fi - fi - - case $state in - '') - if (( $+__p9k_pb_cmd_skip[$token] )); then - skip=$__p9k_pb_cmd_skip[$token] - [[ $token == '}' ]] && state=a || state=${skip:+s} - continue - fi - if [[ $token == *=* ]]; then - v=${(S)token/#(<->|([[:alpha:]_][[:IDENT:]]#(|'['*[^\\](\\\\)#']')))(|'+')=} - if (( $#v < $#token )); then - if [[ $v == '(' ]]; then - state=s - skip='\)' - fi - continue - fi - fi - : ${token::=${(Q)${~token}}} - ;; - p2) - if [[ -n $prev ]]; then - prev= - else - : ${token::=${(Q)${~token}}} - if [[ $token == '{'$~id'}' ]]; then - state=p2x - prev=$token - else - state=p - fi - continue - fi - ;& # fall through - p) - if [[ -n $prev ]]; then - token=$prev - prev= - else - : ${token::=${(Q)${~token}}} - case $token in - '{'$~id'}') prev=$token; state=px; continue;; - [^-]*) ;; - --) state=p1; continue;; - $~skip) state=p2; continue;; - *) continue;; - esac - fi - ;; - p1) - if [[ -n $prev ]]; then - token=$prev - prev= - else - : ${token::=${(Q)${~token}}} - if [[ $token == '{'$~id'}' ]]; then - state=p1x - prev=$token - continue - fi - fi - ;; - esac - - if (( $+__p9k_pb_precommand[$token] )); then - prev= - state=p - skip=$__p9k_pb_precommand[$token] - cmd+=$token$'\0' - else - state=t - [[ $token == ('(('*'))'|'`'*'`'|'$'*|['<>=']'('*')'|*$'\0'*) ]] || cmd+=$token$'\0' - fi - done - } always { - [[ $state == (px|p1x) ]] && cmd+=$prev - P9K_COMMANDS+=$cmd - P9K_COMMANDS=(${(u)P9K_COMMANDS%$'\0'}) - } -} diff --git a/.zsh/themes/powerlevel10k/internal/wizard.zsh b/.zsh/themes/powerlevel10k/internal/wizard.zsh deleted file mode 100644 index 7b6de60..0000000 --- a/.zsh/themes/powerlevel10k/internal/wizard.zsh +++ /dev/null @@ -1,2187 +0,0 @@ -local -i force=0 - -local opt -while getopts 'f' opt; do - case $opt in - f) force=1;; - +f) force=0;; - \?) return 1;; - esac -done - -if (( OPTIND <= ARGC )); then - print -lr -- "wizard.zsh: invalid arguments: $@" >&2 - return 1 -fi - -local -i in_z4h_wizard=0 -[[ $force == 0 && $+functions[z4h] == 1 && -n $Z4H && -e $Z4H/welcome ]] && in_z4h_wizard=1 - -local -i success=0 - -local -ri force - -local -r font_base_url='https://github.com/romkatv/powerlevel10k-media/raw/master' - -local -ri prompt_indent=2 - -local -rA pure_original=(grey 242 red 1 yellow 3 blue 4 magenta 5 cyan 6 white 7) -local -rA pure_snazzy=(grey 242 red '#FF5C57' yellow '#F3F99D' blue '#57C7FF' magenta '#FF6AC1' cyan '#9AEDFE' white '#F1F1F0') -local -ra bg_color=(240 238 236 234) -local -ra sep_color=(248 246 244 242) -local -ra prefix_color=(250 248 246 244) - -local -r left_circle='\uE0B6' -local -r right_circle='\uE0B4' -local -r left_arc='\uE0B7' -local -r right_arc='\uE0B5' -local -r left_triangle='\uE0B2' -local -r right_triangle='\uE0B0' -local -r left_angle='\uE0B3' -local -r right_angle='\uE0B1' -local -r fade_in='░▒▓' -local -r fade_out='▓▒░' -local -r vertical_bar='\u2502' - -local -r cursor='%1{\e[07m \e[27m%}' - -local -r time_24h='16:23:42' -local -r time_12h='04:23:42 PM' - -local -ra lean_left=( - '%$frame_color[$color]F╭─ ' '${extra_icons[1]:+%f$extra_icons[1] }%31F$extra_icons[2]%B%39F~%b%31F/%B%39Fsrc%b%f $prefixes[1]%76F$extra_icons[3]master%f ' - '%$frame_color[$color]F╰─' '%76F$prompt_char%f ${buffer:-$cursor}' -) - -local -ra lean_right=( - ' $prefixes[2]%101F$extra_icons[4]5s%f${time:+ $prefixes[3]%66F$extra_icons[5]$time%f}' ' %$frame_color[$color]F─╮%f' - '' ' %$frame_color[$color]F─╯%f' -) - -local -ra lean_8colors_left=( - '%$frame_color[$color]F╭─ ' '${extra_icons[1]:+%f$extra_icons[1] }%4F$extra_icons[2]%4F~/src%f $prefixes[1]%2F$extra_icons[3]master%f ' - '%$frame_color[$color]F╰─' '%2F$prompt_char%f ${buffer:-$cursor}' -) - -local -ra lean_8colors_right=( - ' $prefixes[2]%3F$extra_icons[4]5s%f${time:+ $prefixes[3]%6F$extra_icons[5]$time%f}' ' %$frame_color[$color]F─╮%f' - '' ' %$frame_color[$color]F─╯%f' -) - -local -ra classic_left=( - '%$frame_color[$color]F╭─' '%F{$bg_color[$color]}$left_tail%K{$bg_color[$color]} ${extra_icons[1]:+%255F$extra_icons[1] %$sep_color[$color]F$left_subsep%f }%31F$extra_icons[2]%B%39F~%b%K{$bg_color[$color]}%31F/%B%39Fsrc%b%K{$bg_color[$color]} %$sep_color[$color]F$left_subsep%f %$prefix_color[$color]F$prefixes[1]%76F$extra_icons[3]master %k%$bg_color[$color]F$left_head%f' - '%$frame_color[$color]F╰─' '%f ${buffer:-$cursor}' -) - -local -ra classic_right=( - '%$bg_color[$color]F$right_head%K{$bg_color[$color]}%f %$prefix_color[$color]F$prefixes[2]%101F5s $extra_icons[4]${time:+%$sep_color[$color]F$right_subsep %$prefix_color[$color]F$prefixes[3]%66F$time $extra_icons[5]}%k%F{$bg_color[$color]}$right_tail%f' '%$frame_color[$color]F─╮%f' - '' '%$frame_color[$color]F─╯%f' -) - -local -ra pure_left=( - '' '%F{$pure_color[blue]}~/src%f %F{$pure_color[grey]}master%f ${pure_use_rprompt-%F{$pure_color[yellow]\}5s%f }' - '' '%F{$pure_color[magenta]}$prompt_char%f ${buffer:-$cursor}' -) - -local -ra pure_right=( - '${pure_use_rprompt+%F{$pure_color[yellow]\}5s%f${time:+ }}${time:+%F{$pure_color[grey]\}$time%f}' '' - '' '' -) - -local -ra rainbow_left=( - '%$frame_color[$color]F╭─' '%F{${${extra_icons[1]:+7}:-4}}$left_tail${extra_icons[1]:+%K{7\}%232F $extra_icons[1] %K{4\}%7F$left_sep}%K{4}%254F $extra_icons[2]%B%255F~%b%K{4}%254F/%B%255Fsrc%b%K{4} %K{2}%4F$left_sep %0F$prefixes[1]$extra_icons[3]master %k%2F$left_head%f' - '%$frame_color[$color]F╰─' '%f ${buffer:-$cursor}' -) - -local -ra rainbow_right=( - '%3F$right_head%K{3} %0F$prefixes[2]5s $extra_icons[4]%3F${time:+%7F$right_sep%K{7\} %0F$prefixes[3]$time $extra_icons[5]%7F}%k$right_tail%f' '%$frame_color[$color]F─╮%f' - '' '%$frame_color[$color]F─╯%f' -) - -function prompt_length() { - local -i COLUMNS=1024 - local -i x y=$#1 m - if (( y )); then - while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do - x=y - (( y *= 2 )) - done - while (( y > x + 1 )); do - (( m = x + (y - x) / 2 )) - (( ${${(%):-$1%$m(l.x.y)}[-1]} = m )) - done - fi - typeset -g REPLY=$x -} - -function print_prompt() { - [[ $parameters[extra_icons] == scalar* ]] && eval "local -a extra_icons=$extra_icons" - [[ $parameters[pure_color] == scalar* ]] && eval "local -A pure_color=$pure_color" - [[ $parameters[prefixes] == scalar* ]] && eval "local -a prefixes=$prefixes" - - local left=${style}_left - local right=${style}_right - left=("${(@P)left}") - right=("${(@P)right}") - (( disable_rprompt )) && right=() - eval "left=(${(@)left:/(#b)(*)/\"$match[1]\"})" - eval "right=(${(@)right:/(#b)(*)/\"$match[1]\"})" - if (( num_lines == 1)); then - left=($left[2] $left[4]) - right=($right[1] $right[3]) - else - local c=76 - [[ $style == pure ]] && c=$pure_color[magenta] - [[ $style == lean_8colors ]] && c=2 - (( left_frame )) || left=('' $left[2] '' "%F{$c}$prompt_char%f ${buffer:-$cursor}") - (( right_frame )) || right=($right[1] '' '' '') - fi - local -i left_indent=prompt_indent - local -i right_indent=prompt_indent - prompt_length ${(g::):-$left[1]$left[2]$right[1]$right[2]} - local -i width=REPLY - while (( wizard_columns - width <= left_indent + right_indent )); do - if (( right_indent )); then - (( --right_indent )) - elif (( left_indent )); then - (( --left_indent )) - else - print -P ' [%3Fnot enough horizontal space to display this%f]' - return 0 - fi - done - local -i i - for ((i = 1; i < $#left; i+=2)); do - local l=${(g::):-$left[i]$left[i+1]} - local r=${(g::):-$right[i]$right[i+1]} - prompt_length $l$r - local -i gap=$((wizard_columns - left_indent - right_indent - REPLY)) - (( num_lines == 2 && i == 1 )) && local fill=$gap_char || local fill=' ' - print -n -- ${(pl:$left_indent:: :)} - print -nP -- $l - print -nP -- "%$frame_color[$color]F${(pl:$gap::$fill:)}%f" - print -P -- $r - done -} - -function href() { - local url=${${1//\%/%%}//\\/\\\\} - if (( _p9k_term_has_href )); then - print -r -- '%{\e]8;;'$url'\a%}'$url'%{\e]8;;\a%}' - else - print -r -- $url - fi -} - -function flowing() { - (( ${wizard_columns:-0} )) || local -i wizard_columns=COLUMNS - local opt - local -i centered indentation - while getopts 'ci:' opt; do - case $opt in - i) indentation=$OPTARG;; - c) centered=1;; - +c) centered=0;; - \?) exit 1;; - esac - done - shift $((OPTIND-1)) - local line word lines=() - for word in "$@"; do - prompt_length ${(g::):-"$line $word"} - if (( REPLY > wizard_columns )); then - [[ -z $line ]] || lines+=$line - line= - fi - if [[ -n $line ]]; then - line+=' ' - elif (( $#lines )); then - line=${(pl:$indentation:: :)} - fi - line+=$word - done - [[ -z $line ]] || lines+=$line - for line in $lines; do - prompt_length ${(g::)line} - (( centered && REPLY < wizard_columns )) && print -n -- ${(pl:$(((wizard_columns - REPLY) / 2)):: :)} - print -P -- $line - done -} - -function clear() { - if (( $+commands[clear] )) && command clear 2>/dev/null; then - return - fi - echoti clear 2>/dev/null - print -n -- "\e[H\e[2J\e[3J" -} - -function hide_cursor() { - (( $+terminfo[cnorm] )) || return - echoti civis 2>/dev/null -} - -function show_cursor() { - local cnorm=${terminfo[cnorm]-} - if [[ $cnorm == *$'\e[?25h'(|'\e'*) ]]; then - print -n '\e[?25h' - else - print -n $cnorm - fi -} - -function consume_input() { - local key - while true; do - [[ -t 2 ]] - read -t0 -k key || break - done 2>/dev/null -} - -function quit() { - consume_input - if [[ $1 == '-c' ]]; then - print -Pr -- '' - print -Pr -- '%b%k%f%u%s' - print -Pr -- '%F{3}--- stack trace (most recent call first) ---%f' - print -lr -- $funcfiletrace - print -Pr -- '%F{3}--- end of stack trace ---%f' - print -Pr -- '' - print -Pr -- 'Press %BENTER%b to continue.' - hide_cursor - read -s - fi - restore_screen - print - if (( force )); then - flowing Powerlevel10k configuration wizard has been aborted. To run it again, type: - print -P "" - print -P " %2Fp10k%f %Bconfigure%b" - print -P "" - else - flowing \ - Powerlevel10k configuration wizard has been aborted. It will run again \ - next time unless you define at least one Powerlevel10k configuration option. \ - To define an option that does nothing except for disabling Powerlevel10k \ - configuration wizard, type the following command: - print -P "" - print -P " %2Fecho%f %3F'POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true'%f >>! $__p9k_zshrc_u" - print -P "" - flowing To run Powerlevel10k configuration wizard right now, type: - print -P "" - print -P " %2Fp10k%f %Bconfigure%b" - print -P "" - fi - function quit() {} - stty echo 2>/dev/null - show_cursor - exit 1 -} - -local screen_widgets=() -local -i max_priority -local -i prompt_idx -local choice - -function add_widget() { - local priority=$1 - shift - local render="${(j: :)${(@q)*}}" - screen_widgets+=("$priority" "$render") - (( priority <= max_priority )) || max_priority=priority -} - -function render_screen_pass() { - local -i pass=$1 - local -i prev_pass cur_pass - local prev_render cur_render - for cur_pass cur_render in "${(@)screen_widgets}" 0 ''; do - if (( prev_pass <= pass && (cur_pass == 0 || cur_pass > pass) )); then - eval $prev_render - fi - prev_pass=cur_pass - prev_render=$cur_render - done -} - -function get_columns() { return 'COLUMNS > 88 ? 88 : COLUMNS' } -functions -M get_columns 0 0 - -function render_screen() { - { - hide_cursor - while true; do - while true; do - typeset -gi wizard_columns='get_columns()' - typeset -gi wizard_lines=LINES - if (( wizard_columns < __p9k_wizard_columns )); then - clear - flowing -c %1FNot enough horizontal space.%f - print - flowing Make terminal window %Bwider%b or press %BCtrl-C%b to abort Powerlevel10k configuration wizard. - elif (( wizard_lines < __p9k_wizard_lines )); then - clear - flowing -c %1FNot enough vertical space.%f - print - flowing Make terminal window %Btaller%b or press %BCtrl-C%b to abort Powerlevel10k configuration wizard. - else - break - fi - while (( get_columns() == wizard_columns && LINES == wizard_lines )); do - sleep 1 - done - done - - local -a passes - () { - local -i pass - local render - for pass render in "${(@)screen_widgets}"; do - passes+=$pass - done - passes=(${(onu)passes}) - } - - local -i pass - for pass in $passes; do - local content="$(render_screen_pass $pass)" - local lines=("${(@f)content}") - (( $#lines > wizard_lines )) && continue - clear - print -rn -- $content - return 0 - done - - clear - flowing -c %1FNot enough vertical space.%f - print - flowing Make terminal window %Btaller%b or press %BCtrl-C%b to abort Powerlevel10k configuration wizard. - while (( get_columns() == wizard_columns && LINES == wizard_lines )); do - sleep 1 - done - done - } always { - show_cursor - } -} - -function add_prompt_n() { - add_widget 0 "$@" print_prompt - local var - for var; do - eval "local ${(q)var}" - done - if (( num_lines == 2 )); then - add_widget $(( 100 - ++prompt_idx )) print -P ' [%3Fnot enough vertical space to display this%f]' - fi -} - -function add_prompt() { - add_widget 0 print - add_widget 1 - add_prompt_n "$@" - add_widget 0 print - add_widget 2 -} - -function ask() { - local choices=$1 - local -i lines columns wizard_lines wizard_columns - add_widget 0 print -P "(q) Quit and do nothing." - add_widget 0 print - add_widget $((max_priority + 1)) - add_widget 0 print -P "%BChoice [${choices}q]: %b" - while true; do - =true - if (( LINES != lines || get_columns() != columns )); then - render_screen - lines=wizard_lines - columns=wizard_columns - fi - typeset -g choice= - if read -t1 -k choice; then - choice=${(L)choice} - if [[ $choice == q ]]; then - quit - fi - if [[ $choices == *$choice* ]]; then - screen_widgets=() - max_priority=0 - prompt_idx=0 - return - fi - fi - done -} - -local -i greeting_printed=0 - -function print_greeting() { - (( greeting_printed )) && return - if (( in_z4h_wizard )); then - flowing -c %3FZsh for Humans%f uses %4FPowerlevel10k%f to print command \ - line prompt. This wizard will ask you a few questions and configure \ - prompt for you. - elif (( force )); then - flowing -c This is %4FPowerlevel10k configuration wizard%f. \ - It will ask you a few questions and configure your prompt. - else - flowing -c This is %4FPowerlevel10k configuration wizard%f. \ - You are seeing it because you haven\'t defined any \ - Powerlevel10k configuration options. It will ask \ - you a few questions and configure your prompt. - fi - print -P "" -} - -function iterm_get() { - /usr/libexec/PlistBuddy -c "Print :$1" ~/Library/Preferences/com.googlecode.iterm2.plist -} - -local terminal iterm2_font_size iterm2_old_font=0 can_install_font=0 - -() { - [[ $P9K_SSH == 0 ]] || return - if [[ "$(uname)" == Linux && "$(uname -o)" == Android ]]; then - (( $+commands[termux-reload-settings] )) || return - (( $+commands[curl] )) || return - if [[ -f ~/.termux/font.ttf ]]; then - [[ -r ~/.termux/font.ttf ]] || return - [[ -w ~/.termux/font.ttf ]] || return - ! grep -q 'MesloLGS NF' ~/.termux/font.ttf 2>/dev/null || return - fi - if [[ -f ~/.termux ]]; then - [[ -d ~/.termux && -w ~/.termux ]] || return - else - [[ -w ~ ]] || return - fi - terminal=Termux - return 0 - fi - if [[ "$(uname)" == Darwin && $TERM_PROGRAM == iTerm.app ]]; then - (( $+commands[curl] )) || return - [[ $TERM_PROGRAM_VERSION == [2-9]* ]] || return - if [[ -f ~/Library/Fonts ]]; then - [[ -d ~/Library/Fonts && -w ~/Library/Fonts ]] || return - else - [[ -d ~/Library && -w ~/Library ]] || return - fi - [[ -x /usr/libexec/PlistBuddy ]] || return - [[ -x /usr/bin/plutil ]] || return - [[ -x /usr/bin/defaults ]] || return - [[ -f ~/Library/Preferences/com.googlecode.iterm2.plist ]] || return - [[ -r ~/Library/Preferences/com.googlecode.iterm2.plist ]] || return - [[ -w ~/Library/Preferences/com.googlecode.iterm2.plist ]] || return - local guid1 && guid1="$(iterm_get '"Default Bookmark Guid"' 2>/dev/null)" || return - local guid2 && guid2="$(iterm_get '"New Bookmarks":0:"Guid"' 2>/dev/null)" || return - local font && font="$(iterm_get '"New Bookmarks":0:"Normal Font"' 2>/dev/null)" || return - [[ $guid1 == $guid2 ]] || return - [[ $font != 'MesloLGS-NF-Regular '<-> ]] || return - [[ $font == (#b)*' '(<->) ]] || return - [[ $font == 'MesloLGSNer-Regular '<-> ]] && iterm2_old_font=1 - iterm2_font_size=$match[1] - terminal=iTerm2 - return 0 - fi - return 1 -} && can_install_font=1 - -function run_command() { - local msg=$1 - shift - [[ -n $msg ]] && print -nP -- "$msg ..." - local err && err="$("$@" 2>&1)" || { - print -P " %1FERROR%f" - print -P "" - print -nP "%BCommand:%b " - print -r -- "${(@q)*}" - if [[ -n $err ]]; then - print -P "" - print -r -- $err - fi - quit -c - } - [[ -n $msg ]] && print -P " %2FOK%f" -} - -function install_font() { - clear - case $terminal in - Termux) - command mkdir -p -- ~/.termux || quit -c - run_command "Downloading %BMesloLGS NF Regular.ttf%b" \ - curl -fsSL -o ~/.termux/font.ttf "$font_base_url/MesloLGS%20NF%20Regular.ttf" - run_command "Reloading %BTermux%b settings" termux-reload-settings - ;; - iTerm2) - command mkdir -p -- ~/Library/Fonts || quit -c - local style - for style in Regular Bold Italic 'Bold Italic'; do - local file="MesloLGS NF ${style}.ttf" - run_command "Downloading %B$file%b" \ - curl -fsSL -o ~/Library/Fonts/$file.tmp "$font_base_url/${file// /%20}" - command mv -f -- ~/Library/Fonts/$file{.tmp,} || quit -c - done - print -nP -- "Changing %BiTerm2%b settings ..." - local size=$iterm2_font_size - [[ $size == 12 ]] && size=13 - local k t v settings=( - '"Normal Font"' string '"MesloLGS-NF-Regular '$size'"' - '"Terminal Type"' string '"xterm-256color"' - '"Horizontal Spacing"' real 1 - '"Vertical Spacing"' real 1 - '"Minimum Contrast"' real 0 - '"Use Bold Font"' bool 1 - '"Use Bright Bold"' bool 1 - '"Use Italic Font"' bool 1 - '"ASCII Anti Aliased"' bool 1 - '"Non-ASCII Anti Aliased"' bool 1 - '"Use Non-ASCII Font"' bool 0 - '"Ambiguous Double Width"' bool 0 - '"Draw Powerline Glyphs"' bool 1 - '"Only The Default BG Color Uses Transparency"' bool 1 - ) - for k t v in $settings; do - /usr/libexec/PlistBuddy -c "Set :\"New Bookmarks\":0:$k $v" \ - ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null && continue - run_command "" /usr/libexec/PlistBuddy -c \ - "Add :\"New Bookmarks\":0:$k $t $v" ~/Library/Preferences/com.googlecode.iterm2.plist - done - print -P " %2FOK%f" - print -nP "Updating %BiTerm2%b settings cache ..." - run_command "" /usr/bin/defaults read com.googlecode.iterm2 - sleep 3 - print -P " %2FOK%f" - sleep 1 - clear - hide_cursor - print - flowing +c "%2FMeslo Nerd Font%f" successfully installed. - print -P "" - () { - local out - out=$(/usr/bin/defaults read 'Apple Global Domain' NSQuitAlwaysKeepsWindows 2>/dev/null) || return - [[ $out == 1 ]] || return - out="$(iterm_get OpenNoWindowsAtStartup 2>/dev/null)" || return - [[ $out == false ]] - } - if (( $? )); then - flowing +c Please "%Brestart iTerm2%b" for the changes to take effect. - print -P "" - flowing +c -i 5 " 1. Click" "%BiTerm2 → Quit iTerm2%b" or press "%B⌘ Q%b." - flowing +c -i 5 " 2. Open %BiTerm2%b." - print -P "" - flowing +c "It's" important to "%Brestart iTerm2%b" by following the instructions above. \ - "It's" "%Bnot enough%b" to close iTerm2 by clicking on the red circle. You must \ - click "%BiTerm2 → Quit iTerm2%b" or press "%B⌘ Q%b." - else - flowing +c Please "%Brestart your computer%b" for the changes to take effect. - fi - while true; do sleep 60 2>/dev/null; done - ;; - esac - - return 0 -} - -function ask_font() { - (( can_install_font )) || return 0 - add_widget 0 print_greeting - if (( iterm2_old_font )); then - add_widget 0 flowing -c A new version of '%2FMeslo Nerd Font%f' is available. '%BInstall?%b' - else - add_widget 0 flowing -c %BInstall '%b%2FMeslo Nerd Font%f%B?%b' - fi - add_widget 0 print - add_widget 0 print -P "%B(y) Yes (recommended).%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(n) No. Use the current font.%b" - add_widget 0 print - add_widget 1 - ask yn - greeting_printed=1 - case $choice in - y) - ask_remove_font || return - install_font - ;; - n) ;; - esac - return 0 -} - -function print_file_path() { - local file=$1 - if (( ${(m)#file} > wizard_columns - 2 )); then - file[wizard_columns-4,-1]='...' - fi - add_widget 0 print -P " %B${file//\%/%%}%b" -} - -function ask_remove_font() { - local font - local -a fonts - local -i protected - for font in {,/System,~}/Library/Fonts/**/*[Mm]eslo*.(ttf|otf)(N:A); do - [[ -f $font && -r $font ]] || continue - [[ $font == ~/Library/Fonts/'MesloLGS NF '(Regular|Bold|Italic|Bold\ Italic).ttf ]] && continue - [[ "$(<$font)" == *"MesloLGS NF"$'\0'* ]] || continue - fonts+=$font - [[ -w ${font:h} ]] || protected=1 - done - (( $#fonts )) || return 0 - add_widget 0 flowing -c A variant of "%2FMeslo Nerd Font%f" is already installed. - add_widget 0 print -P "" - for font in $fonts; do - add_widget 0 print_file_path $font - done - add_widget 0 print -P "" - if (( protected )); then - if (( $#fonts == 1 )); then - add_widget 0 flowing Please %Bdelete%b this file and run '%2Fp10k%f %Bconfigure%b.' - else - add_widget 0 flowing Please %Bdelete%b these files and run '%2Fp10k%f %Bconfigure%b.' - fi - add_widget 0 print - restore_screen - local pass render - for pass render in "${(@)screen_widgets}"; do - (( pass == 0 )) && eval $render - done - exit 1 - fi - if (( $#fonts == 1 )); then - add_widget 0 flowing -c "%BDelete this file?%b" - else - add_widget 0 flowing -c "%BDelete these files?%b" - fi - add_widget 0 print -P "" - add_widget 0 print -P "%B(y) Yes (recommended).%b" - add_widget 0 print -P "" - add_widget 0 print -P "(r) Restart from the beginning." - ask yr - case $choice in - r) return 1;; - y) zf_rm -f -- $fonts || quit -c;; - esac - return 0 -} - -function ask_diamond() { - local extra - add_widget 0 print_greeting - add_widget 0 flowing -c %BDoes this look like a%b %2Fdiamond%f '%B(rotated square)?%b' - add_widget 0 flowing -c reference: "$(href https://graphemica.com/%E2%97%86)" - add_widget 0 print - add_widget 0 flowing -c -- "---> \uE0B2\uE0B0 <---" - add_widget 0 print - add_widget 3 - add_widget 0 print -P "%B(y) Yes.%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(n) No.%b" - add_widget 0 print - add_widget 2 - if (( can_install_font )); then - extra+=r - add_widget 0 print -P "(r) Restart from the beginning." - fi - ask yn$extra - greeting_printed=1 - case $choice in - r) return 1;; - y) cap_diamond=1;; - n) cap_diamond=0;; - esac - return 0 -} - -function ask_lock() { - [[ -n $2 ]] && add_widget 0 flowing -c "$2" - add_widget 0 flowing -c "%BDoes this look like a %b%2Flock%f%B?%b" - add_widget 0 flowing -c "reference: $(href https://fontawesome.com/icons/lock)" - add_widget 0 print - add_widget 0 flowing -c -- "---> $1 <---" - add_widget 0 print - add_widget 3 - add_widget 0 print -P "%B(y) Yes.%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(n) No.%b" - add_widget 0 print - add_widget 2 - add_widget 0 print -P "(r) Restart from the beginning." - ask ynr - case $choice in - r) return 1;; - y) cap_lock=1;; - n) cap_lock=0;; - esac - return 0 -} - -function ask_python() { - add_widget 0 flowing -c %BDoes this look like a "%b%2FPython logo%f%B?%b" - add_widget 0 flowing -c reference: "$(href https://fontawesome.com/icons/python)" - add_widget 0 print -P "" - add_widget 0 flowing -c -- "---> \uE63C <---" - add_widget 0 print -P "" - add_widget 3 - add_widget 0 print -P "%B(y) Yes.%b" - add_widget 0 print -P "" - add_widget 1 - add_widget 0 print -P "%B(n) No.%b" - add_widget 0 print -P "" - add_widget 2 - add_widget 0 print -P "(r) Restart from the beginning." - ask ynr - case $choice in - r) return 1;; - y) cap_python=1;; - n) cap_python=0;; - esac - return 0 -} - -function ask_arrow() { - add_widget 0 flowing -c %BDoes this look like%b "%2F><%f" %Bbut taller and "fatter?%b" - add_widget 0 print -P "" - add_widget 0 flowing -c -- "---> \u276F\u276E <---" - add_widget 0 print -P "" - add_widget 3 - add_widget 0 print -P "%B(y) Yes.%b" - add_widget 0 print -P "" - add_widget 1 - add_widget 0 print -P "%B(n) No.%b" - add_widget 0 print -P "" - add_widget 2 - add_widget 0 print -P "(r) Restart from the beginning." - ask ynr - case $choice in - r) return 1;; - y) cap_arrow=1;; - n) cap_arrow=0;; - esac - return 0 -} - -function ask_debian() { - add_widget 0 flowing -c %BDoes this look like a%b "%2FDebian logo%f" "%B(swirl/spiral)?%b" - add_widget 0 flowing -c reference: "$(href https://debian.org/logos/openlogo-nd.svg)" - add_widget 0 print -P "" - add_widget 0 flowing -c -- "---> \uF306 <---" - add_widget 0 print -P "" - add_widget 3 - add_widget 0 print -P "%B(y) Yes.%b" - add_widget 0 print -P "" - add_widget 1 - add_widget 0 print -P "%B(n) No.%b" - add_widget 0 print -P "" - add_widget 2 - add_widget 0 print -P "(r) Restart from the beginning." - ask ynr - case $choice in - r) return 1;; - y) cap_debian=1;; - n) cap_debian=0;; - esac - return 0 -} - -function ask_icon_padding() { - if [[ $POWERLEVEL9K_MODE == (powerline|compatible|ascii) ]]; then - POWERLEVEL9K_ICON_PADDING=none - return 0 - fi - - local text="X" - text+="%1F${icons[VCS_GIT_ICON]// }%fX" - text+="%2F${icons[VCS_GIT_GITHUB_ICON]// }%fX" - text+="%3F${icons[TIME_ICON]// }%fX" - text+="%4F${icons[RUBY_ICON]// }%fX" - text+="%5F${icons[HOME_ICON]// }%fX" - text+="%6F${icons[HOME_SUB_ICON]// }%fX" - text+="%1F${icons[FOLDER_ICON]// }%fX" - text+="%2F${icons[RAM_ICON]// }%fX" - - add_widget 0 flowing -c %BDo all these icons "%b%2Ffit between the crosses%f%B?%b" - add_widget 0 print -P "" - add_widget 0 flowing -c -- "---> $text <---" - add_widget 0 print -P "" - add_widget 3 - add_widget 0 flowing +c -i 5 "%B(y) Yes." Icons are very close to the crosses but there is "%b%2Fno overlap%f%B.%b" - add_widget 0 print -P "" - add_widget 1 - add_widget 0 flowing +c -i 5 "%B(n) No." Some icons "%b%2Foverlap%f%B" neighbouring crosses.%b - add_widget 0 print -P "" - add_widget 2 - add_widget 0 print -P "(r) Restart from the beginning." - ask ynr - case $choice in - r) return 1;; - y) - POWERLEVEL9K_ICON_PADDING=none - options+='small icons' - ;; - n) - POWERLEVEL9K_ICON_PADDING=moderate - options+='large icons' - up_triangle+=' ' - down_triangle+=' ' - slanted_bar='\uE0BD ' - ;; - esac - return 0 -} - -function ask_style() { - if (( terminfo[colors] < 256 )); then - style=lean_8colors - left_frame=0 - right_frame=0 - frame_color=(0 7 2 4) - color_name=(Black White Green Blue) - options+=lean_8colors - return 0 - fi - local extra - add_widget 0 flowing -c "%BPrompt Style%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) Lean.%b" - add_prompt style=lean left_frame=0 right_frame=0 - add_widget 0 print -P "%B(2) Classic.%b" - add_prompt style=classic - add_widget 0 print -P "%B(3) Rainbow.%b" - add_prompt style=rainbow - if [[ $POWERLEVEL9K_MODE != ascii ]]; then - extra+=4 - add_widget 0 print -P "%B(4) Pure.%b" - add_prompt style=pure - fi - add_widget 0 print -P "(r) Restart from the beginning." - ask 123${extra}r - case $choice in - r) return 1;; - 1) style=lean; left_frame=0; right_frame=0; options+=lean;; - 2) style=classic; options+=classic;; - 3) style=rainbow; options+=rainbow;; - 4) style=pure; empty_line=1; options+=pure;; - esac - return 0 -} - -function ask_charset() { - [[ $style == (lean*|classic|rainbow) && $POWERLEVEL9K_MODE != ascii ]] || return 0 - add_widget 0 flowing -c "%BCharacter Set%b" - add_widget 0 print -P "" - add_widget 1 - add_widget 0 print -P "%B(1) Unicode.%b" - add_prompt - add_widget 0 print -P "%B(2) ASCII.%b" - add_prompt \ - left_sep= \ - right_sep= \ - left_subsep='|' \ - right_subsep='|' \ - left_head= \ - right_head= \ - prompt_char='>' \ - left_frame=0 \ - right_frame=0 - add_widget 0 print -P "(r) Restart from the beginning." - ask 12r - case $choice in - r) return 1;; - 1) options+=unicode;; - 2) - options+=ascii - left_sep= - right_sep= - left_subsep='|' - right_subsep='|' - left_head= - right_head= - prompt_char='>' - left_frame=0 - right_frame=0 - POWERLEVEL9K_MODE=ascii - POWERLEVEL9K_ICON_PADDING=none - cap_diamond=0 - cap_python=0 - cap_debian=0 - cap_lock=0 - cap_arrow=0 - ;; - esac - return 0 -} - -function ask_color_scheme() { - (( terminfo[colors] < 256 )) && return - if [[ $style == lean ]]; then - add_widget 0 flowing -c "%BPrompt Colors%b" - add_widget 0 print -P "" - add_widget 1 - add_widget 0 print -P "%B(1) 256 colors.%b" - add_prompt style=lean - add_widget 0 print -P "%B(2) 8 colors.%b" - add_prompt style=lean_8colors - add_widget 0 print -P "(r) Restart from the beginning." - ask 12r - case $choice in - r) return 1;; - 1) style=lean;; - 2) - style=lean_8colors - frame_color=(0 7 2 4) - color_name=(Black White Green Blue) - ;; - esac - options=(${options:#lean} $style) - elif [[ $style == pure && $has_truecolor == 1 ]]; then - add_widget 0 flowing -c "%BPrompt Colors%b" - add_widget 0 print -P "" - add_widget 1 - add_widget 0 print -P "%B(1) Original.%b" - add_prompt "pure_color=(${(j: :)${(@q)${(@kv)pure_original}}})" - add_widget 0 print -P "%B(2) Snazzy.%b" - add_prompt "pure_color=(${(j: :)${(@q)${(@kv)pure_snazzy}}})" - add_widget 0 print -P "(r) Restart from the beginning." - ask 12r - case $choice in - r) return 1;; - 1) - pure_color=(${(kv)pure_original}) - options+=original - ;; - 2) - pure_color=(${(kv)pure_snazzy}) - options+=snazzy - ;; - esac - fi - return 0 -} - -function ask_color() { - [[ $style != classic ]] && return - add_widget 0 flowing -c "%BPrompt Color%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) $color_name[1].%b" - add_prompt color=1 - add_widget 0 print -P "%B(2) $color_name[2].%b" - add_prompt color=2 - add_widget 0 print -P "%B(3) $color_name[3].%b" - add_prompt color=3 - add_widget 0 print -P "%B(4) $color_name[4].%b" - add_prompt color=4 - add_widget 0 print -P "(r) Restart from the beginning." - ask 1234r - case $choice in - r) return 1;; - [1-4]) color=$choice;; - esac - options+=${${(L)color_name[color]}//ı/i} - return 0 -} - -function print_frame_marker() { - local label="(1) $color_name[1]." - local -i n='wizard_columns - 7' - local -i m=$((n - $#label)) - print -P "${(l:$n:: :)}frame" - print -P "%B$label%b${(l:$m:: :)} |" - print -P "${(l:$n:: :)} v" -} - -function ask_ornaments_color() { - [[ $style != (rainbow|lean*) || $num_lines == 1 ]] && return - [[ $gap_char == ' ' && $left_frame == 0 && $right_frame == 0 ]] && return - local ornaments=() - [[ $gap_char != ' ' ]] && ornaments+=Connection - (( left_frame || right_frame )) && ornaments+=Frame - add_widget 0 flowing -c "%B${(j: & :)ornaments} Color%b" - if (( left_frame || right_frame )); then - add_widget 0 print_frame_marker - add_widget 3 print -P "%B(1) $color_name[1].%b" - add_prompt_n color=1 - add_widget 0 print - add_widget 2 - else - add_widget 1 - add_widget 0 print -P "%B(1) $color_name[1].%b" - add_prompt color=1 - fi - add_widget 0 print -P "%B(2) $color_name[2].%b" - add_prompt color=2 - add_widget 0 print -P "%B(3) $color_name[3].%b" - add_prompt color=3 - add_widget 0 print -P "%B(4) $color_name[4].%b" - add_prompt color=4 - add_widget 0 print -P "(r) Restart from the beginning." - ask 1234r - case $choice in - r) return 1;; - [1-4]) color=$choice;; - esac - options+=${${(L)color_name[color]}//ı/i}-ornaments - return 0 -} - -function ask_time() { - local extra - add_widget 0 flowing -c "%BShow current time?%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) No.%b" - add_prompt time= - add_widget 0 print -P "%B(2) 24-hour format.%b" - add_prompt time=$time_24h - add_widget 0 print -P "%B(3) 12-hour format.%b" - add_prompt time=$time_12h - add_widget 0 print -P "(r) Restart from the beginning." - ask 123r - case $choice in - r) return 1;; - 1) time=;; - 2) time=$time_24h; options+='24h time';; - 3) time=$time_12h; options+='12h time';; - esac - return 0 -} - -function ask_use_rprompt() { - [[ $style != pure ]] && return - add_widget 0 flowing -c "%BNon-permanent content location%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) Left.%b" - add_prompt - add_widget 0 print -P "%B(2) Right.%b" - add_prompt pure_use_rprompt= - add_widget 0 print -P "(r) Restart from the beginning." - ask 12r - case $choice in - r) return 1;; - 1) ;; - 2) pure_use_rprompt=; options+=rprompt;; - esac - return 0 -} - -function os_icon_name() { - local uname="$(uname)" - if [[ $uname == Linux && "$(uname -o 2>/dev/null)" == Android ]]; then - echo ANDROID_ICON - else - case $uname in - SunOS) echo SUNOS_ICON;; - Darwin) echo APPLE_ICON;; - CYGWIN_NT-*|MSYS_NT-*|MINGW64_NT-*|MINGW32_NT-*) echo WINDOWS_ICON;; - FreeBSD|OpenBSD|DragonFly) echo FREEBSD_ICON;; - Linux) - local os_release_id - if [[ -r /etc/os-release ]]; then - local lines=(${(f)"$(</etc/os-release)"}) - lines=(${(@M)lines:#ID=*}) - (( $#lines == 1 )) && os_release_id=${lines[1]#ID=} - elif [[ -e /etc/artix-release ]]; then - os_release_id=artix - fi - case $os_release_id in - *arch*) echo LINUX_ARCH_ICON;; - *debian*) echo LINUX_DEBIAN_ICON;; - *raspbian*) echo LINUX_RASPBIAN_ICON;; - *ubuntu*) echo LINUX_UBUNTU_ICON;; - *elementary*) echo LINUX_ELEMENTARY_ICON;; - *fedora*) echo LINUX_FEDORA_ICON;; - *coreos*) echo LINUX_COREOS_ICON;; - *gentoo*) echo LINUX_GENTOO_ICON;; - *mageia*) echo LINUX_MAGEIA_ICON;; - *centos*) echo LINUX_CENTOS_ICON;; - *opensuse*|*tumbleweed*) echo LINUX_OPENSUSE_ICON;; - *sabayon*) echo LINUX_SABAYON_ICON;; - *slackware*) echo LINUX_SLACKWARE_ICON;; - *linuxmint*) echo LINUX_MINT_ICON;; - *alpine*) echo LINUX_ALPINE_ICON;; - *aosc*) echo LINUX_AOSC_ICON;; - *nixos*) echo LINUX_NIXOS_ICON;; - *devuan*) echo LINUX_DEVUAN_ICON;; - *manjaro*) echo LINUX_MANJARO_ICON;; - *void*) echo LINUX_VOID_ICON;; - *artix*) echo LINUX_ARTIX_ICON;; - *rhel*) echo LINUX_RHEL_ICON;; - amzn) echo LINUX_AMZN_ICON;; - *) echo LINUX_ICON;; - esac - ;; - esac - fi -} - -function ask_extra_icons() { - if [[ $style == pure || $POWERLEVEL9K_MODE == (powerline|compatible|ascii) ]]; then - return 0 - fi - local os_icon=${(g::)icons[$(os_icon_name)]} - local dir_icon=${(g::)icons[HOME_SUB_ICON]} - local vcs_icon=${(g::)icons[VCS_GIT_GITHUB_ICON]} - local branch_icon=${(g::)icons[VCS_BRANCH_ICON]} - local duration_icon=${(g::)icons[EXECUTION_TIME_ICON]} - local time_icon=${(g::)icons[TIME_ICON]} - branch_icon=${branch_icon// } - local few=('' '' '' '' '') - local many=("$os_icon" "$dir_icon " "$vcs_icon $branch_icon " "$duration_icon " "$time_icon ") - add_widget 0 flowing -c "%BIcons%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) Few icons.%b" - add_prompt "extra_icons=(${(j: :)${(@q)few}})" - add_widget 0 print -P "%B(2) Many icons.%b" - add_prompt "extra_icons=(${(j: :)${(@q)many}})" - add_widget 0 print -P "(r) Restart from the beginning." - ask 12r - case $choice in - r) return 1;; - 1) extra_icons=("$few[@]"); options+='few icons';; - 2) extra_icons=("$many[@]"); options+='many icons';; - esac - return 0 -} - -function ask_prefixes() { - if [[ $style == pure ]]; then - return 0 - fi - local concise=('' '' '') - local fluent=('on ' 'took ' 'at ') - add_widget 0 flowing -c "%BPrompt Flow%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) Concise.%b" - add_prompt "prefixes=(${(j: :)${(@q)concise}})" - add_widget 0 print -P "%B(2) Fluent.%b" - add_prompt "prefixes=(${(j: :)${(@q)fluent}})" - add_widget 0 print -P "(r) Restart from the beginning." - ask 12r - case $choice in - r) return 1;; - 1) prefixes=("$concise[@]"); options+=concise;; - 2) prefixes=("$fluent[@]"); options+=fluent;; - esac - return 0 -} - -function ask_separators() { - if [[ $style != (classic|rainbow) || $cap_diamond != 1 ]]; then - return 0 - fi - local extra - add_widget 0 flowing -c "%BPrompt Separators%b" - add_widget 0 print -Pl " separator" "%B(1) Angled.%b /" " /" - add_widget 3 print -P "%B(1) Angled.%b" - add_prompt_n left_sep=$right_triangle right_sep=$left_triangle left_subsep=$right_angle right_subsep=$left_angle - add_widget 0 print - add_widget 2 - add_widget 0 print -P "%B(2) Vertical.%b" - add_prompt left_sep='' right_sep='' left_subsep=$vertical_bar right_subsep=$vertical_bar - if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then - extra+=3 - add_widget 0 print -P "%B(3) Slanted.%b" - add_prompt left_sep=$down_triangle right_sep=$up_triangle left_subsep=$slanted_bar right_subsep=$slanted_bar - extra+=4 - add_widget 0 print -P "%B(4) Round.%b" - add_prompt left_sep=$right_circle right_sep=$left_circle left_subsep=$right_arc right_subsep=$left_arc - fi - add_widget 0 print -P "(r) Restart from the beginning." - ask 12${extra}r - case $choice in - r) return 1;; - 1) - left_sep=$right_triangle - right_sep=$left_triangle - left_subsep=$right_angle - right_subsep=$left_angle - options+='angled separators' - ;; - 2) - left_sep='' - right_sep='' - left_subsep=$vertical_bar - right_subsep=$vertical_bar - options+='vertical separators' - ;; - 3) - left_sep=$down_triangle - right_sep=$up_triangle - left_subsep=$slanted_bar - right_subsep=$slanted_bar - options+='slanted separators' - ;; - 4) - left_sep=$right_circle - right_sep=$left_circle - left_subsep=$right_arc - right_subsep=$left_arc - options+='round separators' - ;; - esac - return 0 -} - -function ask_heads() { - if [[ $style != (classic|rainbow) || $POWERLEVEL9K_MODE == ascii ]]; then - return 0 - fi - local extra - add_widget 0 flowing -c "%BPrompt Heads%b" - if (( cap_diamond )); then - add_widget 0 print -Pl " head" "%B(1) Sharp.%b |" " v" - add_widget 3 print -P "%B(1) Sharp.%b" - add_prompt_n left_head=$right_triangle right_head=$left_triangle - add_widget 0 print - add_widget 2 - else - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) Flat.%b" - add_prompt left_head= right_head= - fi - add_widget 0 print -P "%B(2) Blurred.%b" - add_prompt left_head=$fade_out right_head=$fade_in - if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then - extra+=3 - add_widget 0 print -P "%B(3) Slanted.%b" - add_prompt left_head=$down_triangle right_head=$up_triangle - extra+=4 - add_widget 0 print -P "%B(4) Round.%b" - add_prompt left_head=$right_circle right_head=$left_circle - fi - add_widget 0 print -P "(r) Restart from the beginning." - ask 12${extra}r - case $choice in - r) return 1;; - 1) - if (( cap_diamond )); then - left_head=$right_triangle - right_head=$left_triangle - options+='sharp heads' - else - left_head= - right_head= - options+='flat heads' - fi - ;; - 2) - left_head=$fade_out - right_head=$fade_in - options+='blurred heads' - ;; - 3) - left_head=$down_triangle - right_head=$up_triangle - options+='slanted heads' - ;; - 4) - left_head=$right_circle - right_head=$left_circle - options+='round heads' - ;; - esac - return 0 -} - -function print_tail_marker() { - local label='(1) Flat.' - local -i n='wizard_columns - 7' - local -i m=$((n - $#label)) - print -P "${(l:$n:: :)}tail" - print -P "%B$label%b${(l:$m:: :)} |" - print -P "${(l:$n:: :)} v" -} - -function ask_tails() { - if [[ $style != (classic|rainbow) || $POWERLEVEL9K_MODE == ascii ]]; then - return 0 - fi - local extra - add_widget 0 flowing -c "%BPrompt Tails%b" - add_widget 0 print_tail_marker - add_widget 3 print -P "%B(1) Flat.%b" - add_prompt_n left_tail='' right_tail='' - add_widget 0 print - add_widget 2 - add_widget 0 print -P "%B(2) Blurred.%b" - add_prompt left_tail=$fade_in right_tail=$fade_out - if (( cap_diamond )); then - extra+=3 - add_widget 0 print -P "%B(3) Sharp.%b" - add_prompt left_tail=$left_triangle right_tail=$right_triangle - if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then - extra+=4 - add_widget 0 print -P "%B(4) Slanted.%b" - add_prompt left_tail=$up_triangle right_tail=$down_triangle - extra+=5 - add_widget 0 print -P "%B(5) Round.%b" - add_prompt left_tail=$left_circle right_tail=$right_circle - fi - fi - add_widget 0 print -P "(r) Restart from the beginning." - ask 12${extra}r - case $choice in - r) return 1;; - 1) left_tail=''; right_tail=''; options+='flat tails';; - 2) left_tail=$fade_in; right_tail=$fade_out; options+='blurred tails';; - 3) - left_tail=$left_triangle - right_tail=$right_triangle - options+='sharp tails' - ;; - 4) - left_tail=$up_triangle - right_tail=$down_triangle - options+='slanted tails' - ;; - 5) - left_tail=$left_circle - right_tail=$right_circle - options+='round tails' - ;; - esac - return 0 -} - -function ask_num_lines() { - add_widget 0 flowing -c "%BPrompt Height%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) One line.%b" - add_prompt num_lines=1 - add_widget 0 print -P "%B(2) Two lines.%b" - add_prompt num_lines=2 - add_widget 0 print -P "(r) Restart from the beginning." - ask 12r - case $choice in - r) return 1;; - 1) num_lines=1; options+='1 line';; - 2) num_lines=2; options+='2 lines';; - esac - return 0 -} - -function ask_gap_char() { - [[ $num_lines != 2 || $style == pure ]] && return - if [[ $POWERLEVEL9K_MODE == ascii ]]; then - local dot='.' - local dash='-' - else - local dot='·' - local dash='─' - fi - add_widget 0 flowing -c "%BPrompt Connection%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) Disconnected.%b" - add_prompt gap_char=" " - add_widget 0 print -P "%B(2) Dotted.%b" - add_prompt gap_char=$dot - add_widget 0 print -P "%B(3) Solid.%b" - add_prompt gap_char=$dash - add_widget 0 print -P "(r) Restart from the beginning." - ask 123r - case $choice in - r) return 1;; - 1) gap_char=" "; options+=disconnected;; - 2) gap_char=$dot; options+=dotted;; - 3) gap_char=$dash; options+=solid;; - esac - return 0 -} - -function ask_frame() { - if [[ $style != (classic|rainbow|lean*) || $num_lines != 2 || $POWERLEVEL9K_MODE == ascii ]]; then - return 0 - fi - add_widget 0 flowing -c "%BPrompt Frame%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) No frame.%b" - add_prompt left_frame=0 right_frame=0 - add_widget 0 print -P "%B(2) Left.%b" - add_prompt left_frame=1 right_frame=0 - add_widget 0 print -P "%B(3) Right.%b" - add_prompt left_frame=0 right_frame=1 - add_widget 0 print -P "%B(4) Full.%b" - add_prompt left_frame=1 right_frame=1 - add_widget 0 print -P "(r) Restart from the beginning." - ask 1234r - case $choice in - r) return 1;; - 1) left_frame=0; right_frame=0; options+='no frame';; - 2) left_frame=1; right_frame=0; options+='left frame';; - 3) left_frame=0; right_frame=1; options+='right frame';; - 4) left_frame=1; right_frame=1; options+='full frame';; - esac - return 0 -} - -function ask_empty_line() { - add_widget 0 flowing -c "%BPrompt Spacing%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(1) Compact.%b" - add_widget 0 print - add_widget 1 - add_prompt_n - add_prompt_n - add_widget 0 print - add_widget 2 - add_widget 0 print -P "%B(2) Sparse.%b" - add_widget 0 print - add_widget 1 - add_prompt_n - add_widget 0 print - add_prompt_n - add_widget 0 print - add_widget 2 - add_widget 0 print -P "(r) Restart from the beginning." - ask 12r - case $choice in - r) return 1;; - 1) empty_line=0; options+='compact';; - 2) empty_line=1; options+='sparse';; - esac - return 0 -} - -function print_instant_prompt_link() { - local link='https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt' - (( wizard_columns < $#link )) && return - print - flowing -c "$(href $link)" -} - -function ask_instant_prompt() { - if [[ $ZSH_VERSION != (5.<4->*|<6->.*) ]]; then - instant_prompt=off - options+=instant_prompt=auto-off - return 0 - fi - if (( $+functions[z4h] )); then - instant_prompt=quiet - options+=instant_prompt=auto-quiet - return - fi - add_widget 0 flowing -c "%BInstant Prompt Mode%b" - add_widget 0 print_instant_prompt_link - add_widget 1 - add_widget 0 print - add_widget 2 - add_widget 0 flowing +c -i 5 "%B(1) Verbose (recommended).%b" - add_widget 0 print - add_widget 1 - add_widget 0 flowing +c -i 5 "%B(2) Quiet.%b" Choose this if you\'ve read and understood \ - instant prompt documentation. - add_widget 0 print - add_widget 1 - add_widget 0 flowing +c -i 5 "%B(3) Off.%b" Choose this if you\'ve tried instant prompt \ - and found it incompatible with your zsh configuration files. - add_widget 0 print - add_widget 2 - add_widget 0 print -P "(r) Restart from the beginning." - ask 123r - case $choice in - r) return 1;; - 1) instant_prompt=verbose; options+=instant_prompt=verbose;; - 2) instant_prompt=quiet; options+=instant_prompt=quiet;; - 3) instant_prompt=off; options+=instant_prompt=off;; - esac - return 0 -} - -function ask_transient_prompt() { - local disable_rprompt=$((num_lines == 1)) - local p=76 - [[ $style == pure ]] && p=$pure_color[magenta] - [[ $style == lean_8colors ]] && p=2 - p="%F{$p}$prompt_char%f" - add_widget 0 flowing -c "%BEnable Transient Prompt?%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "%B(y) Yes.%b" - add_widget 0 print - add_widget 1 - add_widget 0 print -P "${(pl:$prompt_indent:: :)}$p %2Fgit%f pull" - add_widget 3 - add_widget 0 print -P "${(pl:$prompt_indent:: :)}$p %2Fgit%f branch x" - (( empty_line )) && add_widget 0 print - add_prompt_n buffer="%2Fgit%f checkout x$cursor" - add_widget 0 print - add_widget 2 - add_widget 0 print -P "%B(n) No.%b" - add_widget 0 print - add_widget 1 - add_widget 0 buffer="%2Fgit%f pull" print_prompt - add_widget 3 - (( empty_line )) && { add_widget 0 print; add_widget 3 } - add_prompt_n buffer="%2Fgit%f branch x" - (( empty_line )) && add_widget 0 print - add_prompt_n buffer="%2Fgit%f checkout x$cursor" - add_widget 0 print - add_widget 2 - add_widget 0 print -P "(r) Restart from the beginning." - ask ynr - case $choice in - r) return 1;; - y) transient_prompt=1; options+=transient_prompt;; - n) transient_prompt=0;; - esac - return 0 -} - -function ask_config_overwrite() { - config_backup= - config_backup_u=0 - if [[ ! -e $__p9k_cfg_path ]]; then - return 0 - fi - add_widget 0 flowing -c Powerlevel10k config file already exists. - add_widget 0 flowing -c "%BOverwrite" "%b%2F${__p9k_cfg_path_u//\\/\\\\}%f%B?%b" - add_widget 0 print -P "" - add_widget 0 print -P "%B(y) Yes.%b" - add_widget 0 print -P "" - add_widget 0 print -P "(r) Restart from the beginning." - ask yr - case $choice in - r) return 1;; - y) - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - local tmpdir_u='$TMPDIR' - else - local tmpdir=/tmp - local tmpdir_u=/tmp - fi - config_backup="$(mktemp $tmpdir/$__p9k_cfg_basename.XXXXXXXXXX)" || quit -c - cp $__p9k_cfg_path $config_backup || quit -c - config_backup_u=$tmpdir_u/${(q-)config_backup:t} - ;; - esac - return 0 -} - -function ask_zshrc_edit() { - zshrc_content= - zshrc_backup= - zshrc_backup_u= - zshrc_has_cfg=0 - zshrc_has_instant_prompt=0 - write_zshrc=0 - - if (( $+functions[z4h] )); then - zshrc_has_cfg=1 - zshrc_has_instant_prompt=1 - return - fi - - check_zshrc_integration || quit -c - [[ $instant_prompt == off ]] && zshrc_has_instant_prompt=1 - (( zshrc_has_cfg && zshrc_has_instant_prompt )) && return - - add_widget 0 flowing -c %BApply changes to "%b%2F${__p9k_zshrc_u//\\/\\\\}%f%B?%b" - add_widget 0 print -P "" - add_widget 1 - local modifiable=y - if [[ ! -w $__p9k_zd ]]; then - modifiable= - add_widget 0 flowing -c %3FWARNING:%f %2F${__p9k_zd_u//\\/\\\\}%f %3Fis readonly.%f - add_widget 0 print -P "" - elif [[ -e $__p9k_zshrc && ! -w $__p9k_zshrc ]]; then - local -a stat - zstat -A stat +uid -- $__p9k_zshrc || quit -c - if (( stat[1] == EUID )); then - add_widget 0 flowing -c %3FNOTE:%f %2F${__p9k_zshrc_u//\\/\\\\}%f %3Fis readonly.%f - else - modifiable= - add_widget 0 flowing -c \ - %3FWARNING:%f %2F${__p9k_zshrc_u//\\/\\\\}%f %3Fis readonly and \ - not owned by the user. Cannot modify it.%f - fi - add_widget 0 print -P "" - fi - if [[ $modifiable == y ]]; then - add_widget 0 print -P "%B(y) Yes (recommended).%b" - else - add_widget 0 print -P "%1F(y) Yes (disabled).%f" - fi - add_widget 0 print -P "" - add_widget 0 flowing +c -i 5 "%B(n) No." I know which changes to apply and will do it myself.%b - add_widget 0 print -P "" - add_widget 0 print -P "(r) Restart from the beginning." - ask ${modifiable}nr - case $choice in - r) return 1;; - n) return 0;; - y) - write_zshrc=1 - if [[ -n $zshrc_content ]]; then - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - local tmpdir_u='$TMPDIR' - else - local tmpdir=/tmp - local tmpdir_u=/tmp - fi - zshrc_backup="$(mktemp $tmpdir/.zshrc.XXXXXXXXXX)" || quit -c - cp -p $__p9k_zshrc $zshrc_backup || quit -c - local -i writable=1 - if [[ ! -w $zshrc_backup ]]; then - chmod u+w -- $zshrc_backup || quit -c - writable=0 - fi - print -r -- $zshrc_content >$zshrc_backup || quit -c - (( writable )) || chmod u-w -- $zshrc_backup || quit -c - zshrc_backup_u=$tmpdir_u/${(q-)zshrc_backup:t} - fi - ;; - esac - return 0 -} - -function generate_config() { - local base && base="$(<$__p9k_root_dir/config/p10k-${style//_/-}.zsh)" || return - local lines=("${(@f)base}") - - function sub() { - lines=("${(@)lines/#(#b)([[:space:]]#)typeset -g POWERLEVEL9K_$1=*/$match[1]typeset -g POWERLEVEL9K_$1=$2}") - } - - function uncomment() { - lines=("${(@)lines/#(#b)([[:space:]]#)\# $1( |)/$match[1]$1$match[2]$match[2]}") - } - - function rep() { - lines=("${(@)lines//$1/$2}") - } - - if [[ $style == pure ]]; then - rep "local grey=242" "local grey='$pure_color[grey]'" - rep "local red=1" "local red='$pure_color[red]'" - rep "local yellow=3" "local yellow='$pure_color[yellow]'" - rep "local blue=4" "local blue='$pure_color[blue]'" - rep "local magenta=5" "local magenta='$pure_color[magenta]'" - rep "local cyan=6" "local cyan='$pure_color[cyan]'" - rep "local white=7" "local white='$pure_color[white]'" - else - sub MODE $POWERLEVEL9K_MODE - - sub ICON_PADDING $POWERLEVEL9K_ICON_PADDING - - if [[ $POWERLEVEL9K_MODE == compatible ]]; then - sub STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION "'х'" - sub STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION "'х'" - sub STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION "'х'" - fi - - if [[ $POWERLEVEL9K_MODE == (compatible|powerline) ]]; then - uncomment 'typeset -g POWERLEVEL9K_LOCK_ICON' - sub LOCK_ICON "'∅'" - uncomment 'typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION' - sub NORDVPN_VISUAL_IDENTIFIER_EXPANSION "'nord'" - uncomment 'typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION' - sub RANGER_VISUAL_IDENTIFIER_EXPANSION "'▲'" - uncomment 'typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION' - sub KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION "'○'" - uncomment 'typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION' - sub AZURE_VISUAL_IDENTIFIER_EXPANSION "'az'" - uncomment 'typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION' - sub AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION "'eb'" - uncomment 'typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION' - sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'≡'" - fi - - if [[ $POWERLEVEL9K_MODE == (awesome-patched|awesome-fontconfig) && $cap_python == 0 ]]; then - uncomment 'typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION' - uncomment 'typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION' - uncomment 'typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION' - uncomment 'typeset -g POWERLEVEL9K_PYTHON_ICON' - sub VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'" - sub ANACONDA_VISUAL_IDENTIFIER_EXPANSION "'🐍'" - sub PYENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'" - sub PYTHON_ICON "'🐍'" - fi - - if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then - sub BATTERY_STAGES "'\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578'" - fi - - if [[ $style == (classic|rainbow) ]]; then - if [[ $style == classic ]]; then - sub BACKGROUND $bg_color[$color] - sub LEFT_SUBSEGMENT_SEPARATOR "'%$sep_color[$color]F$left_subsep'" - sub RIGHT_SUBSEGMENT_SEPARATOR "'%$sep_color[$color]F$right_subsep'" - sub VCS_LOADING_FOREGROUND $sep_color[$color] - rep '%248F' "%$prefix_color[$color]F" - else - sub LEFT_SUBSEGMENT_SEPARATOR "'$left_subsep'" - sub RIGHT_SUBSEGMENT_SEPARATOR "'$right_subsep'" - fi - sub RULER_FOREGROUND $frame_color[$color] - sub MULTILINE_FIRST_PROMPT_GAP_FOREGROUND $frame_color[$color] - sub MULTILINE_FIRST_PROMPT_PREFIX "'%$frame_color[$color]F╭─'" - sub MULTILINE_NEWLINE_PROMPT_PREFIX "'%$frame_color[$color]F├─'" - sub MULTILINE_LAST_PROMPT_PREFIX "'%$frame_color[$color]F╰─'" - sub MULTILINE_FIRST_PROMPT_SUFFIX "'%$frame_color[$color]F─╮'" - sub MULTILINE_NEWLINE_PROMPT_SUFFIX "'%$frame_color[$color]F─┤'" - sub MULTILINE_LAST_PROMPT_SUFFIX "'%$frame_color[$color]F─╯'" - sub LEFT_SEGMENT_SEPARATOR "'$left_sep'" - sub RIGHT_SEGMENT_SEPARATOR "'$right_sep'" - sub LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL "'$left_tail'" - sub LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$left_head'" - sub RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL "'$right_head'" - sub RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$right_tail'" - fi - - if [[ -n ${(j::)extra_icons} ]]; then - local branch_icon=${icons[VCS_BRANCH_ICON]// } - sub VCS_BRANCH_ICON "'$branch_icon '" - uncomment os_icon - else - uncomment 'typeset -g POWERLEVEL9K_DIR_CLASSES' - uncomment 'typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION' - uncomment 'typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION' - uncomment 'typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION' - sub VCS_VISUAL_IDENTIFIER_EXPANSION '' - sub COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION '' - sub TIME_VISUAL_IDENTIFIER_EXPANSION '' - fi - - if [[ -n ${(j::)prefixes} ]]; then - uncomment 'typeset -g POWERLEVEL9K_VCS_PREFIX' - uncomment 'typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX' - uncomment 'typeset -g POWERLEVEL9K_CONTEXT_PREFIX' - uncomment 'typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX' - uncomment 'typeset -g POWERLEVEL9K_TIME_PREFIX' - uncomment 'typeset -g POWERLEVEL9K_TOOLBOX_PREFIX' - if [[ $style == (lean|classic) ]]; then - [[ $style == classic ]] && local fg="%$prefix_color[$color]F" || local fg="%f" - sub VCS_PREFIX "'${fg}on '" - sub COMMAND_EXECUTION_TIME_PREFIX "'${fg}took '" - sub CONTEXT_PREFIX "'${fg}with '" - sub KUBECONTEXT_PREFIX "'${fg}at '" - sub TIME_PREFIX "'${fg}at '" - sub TOOLBOX_PREFIX "'${fg}in '" - fi - fi - - sub MULTILINE_FIRST_PROMPT_GAP_CHAR "'$gap_char'" - - if [[ $style == (classic|rainbow) && $num_lines == 2 ]]; then - if (( ! right_frame )); then - sub MULTILINE_FIRST_PROMPT_SUFFIX '' - sub MULTILINE_NEWLINE_PROMPT_SUFFIX '' - sub MULTILINE_LAST_PROMPT_SUFFIX '' - fi - if (( ! left_frame )); then - sub MULTILINE_FIRST_PROMPT_PREFIX '' - sub MULTILINE_NEWLINE_PROMPT_PREFIX '' - sub MULTILINE_LAST_PROMPT_PREFIX '' - sub STATUS_OK false - sub STATUS_ERROR false - fi - fi - - if [[ $style == lean* ]]; then - sub RULER_FOREGROUND $frame_color[$color] - sub MULTILINE_FIRST_PROMPT_GAP_FOREGROUND $frame_color[$color] - if (( right_frame )); then - sub MULTILINE_FIRST_PROMPT_SUFFIX "'%$frame_color[$color]F─╮'" - sub MULTILINE_NEWLINE_PROMPT_SUFFIX "'%$frame_color[$color]F─┤'" - sub MULTILINE_LAST_PROMPT_SUFFIX "'%$frame_color[$color]F─╯'" - sub RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL "' '" - fi - if (( left_frame )); then - sub MULTILINE_FIRST_PROMPT_PREFIX "'%$frame_color[$color]F╭─'" - sub MULTILINE_NEWLINE_PROMPT_PREFIX "'%$frame_color[$color]F├─'" - sub MULTILINE_LAST_PROMPT_PREFIX "'%$frame_color[$color]F╰─'" - sub LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL "' '" - fi - fi - - if [[ $style == (classic|rainbow) ]]; then - if (( num_lines == 2 && ! left_frame )); then - uncomment prompt_char - else - uncomment vi_mode - fi - fi - - if [[ $POWERLEVEL9K_MODE == ascii ]]; then - sub 'STATUS_OK_VISUAL_IDENTIFIER_EXPANSION' "'ok'" - sub 'STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION' "'ok'" - sub 'STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION' "'err'" - sub 'STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION' "" - sub 'STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION' "'err'" - sub 'BATTERY_STAGES' "('battery')" - sub 'PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION' "'>'" - sub 'PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION' "'<'" - sub 'PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION' "'V'" - sub 'PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION' "'^'" - rep "-i '⭐'" "-i '*'" - rep '…' '..' - rep '⇣' '<' - rep '⇡' '>' - rep '⇠' '<-' - rep '⇢' '->' - rep '─' '-' - fi - fi - - if (( $+pure_use_rprompt )); then - local segment - for segment in command_execution_time virtualenv context; do - rep " $segment" " tmp_$segment" - uncomment $segment - rep " tmp_$segment " " # $segment" - done - fi - - if [[ -n $time ]]; then - uncomment time - if [[ $time == $time_12h ]]; then - sub TIME_FORMAT "'%D{%I:%M:%S %p}'" - fi - fi - - if (( num_lines == 1 )); then - local -a tmp - local line - for line in "$lines[@]"; do - [[ $line == (' newline'*|*'===[ Line #'*) ]] || tmp+=$line - done - lines=("$tmp[@]") - fi - - (( empty_line )) && sub PROMPT_ADD_NEWLINE true || sub PROMPT_ADD_NEWLINE false - - sub INSTANT_PROMPT $instant_prompt - (( transient_prompt )) && sub TRANSIENT_PROMPT always - - local header=${(%):-"# Generated by Powerlevel10k configuration wizard on %D{%Y-%m-%d at %H:%M %Z}."}$'\n' - header+="# Based on romkatv/powerlevel10k/config/p10k-${style//_/-}.zsh" - if [[ $commands[sum] == ('/bin'|'/usr/bin'|'/usr/local/bin')'/sum' ]]; then - local -a sum - if sum=($(sum <<<${base//$'\r\n'/$'\n'} 2>/dev/null)) && (( $#sum == 2 )); then - header+=", checksum $sum[1]" - fi - fi - header+=$'.\n' - local line="# Wizard options: $options[1]" - local opt - for opt in $options[2,-1]; do - if (( $#line + $#opt > 85 )); then - header+=$line - header+=$',\n' - line="# $opt" - else - line+=", $opt" - fi - done - header+=$line - header+=$'.\n# Type `p10k configure` to generate another config.\n#' - - command mkdir -p -- ${__p9k_cfg_path:h} || return - - if [[ -e $__p9k_cfg_path ]]; then - unlink $__p9k_cfg_path || return - fi - print -lr -- "$header" "$lines[@]" >$__p9k_cfg_path -} - -function change_zshrc() { - (( write_zshrc )) || return 0 - - local tmp=$__p9k_zshrc.${(%):-%n}.tmp.$$ - [[ ! -e $__p9k_zshrc ]] || cp -p $__p9k_zshrc $tmp || return - - { - local -i writable=1 - if [[ -e $tmp && ! -w $tmp ]]; then - chmod u+w -- $tmp || return - writable=0 - fi - - print -n >$tmp || return - - if (( !zshrc_has_instant_prompt )); then - >>$tmp print -r -- "# Enable Powerlevel10k instant prompt. Should stay close to the top of ${(%)__p9k_zshrc_u}. -# Initialization code that may require console input (password prompts, [y/n] -# confirmations, etc.) must go above this block; everything else may go below. -if [[ -r \"\${XDG_CACHE_HOME:-\$HOME/.cache}/p10k-instant-prompt-\${(%):-%n}.zsh\" ]]; then - source \"\${XDG_CACHE_HOME:-\$HOME/.cache}/p10k-instant-prompt-\${(%):-%n}.zsh\" -fi" || return - fi - if [[ -n $zshrc_content ]]; then - (( zshrc_has_instant_prompt )) || print >>$tmp || return - >>$tmp print -r -- $zshrc_content || return - fi - if (( !zshrc_has_cfg )); then - >>$tmp print -r -- " -# To customize prompt, run \`p10k configure\` or edit ${(%)__p9k_cfg_path_u}. -[[ ! -f ${(%)__p9k_cfg_path_u} ]] || source ${(%)__p9k_cfg_path_u}" || return - fi - (( writable )) || chmod u-w -- $tmp || return - command mv -f -- $tmp $__p9k_zshrc || return - } always { - zf_rm -f -- $tmp - } - - if [[ -n $zshrc_backup_u ]]; then - print -rP "" - flowing +c See "%B${__p9k_zshrc_u//\\/\\\\}%b" changes: - print -rP " - %2Fdiff%f %B$zshrc_backup_u%b %B$__p9k_zshrc_u%b" - fi - return 0 -} - -function check_zshrc_integration() { - typeset -g zshrc_content= - typeset -gi zshrc_has_cfg=0 zshrc_has_instant_prompt=0 - [[ -e $__p9k_zshrc ]] || return 0 - zshrc_content="$(<$__p9k_zshrc)" || return - local lines=(${(f)zshrc_content}) - local f0=$__p9k_cfg_path_o - local f1=${(q)f0} - local f2=${(q-)f0} - local f3=${(qq)f0} - local f4=${(qqq)f0} - local g1=${${(q)__p9k_cfg_path_o}/#(#b)${(q)HOME}\//'~/'} - local h0='${ZDOTDIR:-~}/.p10k.zsh' - local h1='${ZDOTDIR:-$HOME}/.p10k.zsh' - local h2='"${ZDOTDIR:-$HOME}/.p10k.zsh"' - local h3='"${ZDOTDIR:-$HOME}"/.p10k.zsh' - local h4='${ZDOTDIR}/.p10k.zsh' - local h5='"${ZDOTDIR}/.p10k.zsh"' - local h6='"${ZDOTDIR}"/.p10k.zsh' - local h7='$ZDOTDIR/.p10k.zsh' - local h8='"$ZDOTDIR/.p10k.zsh"' - local h9='"$ZDOTDIR"/.p10k.zsh' - local h10='$POWERLEVEL9K_CONFIG_FILE' - local h11='"$POWERLEVEL9K_CONFIG_FILE"' - if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$g1|$h0|$h1|$h2|$h3|$h4|$h5|$h6|$h7|$h8|$h9|$h10|$h11)(|[[:space:]]*|'#'*)} ]]; then - zshrc_has_cfg=1 - fi - local pre='${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh' - if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($pre|\"$pre\")(|[[:space:]]*|'#'*)} ]]; then - zshrc_has_instant_prompt=1 - fi - return 0 -} - -() { - (( force )) && return - _p9k_can_configure -q || return 0 - local zshrc_content zshrc_has_cfg zshrc_has_instant_prompt - check_zshrc_integration 2>/dev/null || return 0 - (( zshrc_has_cfg )) || return 0 - [[ -s $__p9k_cfg_path ]] || return 0 - print -P "" - flowing \ - Powerlevel10k configuration file "($__p9k_cfg_path_u)" was not sourced. This \ - might have been caused by errors in zsh startup files, most likely in \ - $__p9k_zshrc_u. See above for any indication of such errors and fix them. If \ - there are no errors, try running Powerlevel10k configuration wizard: - print -P '' - print -P ' %2Fp10k%f %Bconfigure%b' - print -P '' - flowing \ - If you do nothing, you will see this message again when you start zsh. You can \ - suppress it by defining %BPOWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true%b in \ - $__p9k_zshrc_u. - print -P '' - return 1 -} || return - -if (( $+terminfo[smcup] && $+terminfo[rmcup] )) && echoti smcup 2>/dev/null; then - function restore_screen() { - echoti rmcup 2>/dev/null - function restore_screen() {} - } -else - function restore_screen() {} -fi - -{ # always - -if (( force )); then - _p9k_can_configure || return -else - _p9k_can_configure -q || return -fi - -zmodload zsh/terminfo || return - -if [[ $ZSH_VERSION == (5.7.<1->*|5.<8->*|<6->.*) && $COLORTERM == (24bit|truecolor) ]]; then - local -ir has_truecolor=1 -else - local -ir has_truecolor=0 -fi - -stty -echo 2>/dev/null - -while true; do - local instant_prompt=verbose zshrc_content= zshrc_backup= zshrc_backup_u= - local -i zshrc_has_cfg=0 zshrc_has_instant_prompt=0 write_zshrc=0 - local POWERLEVEL9K_MODE= POWERLEVEL9K_ICON_PADDING=moderate style= config_backup= config_backup_u= - local gap_char=' ' prompt_char='❯' down_triangle='\uE0BC' up_triangle='\uE0BA' slanted_bar='\u2571' - local left_subsep= right_subsep= left_tail= right_tail= left_head= right_head= time= - local -i num_lines=2 empty_line=0 color=2 left_frame=1 right_frame=1 transient_prompt=0 - local -i cap_diamond=0 cap_python=0 cap_debian=0 cap_lock=0 cap_arrow=0 - local -a extra_icons=('' '' '') - local -a frame_color=(244 242 240 238) - local -a color_name=(Lightest Light Dark Darkest) - local -a prefixes=('' '') - local -a options=() - if (( has_truecolor )); then - local -A pure_color=(${(kv)pure_snazzy}) - else - local -A pure_color=(${(kv)pure_original}) - fi - - unset pure_use_rprompt - - if [[ $TERM != (dumb|linux) && $langinfo[CODESET] == (utf|UTF)(-|)8 ]]; then - ask_font || continue - ask_diamond || continue - if [[ $AWESOME_GLYPHS_LOADED == 1 ]]; then - POWERLEVEL9K_MODE=awesome-mapped-fontconfig - else - ask_lock '\uF023' || continue - if (( ! cap_lock )); then - ask_lock '\uE138' "Let's try another one." || continue - if (( cap_lock )); then - if (( cap_diamond )); then - POWERLEVEL9K_MODE=awesome-patched - ask_python || continue - else - POWERLEVEL9K_MODE=flat - fi - else - if (( cap_diamond )); then - POWERLEVEL9K_MODE=powerline - else - ask_arrow || continue - (( cap_arrow )) && POWERLEVEL9K_MODE=compatible || POWERLEVEL9K_MODE=ascii - fi - fi - elif (( ! cap_diamond )); then - POWERLEVEL9K_MODE=awesome-fontconfig - else - ask_debian || continue - if (( cap_debian )); then - POWERLEVEL9K_MODE=nerdfont-complete - else - POWERLEVEL9K_MODE=awesome-fontconfig - ask_python || continue - fi - fi - fi - else - POWERLEVEL9K_MODE=ascii - fi - - if [[ $POWERLEVEL9K_MODE == powerline ]]; then - options+=powerline - elif (( cap_diamond )); then - options+="$POWERLEVEL9K_MODE + powerline" - else - options+="$POWERLEVEL9K_MODE" - fi - (( cap_python )) && options[-1]+=' + python' - if (( cap_diamond )); then - left_sep=$right_triangle - right_sep=$left_triangle - left_subsep=$right_angle - right_subsep=$left_angle - left_head=$right_triangle - right_head=$left_triangle - else - left_sep= - right_sep= - left_head= - right_head= - if [[ $POWERLEVEL9K_MODE == ascii ]]; then - left_subsep='|' - right_subsep='|' - prompt_char='>' - left_frame=0 - right_frame=0 - else - left_subsep=$vertical_bar - right_subsep=$vertical_bar - fi - fi - - _p9k_init_icons - ask_icon_padding || continue - _p9k_init_icons - - ask_style || continue - ask_charset || continue - ask_color_scheme || continue - ask_color || continue - ask_use_rprompt || continue - ask_time || continue - ask_separators || continue - ask_heads || continue - ask_tails || continue - ask_num_lines || continue - ask_gap_char || continue - ask_frame || continue - ask_ornaments_color || continue - ask_empty_line || continue - ask_extra_icons || continue - ask_prefixes || continue - ask_transient_prompt || continue - ask_instant_prompt || continue - ask_config_overwrite || continue - ask_zshrc_edit || continue - break -done - -restore_screen - -if (( !in_z4h_wizard )); then - print - - flowing +c New config: "%U${__p9k_cfg_path_u//\\/\\\\}%u." - if [[ -n $config_backup ]]; then - flowing +c Backup of the old config: "%U${config_backup_u//\\/\\\\}%u." - fi - if [[ -n $zshrc_backup ]]; then - flowing +c Backup of "%U${__p9k_zshrc_u//\\/\\\\}%u:" "%U${zshrc_backup_u//\\/\\\\}%u." - fi -fi - -generate_config || return -change_zshrc || return - -if (( !in_z4h_wizard )); then - print -rP "" - flowing +c File feature requests and bug reports at "$(href https://github.com/romkatv/powerlevel10k/issues)" - print -rP "" -fi - -success=1 - -} always { - (( success )) || quit - consume_input - stty echo 2>/dev/null - show_cursor - restore_screen -} diff --git a/.zsh/themes/powerlevel10k/internal/worker.zsh b/.zsh/themes/powerlevel10k/internal/worker.zsh deleted file mode 100644 index 269e8aa..0000000 --- a/.zsh/themes/powerlevel10k/internal/worker.zsh +++ /dev/null @@ -1,219 +0,0 @@ -# invoked in worker: _p9k_worker_main <pgid> -function _p9k_worker_main() { - mkfifo -- $_p9k__worker_file_prefix.fifo || return - echo -nE - s$_p9k_worker_pgid$'\x1e' || return - exec <$_p9k__worker_file_prefix.fifo || return - zf_rm -- $_p9k__worker_file_prefix.fifo || return - - local -i reset - local req fd - local -a ready - local _p9k_worker_request_id - local -A _p9k_worker_fds # fd => id$'\x1f'callback - local -A _p9k_worker_inflight # id => inflight count - - function _p9k_worker_reply() { - print -nr -- e${(pj:\n:)@}$'\x1e' || kill -- -$_p9k_worker_pgid - } - - # usage: _p9k_worker_async <work> <callback> - function _p9k_worker_async() { - local fd async=$1 - sysopen -r -o cloexec -u fd <(() { eval $async; } && print -n '\x1e') || return - (( ++_p9k_worker_inflight[$_p9k_worker_request_id] )) - _p9k_worker_fds[$fd]=$_p9k_worker_request_id$'\x1f'$2 - } - - trap '' PIPE - - { - while zselect -a ready 0 ${(k)_p9k_worker_fds}; do - [[ $ready[1] == -r ]] || return - for fd in ${ready:1}; do - if [[ $fd == 0 ]]; then - local buf= - [[ -t 0 ]] # https://www.zsh.org/mla/workers/2020/msg00207.html - if sysread -t 0 'buf[$#buf+1]'; then - while [[ $buf != *$'\x1e' ]]; do - sysread 'buf[$#buf+1]' || return - done - else - (( $? == 4 )) || return - fi - for req in ${(ps:\x1e:)buf}; do - _p9k_worker_request_id=${req%%$'\x1f'*} - () { eval $req[$#_p9k_worker_request_id+2,-1] } - (( $+_p9k_worker_inflight[$_p9k_worker_request_id] )) && continue - print -rn -- d$_p9k_worker_request_id$'\x1e' || return - done - else - local REPLY= - while true; do - if sysread -i $fd 'REPLY[$#REPLY+1]'; then - [[ $REPLY == *$'\x1e' ]] || continue - else - (( $? == 5 )) || return - break - fi - done - local cb=$_p9k_worker_fds[$fd] - _p9k_worker_request_id=${cb%%$'\x1f'*} - unset "_p9k_worker_fds[$fd]" - exec {fd}>&- - if [[ $REPLY == *$'\x1e' ]]; then - REPLY[-1]="" - () { eval $cb[$#_p9k_worker_request_id+2,-1] } - fi - if (( --_p9k_worker_inflight[$_p9k_worker_request_id] == 0 )); then - unset "_p9k_worker_inflight[$_p9k_worker_request_id]" - print -rn -- d$_p9k_worker_request_id$'\x1e' || return - fi - fi - done - done - } always { - kill -- -$_p9k_worker_pgid - } -} - -# invoked in master: _p9k_worker_invoke <request-id> <list> -function _p9k_worker_invoke() { - [[ -n $_p9k__worker_resp_fd ]] || return - local req=$1$'\x1f'$2$'\x1e' - if [[ -n $_p9k__worker_req_fd && $+_p9k__worker_request_map[$1] == 0 ]]; then - _p9k__worker_request_map[$1]= - print -rnu $_p9k__worker_req_fd -- $req - else - _p9k__worker_request_map[$1]=$req - fi -} - -function _p9k_worker_cleanup() { - # __p9k_intro bugs out here in some cases for some reason. - emulate -L zsh - [[ $_p9k__worker_shell_pid == $sysparams[pid] ]] && _p9k_worker_stop - return 0 -} - -function _p9k_worker_stop() { - # See comments in _p9k_worker_cleanup. - emulate -L zsh - add-zsh-hook -D zshexit _p9k_worker_cleanup - [[ -n $_p9k__worker_resp_fd ]] && zle -F $_p9k__worker_resp_fd - [[ -n $_p9k__worker_resp_fd ]] && exec {_p9k__worker_resp_fd}>&- - [[ -n $_p9k__worker_req_fd ]] && exec {_p9k__worker_req_fd}>&- - [[ -n $_p9k__worker_pid ]] && kill -- -$_p9k__worker_pid 2>/dev/null - [[ -n $_p9k__worker_file_prefix ]] && zf_rm -f -- $_p9k__worker_file_prefix.fifo - _p9k__worker_pid= - _p9k__worker_req_fd= - _p9k__worker_resp_fd= - _p9k__worker_shell_pid= - _p9k__worker_request_map=() - return 0 -} - -function _p9k_worker_receive() { - eval "$__p9k_intro" - - [[ -z $_p9k__worker_resp_fd ]] && return - - { - (( $# <= 1 )) || return - - local buf resp - - [[ -t $_p9k__worker_resp_fd ]] # https://www.zsh.org/mla/workers/2020/msg00207.html - if sysread -i $_p9k__worker_resp_fd -t 0 'buf[$#buf+1]'; then - while [[ $buf == *[^$'\x05\x1e']$'\x05'# ]]; do - sysread -i $_p9k__worker_resp_fd 'buf[$#buf+1]' || return - done - else - (( $? == 4 )) || return - fi - - local -i reset max_reset - for resp in ${(ps:\x1e:)${buf//$'\x05'}}; do - local arg=$resp[2,-1] - case $resp[1] in - d) - local req=$_p9k__worker_request_map[$arg] - if [[ -n $req ]]; then - _p9k__worker_request_map[$arg]= - print -rnu $_p9k__worker_req_fd -- $req || return - else - unset "_p9k__worker_request_map[$arg]" - fi - ;; - e) - () { eval $arg } - (( reset > max_reset )) && max_reset=reset - ;; - s) - [[ -z $_p9k__worker_req_fd ]] || return - [[ $arg == <1-> ]] || return - _p9k__worker_pid=$arg - sysopen -w -o cloexec -u _p9k__worker_req_fd $_p9k__worker_file_prefix.fifo || return - local req= - for req in $_p9k__worker_request_map; do - print -rnu $_p9k__worker_req_fd -- $req || return - done - _p9k__worker_request_map=({${(k)^_p9k__worker_request_map},''}) - ;; - *) - return 1 - ;; - esac - done - - if (( max_reset == 2 )); then - _p9k__refresh_reason=worker - _p9k_set_prompt - _p9k__refresh_reason='' - fi - (( max_reset )) && _p9k_reset_prompt - return 0 - } always { - (( $? )) && _p9k_worker_stop - } -} - -function _p9k_worker_start() { - setopt monitor || return - { - [[ -n $_p9k__worker_resp_fd ]] && return - - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - _p9k__worker_file_prefix=$tmpdir/p10k.worker.$EUID.$sysparams[pid].$EPOCHSECONDS - - sysopen -r -o cloexec -u _p9k__worker_resp_fd <( - exec 0</dev/null - if [[ -n $_POWERLEVEL9K_WORKER_LOG_LEVEL ]]; then - exec 2>$_p9k__worker_file_prefix.log - setopt xtrace - else - exec 2>/dev/null - fi - builtin cd -q / || return - zmodload zsh/zselect || return - ! { zselect -t0 || (( $? != 1 )) } || return - local _p9k_worker_pgid=$sysparams[pid] - _p9k_worker_main & - { - trap '' PIPE - while syswrite $'\x05'; do zselect -t 1000; done - zf_rm -f $_p9k__worker_file_prefix.fifo - kill -- -$_p9k_worker_pgid - } & - exec =true) || return - _p9k__worker_pid=$sysparams[procsubstpid] - zle -F $_p9k__worker_resp_fd _p9k_worker_receive - _p9k__worker_shell_pid=$sysparams[pid] - add-zsh-hook zshexit _p9k_worker_cleanup - } always { - (( $? )) && _p9k_worker_stop - } -} diff --git a/.zsh/themes/powerlevel10k/powerlevel10k.png b/.zsh/themes/powerlevel10k/powerlevel10k.png deleted file mode 100644 index e52e1f7..0000000 Binary files a/.zsh/themes/powerlevel10k/powerlevel10k.png and /dev/null differ diff --git a/.zsh/themes/powerlevel10k/powerlevel10k.zsh-theme b/.zsh/themes/powerlevel10k/powerlevel10k.zsh-theme deleted file mode 100644 index 92079d4..0000000 --- a/.zsh/themes/powerlevel10k/powerlevel10k.zsh-theme +++ /dev/null @@ -1,83 +0,0 @@ -# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 -################################################################ -# Powerlevel10k Theme -# https://github.com/romkatv/powerlevel10k -# -# Forked from Powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# Which in turn was forked from Agnoster Theme -# https://github.com/robbyrussell/oh-my-zsh/blob/74177c5320b2a1b2f8c4c695c05984b57fd7c6ea/themes/agnoster.zsh-theme -################################################################ - -# Temporarily change options. -'builtin' 'local' '-a' '__p9k_src_opts' -[[ ! -o 'aliases' ]] || __p9k_src_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || __p9k_src_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || __p9k_src_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -(( $+__p9k_root_dir )) || typeset -gr __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} -(( $+__p9k_intro )) || { - # Leading spaces before `local` are important. Otherwise Antigen will remove `local` (!!!). - # __p9k_trapint is to work around bugs in zsh: https://www.zsh.org/mla/workers/2020/msg00612.html. - # Likewise for `trap ":"` instead of the plain `trap ""`. - typeset -gr __p9k_intro_base='emulate -L zsh -o no_hist_expand -o extended_glob -o no_prompt_bang -o prompt_percent -o no_prompt_subst -o no_aliases -o no_bg_nice -o typeset_silent -o no_rematch_pcre - (( $+__p9k_trapped )) || { local -i __p9k_trapped; trap : INT; trap "trap ${(q)__p9k_trapint:--} INT" EXIT } - local -a match mbegin mend - local -i MBEGIN MEND OPTIND - local MATCH OPTARG IFS=$'\'' \t\n\0'\' - typeset -gr __p9k_intro_locale='[[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]] && _p9k_init_locale && { [[ -n $LC_ALL ]] && local LC_ALL=$__p9k_locale || local LC_CTYPE=$__p9k_locale }' - typeset -gr __p9k_intro_no_locale="${${__p9k_intro_base/ match / match reply }/ MATCH / MATCH REPLY }" - typeset -gr __p9k_intro_no_reply="$__p9k_intro_base; $__p9k_intro_locale" - typeset -gr __p9k_intro="$__p9k_intro_no_locale; $__p9k_intro_locale" -} - -zmodload zsh/langinfo - -function _p9k_init_locale() { - if (( ! $+__p9k_locale )); then - typeset -g __p9k_locale= - (( $+commands[locale] )) || return - local -a loc - loc=(${(@M)$(locale -a 2>/dev/null):#*.(utf|UTF)(-|)8}) || return - (( $#loc )) || return - typeset -g __p9k_locale=${loc[(r)(#i)C.UTF(-|)8]:-${loc[(r)(#i)en_US.UTF(-|)8]:-$loc[1]}} - fi - [[ -n $__p9k_locale ]] -} - -() { - eval "$__p9k_intro" - if (( $+__p9k_sourced )); then - (( $+functions[_p9k_setup] )) && _p9k_setup - return 0 - fi - typeset -gr __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh - if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file ]] && (( ! $+functions[_p9k_preinit] )) && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then - _p9k_preinit - fi - typeset -gr __p9k_sourced=13 - if [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]]; then - if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus ]]; then - local f - for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,internal/worker.zsh,internal/parser.zsh,gitstatus/gitstatus.plugin.zsh,gitstatus/install}; do - [[ $f.zwc -nt $f ]] && continue - zmodload -F zsh/files b:zf_mv b:zf_rm - local tmp=$f.tmp.$$.zwc - { - # `zf_mv -f src dst` fails on NTFS if `dst` is not writable, hence `zf_rm`. - zf_rm -f -- $f.zwc && zcompile -R -- $tmp $f && zf_mv -f -- $tmp $f.zwc - } always { - (( $? )) && zf_rm -f -- $tmp - } - done - fi - fi - builtin source $__p9k_root_dir/internal/p10k.zsh || true -} - -(( $+__p9k_instant_prompt_active )) && unsetopt prompt_cr prompt_sp || setopt prompt_cr prompt_sp - -(( ${#__p9k_src_opts} )) && setopt ${__p9k_src_opts[@]} -'builtin' 'unset' '__p9k_src_opts' diff --git a/.zsh/themes/powerlevel10k/powerlevel9k.zsh-theme b/.zsh/themes/powerlevel10k/powerlevel9k.zsh-theme deleted file mode 100644 index 328cd83..0000000 --- a/.zsh/themes/powerlevel10k/powerlevel9k.zsh-theme +++ /dev/null @@ -1 +0,0 @@ -'builtin' 'source' "${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}/powerlevel10k.zsh-theme" diff --git a/.zsh/themes/powerlevel10k/prompt_powerlevel10k_setup b/.zsh/themes/powerlevel10k/prompt_powerlevel10k_setup deleted file mode 100644 index 328cd83..0000000 --- a/.zsh/themes/powerlevel10k/prompt_powerlevel10k_setup +++ /dev/null @@ -1 +0,0 @@ -'builtin' 'source' "${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}/powerlevel10k.zsh-theme" diff --git a/.zsh/themes/powerlevel10k/prompt_powerlevel9k_setup b/.zsh/themes/powerlevel10k/prompt_powerlevel9k_setup deleted file mode 100644 index 328cd83..0000000 --- a/.zsh/themes/powerlevel10k/prompt_powerlevel9k_setup +++ /dev/null @@ -1 +0,0 @@ -'builtin' 'source' "${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}/powerlevel10k.zsh-theme" diff --git a/.zsh/themes/spaceship-prompt/.editorconfig b/.zsh/themes/spaceship-prompt/.editorconfig deleted file mode 100644 index 54fd28d..0000000 --- a/.zsh/themes/spaceship-prompt/.editorconfig +++ /dev/null @@ -1,18 +0,0 @@ -# EditorConfig -# http://EditorConfig.org - -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[.gitmodules] -indent_style = tab - -[Makefile] -indent_style = tab diff --git a/.zsh/themes/spaceship-prompt/.gitattributes b/.zsh/themes/spaceship-prompt/.gitattributes deleted file mode 100644 index b3c6648..0000000 --- a/.zsh/themes/spaceship-prompt/.gitattributes +++ /dev/null @@ -1,7 +0,0 @@ -# Set the default behavior, in case people don't have core.autocrlf set. -* text=auto - -# These files should always checkout with LF line endings, even on windows. -*.zsh-theme text eol=lf -*.zsh text eol=lf -*.sh text eol=lf \ No newline at end of file diff --git a/.zsh/themes/spaceship-prompt/.github/FUNDING.yml b/.zsh/themes/spaceship-prompt/.github/FUNDING.yml deleted file mode 100644 index 13e12e7..0000000 --- a/.zsh/themes/spaceship-prompt/.github/FUNDING.yml +++ /dev/null @@ -1,6 +0,0 @@ -# You can add one username per supported platform and one custom link -github: denysdovhan -patreon: denysdovhan -open_collective: spaceship-prompt -ko_fi: # Replace with your Ko-fi username -custom: [buymeacoffee.com/denysdovhan] diff --git a/.zsh/themes/spaceship-prompt/.github/ISSUE_TEMPLATE/bug_report.yml b/.zsh/themes/spaceship-prompt/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 9cadbcf..0000000 --- a/.zsh/themes/spaceship-prompt/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: 🐛 Bug Report -description: If something isn't working as expected 🤔. -labels: - - bug -body: - - type: markdown - attributes: - value: | - ## Thanks for reporting! - - You can run `spaceship bug-report` in your terminal to automatically pre-fill and open this form. - - Please search to see if an issue already exists for the bug you encountered. - Check [FAQ](https://spaceship-prompt.sh/faq) page for commonly encountered problems. - - - type: textarea - attributes: - label: The problem - description: > - Provide a clear and concise description of what the problem is. - - Tell us what you were trying to do and what happened. - validations: - required: true - - - type: textarea - attributes: - label: Relevant Zsh configuration - description: Please, provide the part of your `~/.zshrc` file related to Spaceship. - render: zsh - - - type: markdown - attributes: - value: > - ## Environment - - - type: input - id: spaceship-version - validations: - required: true - attributes: - label: What is version of Spaceship are you using? - placeholder: vX.X.X - description: > - Run `echo $SPACESHIP_VERSION` to get the version of Spaceship you are using. - - - type: input - id: zsh-version - validations: - required: true - attributes: - label: What is version of Zsh are you using? - placeholder: zsh X.X (architecture) - description: > - Run `zsh --version` to get the version of Spaceship you are using. - - - type: input - id: os-system - validations: - required: true - attributes: - label: What operation system are you running? - placeholder: macOS, Linux, Windows, etc. - description: > - Please, type information about your operating system. - - - type: input - id: zsh-framework - attributes: - label: Do you use any Zsh framework or plugin manager? - placeholder: oh-my-zsh/prezto/antigen/zplug/zgen - description: > - Otherwise leave blank. - - - type: input - id: terminal - attributes: - label: Which terminal emulator do you use? - placeholder: iTerm/Hyper/Terminator/etc - description: > - If known, otherwise leave blank. - - - type: textarea - attributes: - label: Additional information - description: > - If you have any additional information for us, use the field below. - - Provide logs, suggestions, possible solutions, fixes or anything you consider useful. - - Please note, you can attach screenshots or screen recordings here, by - dragging and dropping files in the field below. - render: markdown diff --git a/.zsh/themes/spaceship-prompt/.github/ISSUE_TEMPLATE/config.yml b/.zsh/themes/spaceship-prompt/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index adde338..0000000 --- a/.zsh/themes/spaceship-prompt/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,8 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: 🙏 Support Question - url: https://github.com/spaceship-prompt/spaceship-prompt/discussions/new?category=q-a - about: Please ask and answer questions here. - - name: 👾 Join Discord - url: https://discord.gg/Q3SaC2Bt3n - about: Join our discord server to be in touch with the community. Get help, discuss new features, have fun. diff --git a/.zsh/themes/spaceship-prompt/.github/ISSUE_TEMPLATE/feature_request.yml b/.zsh/themes/spaceship-prompt/.github/ISSUE_TEMPLATE/feature_request.yml deleted file mode 100644 index a610563..0000000 --- a/.zsh/themes/spaceship-prompt/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: 🚀 Feature Request -description: I have a suggestion (and might want to implement myself 🙂)! -labels: - - proposal -body: - - type: markdown - attributes: - value: | - ## Thanks for suggesting a feature! - - We will gradly consider your suggestion. Please, also consider submitting a pull-request. - - ### Suggesting a new section? - - Help us validate your suggestion. - Visit our [contributing guidelines](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/CONTRIBUTING.md#sections) and make sure your section: - - * Will not clutter the prompt - * Will not slow down the prompt - * Worth to be aware of on every command - - - type: textarea - attributes: - label: The problem - description: > - Is your feature request related to a problem? Please describe. - Provide a clear and concise description of what the problem is. - - Tell us what you were trying to do and what happened. - - - type: textarea - validations: - required: true - attributes: - label: Describe the solution you'd like - description: > - A clear and concise description of what you want to happen. Add any considered drawbacks. - - - type: textarea - attributes: - label: Describe alternatives you've considered - description: > - A clear and concise description of any alternative solutions or features you've considered. - - - type: textarea - attributes: - label: Documentation and adoption - description: > - If you can, explain how users will be able to use this and possibly write out a version the docs. - - Please note, you can attach screenshots or screen recordings here, by - dragging and dropping files in the field below. - render: markdown diff --git a/.zsh/themes/spaceship-prompt/.github/PULL_REQUEST_TEMPLATE.md b/.zsh/themes/spaceship-prompt/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6dc3a86..0000000 --- a/.zsh/themes/spaceship-prompt/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,13 +0,0 @@ -<!-- Thanks for your pull-request! - -Please, make sure you've read `CONTRIBUTING.md` before submitting this PR. --> - -#### Description - -<!-- Describe your pull-request, what was changed and why… --> - -#### Screenshot - -<!-- Please, attach a screenshot, if possible. - -![screenshot](url) --> diff --git a/.zsh/themes/spaceship-prompt/.github/dependabot.yml b/.zsh/themes/spaceship-prompt/.github/dependabot.yml deleted file mode 100644 index 9450b9c..0000000 --- a/.zsh/themes/spaceship-prompt/.github/dependabot.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "gitsubmodule" - directory: "/" - schedule: - interval: "daily" - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - - - package-ecosystem: "npm" - directory: "/" - schedule: - interval: "daily" diff --git a/.zsh/themes/spaceship-prompt/.github/workflows/deps.yaml b/.zsh/themes/spaceship-prompt/.github/workflows/deps.yaml deleted file mode 100644 index 0217dc8..0000000 --- a/.zsh/themes/spaceship-prompt/.github/workflows/deps.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: deps -on: - schedule: - - cron: '0 10 * * 1' # At 10:00, every Monday - -jobs: - zsh-async: - name: Update zsh-async - runs-on: ubuntu-latest - steps: - - name: ⬇️ Checkout Repo - uses: actions/checkout@v3 - - - name: 👀 Check zsh-async Releases - id: zsh-async - run: | - echo ::set-output name=release_tag::$(curl -sL https://api.github.com/repos/mafredri/zsh-async/releases/latest | jq -r ".tag_name") - echo ::set-output name=current_tag::$(grep '# version:' ./lib/async.zsh | cut -d':' -f2 | xargs) - - - name: 📦 Update zsh-async - if: steps.zsh-async.outputs.current_tag != steps.zsh-async.outputs.release_tag - env: - RELEASE_TAG: ${{ steps.zsh-async.outputs.release_tag }} - run: | - # Download the release - curl -sL -o $RELEASE_TAG https://api.github.com/repos/mafredri/zsh-async/tarball/$RELEASE_TAG - - # Extract a async.zsh file from the release - tar -xzvf $RELEASE_TAG --strip-components=1 $(tar -tzf $RELEASE_TAG | head -1 | cut -f1 -d"/")/async.zsh - - # Remove archive - rm $RELEASE_TAG - - - name: ↩️ Create Pull Request - uses: peter-evans/create-pull-request@v4 - with: - commit-message: | - build(zsh-async): Update zsh-async to ${{ steps.zsh-async.outputs.release_tag }} - title: | - build(zsh-async): Update zsh-async to ${{ steps.zsh-async.outputs.release_tag }} - body: | - Updates [zsh-async][1] to ${{ steps.zsh-async.outputs.release_tag }} - - [1]: https://github.com/mafredri/zsh-async - labels: async, dependencies - branch: zsh-async-bump - delete-branch: true diff --git a/.zsh/themes/spaceship-prompt/.github/workflows/docker.yml b/.zsh/themes/spaceship-prompt/.github/workflows/docker.yml deleted file mode 100644 index 5b83df4..0000000 --- a/.zsh/themes/spaceship-prompt/.github/workflows/docker.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: docker -on: - release: - types: - - published - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - name: Build Docker Image - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: ⬇️ Checkout Repo - uses: actions/checkout@v3 - with: - submodules: true - - - name: 🔑 Login to Docker Hub - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: 🏷 Extract Metadata for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: 🐳 Build and push Docker images - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.zsh/themes/spaceship-prompt/.github/workflows/homebrew.yml b/.zsh/themes/spaceship-prompt/.github/workflows/homebrew.yml deleted file mode 100644 index 31d0764..0000000 --- a/.zsh/themes/spaceship-prompt/.github/workflows/homebrew.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: homebrew -on: - release: - types: - - published - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - main: - name: Homebrew Bump - runs-on: ubuntu-latest - steps: - - name: 🍺 Bump Homebrew Formula - uses: mislav/bump-homebrew-formula-action@v2.1 - with: - formula-name: spaceship - env: - COMMITTER_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.zsh/themes/spaceship-prompt/.github/workflows/release.yml b/.zsh/themes/spaceship-prompt/.github/workflows/release.yml deleted file mode 100644 index 71738ae..0000000 --- a/.zsh/themes/spaceship-prompt/.github/workflows/release.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: release -on: - schedule: - - cron: '0 12 * * 3' # At 12:00, every Wednesday - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - release: - name: Release - if: github.repository_owner == 'spaceship-prompt' - runs-on: ubuntu-latest - steps: - - name: ⬇️ Checkout Repo - uses: actions/checkout@v3 - with: - persist-credentials: false - submodules: true - - - name: 🚀 Release - uses: cycjimmy/semantic-release-action@v3 - id: semantic - with: - extra_plugins: | - @google/semantic-release-replace-plugin - @semantic-release/changelog - @semantic-release/git - semantic-release-license - env: - # Using PAT here, because published release should trigger a workflow - # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.zsh/themes/spaceship-prompt/.github/workflows/validate.yaml b/.zsh/themes/spaceship-prompt/.github/workflows/validate.yaml deleted file mode 100644 index 4032d2e..0000000 --- a/.zsh/themes/spaceship-prompt/.github/workflows/validate.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: validate -on: - push: - branches: - - master - - +([0-9])?(.{+([0-9]),x}).x - - next - - beta - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - tests: - name: Tests - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - steps: - - name: ⬇️ Checkout Repo - uses: actions/checkout@v3 - with: - submodules: true - - - name: 💤 Install Zsh - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install zsh - - - name: 🖨 Print Zsh Vesion - run: zsh --version - - - name: 🧪 Run Tests - run: make tests - - # This job does nothing and is only used for the branch protection - # See: https://github.com/re-actors/alls-green - check: - name: All green - if: always() - needs: - - tests - runs-on: ubuntu-latest - steps: - - name: Decide whether the needed jobs succeeded or failed - uses: re-actors/alls-green@release/v1 - with: - jobs: ${{ toJSON(needs) }} diff --git a/.zsh/themes/spaceship-prompt/.gitignore b/.zsh/themes/spaceship-prompt/.gitignore deleted file mode 100644 index e123fa7..0000000 --- a/.zsh/themes/spaceship-prompt/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules -site - -# Lockfiles -package-lock.json -yarn.lock - -# Compiled zsh files -*.zwc diff --git a/.zsh/themes/spaceship-prompt/.gitmodules b/.zsh/themes/spaceship-prompt/.gitmodules deleted file mode 100644 index 6dc5bf5..0000000 --- a/.zsh/themes/spaceship-prompt/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "tests/shunit2"] - path = tests/shunit2 - url = https://github.com/kward/shunit2.git - update = merge diff --git a/.zsh/themes/spaceship-prompt/.npmrc b/.zsh/themes/spaceship-prompt/.npmrc deleted file mode 100644 index 43c97e7..0000000 --- a/.zsh/themes/spaceship-prompt/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/.zsh/themes/spaceship-prompt/.releaserc.json b/.zsh/themes/spaceship-prompt/.releaserc.json deleted file mode 100644 index 88037ef..0000000 --- a/.zsh/themes/spaceship-prompt/.releaserc.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "plugins": [ - "@semantic-release/commit-analyzer", - "@semantic-release/release-notes-generator", - "@semantic-release/npm", - "@semantic-release/github", - "@semantic-release/changelog", - ["semantic-release-license", { - "license": { - "path": "LICENSE.md" - } - }], - ["@google/semantic-release-replace-plugin", { - "replacements": [{ - "files": ["spaceship.zsh"], - "from": "export SPACESHIP_VERSION='.*'", - "to": "export SPACESHIP_VERSION='${nextRelease.version}'", - "results": [ - { - "file": "spaceship.zsh", - "hasChanged": true, - "numMatches": 1, - "numReplacements": 1 - } - ], - "countMatches": true - }] - }], - ["@semantic-release/git", { - "assets": ["package.json", "spaceship.zsh","CHANGELOG.md", "LICENSE.md"] - }] - ] -} diff --git a/.zsh/themes/spaceship-prompt/CHANGELOG.md b/.zsh/themes/spaceship-prompt/CHANGELOG.md deleted file mode 100644 index 6b96ea9..0000000 --- a/.zsh/themes/spaceship-prompt/CHANGELOG.md +++ /dev/null @@ -1,523 +0,0 @@ -## [4.10.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.10.0...v4.10.1) (2022-11-12) - - -### Bug Fixes - -* **section:** Fix newline characters in section suffix. ([e585e9d](https://github.com/spaceship-prompt/spaceship-prompt/commit/e585e9d0954efcd241ee8cbc6efcd7aff4fae56c)), closes [#1267](https://github.com/spaceship-prompt/spaceship-prompt/issues/1267) - -# [4.10.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.9.1...v4.10.0) (2022-11-10) - - -### Bug Fixes - -* **java:** Added support gradle kotlin dsl ([#1289](https://github.com/spaceship-prompt/spaceship-prompt/issues/1289)) ([5b186d6](https://github.com/spaceship-prompt/spaceship-prompt/commit/5b186d68b3aae757ad6b9c0e660619d24c2f19c9)) -* **java:** detect empty java version ([178ffc9](https://github.com/spaceship-prompt/spaceship-prompt/commit/178ffc94455270a476c19f3c5149b1c8fc7bd4fd)) -* **sudo:** Sudo should be hidden by default ([36a5852](https://github.com/spaceship-prompt/spaceship-prompt/commit/36a585267f67c3466abaaeaec30148720b45cdfd)) -* **upsearch:** find complains about -name. Fix [#1286](https://github.com/spaceship-prompt/spaceship-prompt/issues/1286) ([5e8b7c0](https://github.com/spaceship-prompt/spaceship-prompt/commit/5e8b7c0a575ee2d333596c1ed933726bd838c591)) -* **upsearch:** Prevent globs from expanding to early ([b10e093](https://github.com/spaceship-prompt/spaceship-prompt/commit/b10e093cad17691b8d32fca80ecbd8633cfc02bc)) - - -### Features - -* **gnu_screen:** Add Screen session section to prompt ([#1062](https://github.com/spaceship-prompt/spaceship-prompt/issues/1062)) ([f996381](https://github.com/spaceship-prompt/spaceship-prompt/commit/f996381929a37c5f6c72f032b92c2287e083de74)) -* **sudo:** Add sudo section ([49ce387](https://github.com/spaceship-prompt/spaceship-prompt/commit/49ce387ad2e38a321ae6e3365bb79d549258786a)) -* **vlang:** Add V Section ([#877](https://github.com/spaceship-prompt/spaceship-prompt/issues/877)) ([9399e09](https://github.com/spaceship-prompt/spaceship-prompt/commit/9399e099269fb3376d8b6d4f0a4bc819068f5cdc)) - -## [4.9.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.9.0...v4.9.1) (2022-11-09) - - -### Bug Fixes - -* **upsearch:** find warning for maxdepth ([8f961b6](https://github.com/spaceship-prompt/spaceship-prompt/commit/8f961b609904f979f309377da6bccde105b21534)) - -# [4.9.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.8.0...v4.9.0) (2022-11-09) - - -### Features - -* **ansible:** Add Ansible section ([#1283](https://github.com/spaceship-prompt/spaceship-prompt/issues/1283)) ([30c7e6c](https://github.com/spaceship-prompt/spaceship-prompt/commit/30c7e6c53d3a25c673b1599bbf7f0fdf2f71c16e)) -* **docker_compose:** Add docker_compose section ([#1282](https://github.com/spaceship-prompt/spaceship-prompt/issues/1282)) ([f883f31](https://github.com/spaceship-prompt/spaceship-prompt/commit/f883f3115ce225ed52664706dbb3c38a0a7cdecb)) -* **haskell:** Add Cabal support ([b253370](https://github.com/spaceship-prompt/spaceship-prompt/commit/b253370edd35b144cbfcfcdecac6cb6d8ce0f032)) -* **pulumi:** Add pulumi ([#834](https://github.com/spaceship-prompt/spaceship-prompt/issues/834)) ([1ab9162](https://github.com/spaceship-prompt/spaceship-prompt/commit/1ab9162f84ad54e109047ed14f900d53db8432bd)) - -# [4.8.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.7.0...v4.8.0) (2022-11-03) - - -### Bug Fixes - -* detect root via version variable ([#1280](https://github.com/spaceship-prompt/spaceship-prompt/issues/1280)) ([111c6f1](https://github.com/spaceship-prompt/spaceship-prompt/commit/111c6f160c4376001d5469f8e8771ee89ea4158a)), closes [#1140](https://github.com/spaceship-prompt/spaceship-prompt/issues/1140) [#1140](https://github.com/spaceship-prompt/spaceship-prompt/issues/1140) - - -### Features - -* **char:** Add different symbol according to returned value ([#673](https://github.com/spaceship-prompt/spaceship-prompt/issues/673)) ([ac31311](https://github.com/spaceship-prompt/spaceship-prompt/commit/ac313114c3da78d4ceb2b9b6a35822f764880e37)), closes [#1109](https://github.com/spaceship-prompt/spaceship-prompt/issues/1109) [#1273](https://github.com/spaceship-prompt/spaceship-prompt/issues/1273) [#1248](https://github.com/spaceship-prompt/spaceship-prompt/issues/1248) [#1278](https://github.com/spaceship-prompt/spaceship-prompt/issues/1278) [#1262](https://github.com/spaceship-prompt/spaceship-prompt/issues/1262) [#1275](https://github.com/spaceship-prompt/spaceship-prompt/issues/1275) [#1135](https://github.com/spaceship-prompt/spaceship-prompt/issues/1135) [#1269](https://github.com/spaceship-prompt/spaceship-prompt/issues/1269) - -# [4.7.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.6.1...v4.7.0) (2022-11-02) - - -### Bug Fixes - -* add shebangs for every file in the core ([f74df3f](https://github.com/spaceship-prompt/spaceship-prompt/commit/f74df3f6d7bdddeb0b39917a4a5057308e58070b)) -* **docker:** recognize docker in .devcontainer folder (for vscode) ([#1109](https://github.com/spaceship-prompt/spaceship-prompt/issues/1109)) ([a6a8e7d](https://github.com/spaceship-prompt/spaceship-prompt/commit/a6a8e7d4b20674973b4ac8d3084b7c31589a9b92)) - - -### Features - -* **java:** add support for ant ([#1273](https://github.com/spaceship-prompt/spaceship-prompt/issues/1273)) ([ec7abcd](https://github.com/spaceship-prompt/spaceship-prompt/commit/ec7abcd41e2c430079bf9ba9bac62f690bd7de35)) -* **nix_shell:** Added Nix Shell section ([#1248](https://github.com/spaceship-prompt/spaceship-prompt/issues/1248)) ([b6760b8](https://github.com/spaceship-prompt/spaceship-prompt/commit/b6760b82dfa3ffba1afb828395a1c66da10f0d9a)) -* **ocaml:** Add OCaml section ([#1278](https://github.com/spaceship-prompt/spaceship-prompt/issues/1278)) ([98fb3ee](https://github.com/spaceship-prompt/spaceship-prompt/commit/98fb3ee42922e3aa7898d160ea6c2f55a48981ca)) -* **package:** add Dart to the package section ([#1262](https://github.com/spaceship-prompt/spaceship-prompt/issues/1262)) ([d1668e2](https://github.com/spaceship-prompt/spaceship-prompt/commit/d1668e25a219278f3960b4e1ead4838f8598edd9)) -* **package:** Support pyproject.toml for package section ([#1275](https://github.com/spaceship-prompt/spaceship-prompt/issues/1275)) ([8543506](https://github.com/spaceship-prompt/spaceship-prompt/commit/8543506c4a1895a464121742245935e8867fd217)) -* **perl:** Adding perl section ([#1135](https://github.com/spaceship-prompt/spaceship-prompt/issues/1135)) ([d3c2bf6](https://github.com/spaceship-prompt/spaceship-prompt/commit/d3c2bf6b5fb2e23e40f8a86e1f5fd9da4f9bc321)) -* **scala:** Add new Scala section ([#1269](https://github.com/spaceship-prompt/spaceship-prompt/issues/1269)) ([fffea87](https://github.com/spaceship-prompt/spaceship-prompt/commit/fffea87373c7afbb48c4e2ae4f38ba957eeabf60)) - -## [4.6.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.6.0...v4.6.1) (2022-10-14) - - -### Bug Fixes - -* **java:** fix version retrieval when JAVA_TOOL_OPTIONS exist in environment ([#1191](https://github.com/spaceship-prompt/spaceship-prompt/issues/1191)) ([2c3b7df](https://github.com/spaceship-prompt/spaceship-prompt/commit/2c3b7df301fb3e54cc885dbaf9cd987934b7a276)) -* **node:** Add better detection for node context ([#1263](https://github.com/spaceship-prompt/spaceship-prompt/issues/1263)) ([7443d04](https://github.com/spaceship-prompt/spaceship-prompt/commit/7443d046c1f3002b47b242518b322dba4a64d528)) - -# [4.6.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.5.1...v4.6.0) (2022-10-07) - - -### Bug Fixes - -* locale dependent test ([#1253](https://github.com/spaceship-prompt/spaceship-prompt/issues/1253)) ([7477dfb](https://github.com/spaceship-prompt/spaceship-prompt/commit/7477dfb601b7fa41975406c53a4e3969899f0471)) -* problem async section not updating ([b72b54a](https://github.com/spaceship-prompt/spaceship-prompt/commit/b72b54ac2ab2babb829ab5d39565961a8591379e)) - - -### Features - -* add Dart section ([#1249](https://github.com/spaceship-prompt/spaceship-prompt/issues/1249)) ([f403f2f](https://github.com/spaceship-prompt/spaceship-prompt/commit/f403f2f3f499ee5abb8d8d6b1dac30c5bd8412f1)) -* add Lua section ([#1254](https://github.com/spaceship-prompt/spaceship-prompt/issues/1254)) ([7a3a2e9](https://github.com/spaceship-prompt/spaceship-prompt/commit/7a3a2e94657c90c66c20f7d1627625e851ae9ad6)) - -## [4.5.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.5.0...v4.5.1) (2022-09-30) - - -### Bug Fixes - -* **kubectl:** Avoids checking kubectl server version if no context is loaded, stopping potential hangs ([#1246](https://github.com/spaceship-prompt/spaceship-prompt/issues/1246)) ([44819b0](https://github.com/spaceship-prompt/spaceship-prompt/commit/44819b09c3017d0fb42bc22bdcbd05f847b2d915)) -* prepend spaceship root folder to spaceship precompile path ([#1244](https://github.com/spaceship-prompt/spaceship-prompt/issues/1244)) ([6c4623f](https://github.com/spaceship-prompt/spaceship-prompt/commit/6c4623fe9f31ac7b16fb7ebeffaa23b123220ef9)) -* upsearch was exiting when the first file is not found ([#1239](https://github.com/spaceship-prompt/spaceship-prompt/issues/1239)) ([dcfd690](https://github.com/spaceship-prompt/spaceship-prompt/commit/dcfd690f7b7607d05d160b084eb193460e9edf81)) - -# [4.5.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.4.0...v4.5.0) (2022-09-23) - - -### Bug Fixes - -* **crystal:** Include Crystal in order ([d215797](https://github.com/spaceship-prompt/spaceship-prompt/commit/d215797efc63e081cc6516aac6974a1ece6b255a)) -* fix grep unknown option: --color ([#1206](https://github.com/spaceship-prompt/spaceship-prompt/issues/1206)) ([8a16414](https://github.com/spaceship-prompt/spaceship-prompt/commit/8a16414d78a41e0e11574c55e323bef09835a77b)), closes [#1066](https://github.com/spaceship-prompt/spaceship-prompt/issues/1066) - - -### Features - -* **crystal:** Add Crystal section for 4.x ([c72c6c9](https://github.com/spaceship-prompt/spaceship-prompt/commit/c72c6c94f74b0ab1e110c775cfb8ec655b90da0e)) -* **deno:** Add Deno section ([c43f8c5](https://github.com/spaceship-prompt/spaceship-prompt/commit/c43f8c5e4e3886f0ba612c1b347591bcc2b00880)) - -## [4.4.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.4.0...v4.4.1) (2022-09-21) - - -### Bug Fixes - -* fix grep unknown option: --color ([#1206](https://github.com/spaceship-prompt/spaceship-prompt/issues/1206)) ([540a17a](https://github.com/spaceship-prompt/spaceship-prompt/commit/540a17a37a2199a3faa4987564a6485b63582fef)), closes [#1066](https://github.com/spaceship-prompt/spaceship-prompt/issues/1066) - -# [4.4.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.3.3...v4.4.0) (2022-09-21) - - -### Features - -* make package section to support maven and gradle ([#1209](https://github.com/spaceship-prompt/spaceship-prompt/issues/1209)) ([c8b6ce7](https://github.com/spaceship-prompt/spaceship-prompt/commit/c8b6ce7ade1a3176353d6ba46faa37db7e05e709)) - -## [4.3.3](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.3.2...v4.3.3) (2022-09-21) - - -### Bug Fixes - -* attempt to fix [#1187](https://github.com/spaceship-prompt/spaceship-prompt/issues/1187) ([9a5d7be](https://github.com/spaceship-prompt/spaceship-prompt/commit/9a5d7beb7dd51b8290b573dbdef4f6ecc908d938)) - -## [4.3.2](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.3.1...v4.3.2) (2022-09-20) - - -### Bug Fixes - -* mark spaceship libs as global ([e0a0926](https://github.com/spaceship-prompt/spaceship-prompt/commit/e0a09267dc61119738da42862f0828f869e248f5)) - -## [4.3.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.3.0...v4.3.1) (2022-09-19) - - -### Bug Fixes - -* Delete the redundant space for kubectl symbol (iTerm2) ([#1205](https://github.com/spaceship-prompt/spaceship-prompt/issues/1205)) ([8ddbc81](https://github.com/spaceship-prompt/spaceship-prompt/commit/8ddbc8115c714ee82c49101690f5effd45f3a01a)) - -# [4.3.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.2.6...v4.3.0) (2022-09-16) - - -### Features - -* fix package section file path ([71f527b](https://github.com/spaceship-prompt/spaceship-prompt/commit/71f527b68c5464f1283dd878d6481358d67c9741)) - -## [4.2.6](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.2.5...v4.2.6) (2022-09-08) - - -### Bug Fixes - -* **documentation:** use home variable instead of tilde ([#1189](https://github.com/spaceship-prompt/spaceship-prompt/issues/1189)) ([01e153e](https://github.com/spaceship-prompt/spaceship-prompt/commit/01e153efa56bc7c599fa1711d0291397411a002a)) - -## [4.2.5](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.2.4...v4.2.5) (2022-09-05) - - -### Bug Fixes - -* **npm:** Include async into npm package ([e9ff5af](https://github.com/spaceship-prompt/spaceship-prompt/commit/e9ff5af40f7ef4e813677a4d8ce83e3647bde159)) - -## [4.2.4](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.2.3...v4.2.4) (2022-09-05) - - -### Bug Fixes - -* **config:** fix wrong path for spaceship config ([cf4b55e](https://github.com/spaceship-prompt/spaceship-prompt/commit/cf4b55e34f2140f83983cc112a175f03cb0e2507)), closes [#1184](https://github.com/spaceship-prompt/spaceship-prompt/issues/1184) - -## [4.2.3](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.2.2...v4.2.3) (2022-09-05) - - -### Bug Fixes - -* exec_time doc regarding time threshold trigger ([#1183](https://github.com/spaceship-prompt/spaceship-prompt/issues/1183)) ([ffd027b](https://github.com/spaceship-prompt/spaceship-prompt/commit/ffd027b1e6a697c532b40ff8da1b429a371f306a)) - -## [4.2.2](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.2.1...v4.2.2) (2022-09-05) - - -### Bug Fixes - -* **julia:** Better detection for Julia projects ([b91ae3d](https://github.com/spaceship-prompt/spaceship-prompt/commit/b91ae3d0e5006260445c8a62706a3d79f453660d)), closes [#678](https://github.com/spaceship-prompt/spaceship-prompt/issues/678) - -## [4.2.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.2.0...v4.2.1) (2022-09-05) - - -### Bug Fixes - -* change the declaration of readonly variable to typeset ([f80bc28](https://github.com/spaceship-prompt/spaceship-prompt/commit/f80bc2813977f183d8c39ac1694bc1675d808589)), closes [#1175](https://github.com/spaceship-prompt/spaceship-prompt/issues/1175) - -# [4.2.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.1.0...v4.2.0) (2022-09-02) - - -### Features - -* Add ruby interpreter in datafile util ([005f9fa](https://github.com/spaceship-prompt/spaceship-prompt/commit/005f9fa6191dc94d29cb6db3bd860b6b05b59ef9)) - -# [4.1.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.0.0...v4.1.0) (2022-09-02) - - -### Features - -* **bun:** Add Bun section ([83ce0ee](https://github.com/spaceship-prompt/spaceship-prompt/commit/83ce0ee893757aee1c41b11c5433849a4c9de61d)) - -# [4.0.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.16.7...v4.0.0) (2022-09-01) - - -### Bug Fixes - -* add permissions to scripts ([7c3e427](https://github.com/spaceship-prompt/spaceship-prompt/commit/7c3e42727531ff612588722c509da643566f57fd)) -* add x permissions to files ([9a34149](https://github.com/spaceship-prompt/spaceship-prompt/commit/9a341498bb6d31bf6d179121adbe781972fcde26)) -* **async:** remove obsolete runtime variables ([2128ab0](https://github.com/spaceship-prompt/spaceship-prompt/commit/2128ab0046080d633c29a69f86322ca4ca9bed90)) -* cherry pick [#1089](https://github.com/spaceship-prompt/spaceship-prompt/issues/1089) ([52448c1](https://github.com/spaceship-prompt/spaceship-prompt/commit/52448c121f7d3602e2e046ae674b70c5a8bbdafa)) -* **cli:** Add missing commands in help message ([c2eb3e3](https://github.com/spaceship-prompt/spaceship-prompt/commit/c2eb3e35e8088c014cc0ed04aaab8133afaa3dd6)) -* compdef only when compdef is available ([c309af6](https://github.com/spaceship-prompt/spaceship-prompt/commit/c309af62cbb8411583228a179ccb37d8329d2af6)) -* **docker:** add additional utils inside docker image ([8813eb0](https://github.com/spaceship-prompt/spaceship-prompt/commit/8813eb0b691d1ccab1042c93edffc1c43764a0b5)) -* fix command-line completion leving one letter on the beginning of prompt ([6a4abd5](https://github.com/spaceship-prompt/spaceship-prompt/commit/6a4abd5c3489ef3a1f1387673bafdb2ab0298887)), closes [#1064](https://github.com/spaceship-prompt/spaceship-prompt/issues/1064) -* **git:** Add explicit variable for async rendering ([cfa95e6](https://github.com/spaceship-prompt/spaceship-prompt/commit/cfa95e6c80ee9d5d9dfa486daf892c1021278140)) -* **git:** fix ahead/behind indicators ([a067c4d](https://github.com/spaceship-prompt/spaceship-prompt/commit/a067c4df0b663410f7e617e9a2240393f9219095)) -* **git:** Fix typo in a section signature ([f8ed612](https://github.com/spaceship-prompt/spaceship-prompt/commit/f8ed612d8b5328d934a86c5664a745e9fbc0628d)) -* **hg:** Add options for async rendering ([d5bdfa4](https://github.com/spaceship-prompt/spaceship-prompt/commit/d5bdfa42dc969fe9098792a305b34352d1ba4048)) -* **kubectl:** fix kubectl section ([1b71e09](https://github.com/spaceship-prompt/spaceship-prompt/commit/1b71e096dd68be80672173686ea1974d8095ea45)) -* make core variables readonly ([1cd4756](https://github.com/spaceship-prompt/spaceship-prompt/commit/1cd4756caf2080f8a13bd5aab15d927660f3d836)) -* NEWLINE variable doesn't work ([28b37f5](https://github.com/spaceship-prompt/spaceship-prompt/commit/28b37f566ebc141c93395d003601e1447f6bf91f)) -* **ps2:** print PS2 properly ([0d9766c](https://github.com/spaceship-prompt/spaceship-prompt/commit/0d9766c8b65707cb3e7eef19f78bb080cdda3e1b)) -* put user config loading in a proper place ([5c68702](https://github.com/spaceship-prompt/spaceship-prompt/commit/5c68702d6e695b517ca89593777651d665c8719e)) -* **python:** use python3 command ([0466bb8](https://github.com/spaceship-prompt/spaceship-prompt/commit/0466bb8a9c443e930d9ba11318b5fe6b0f8a6cca)) -* **renderer:** fix missing options for globes ([107429c](https://github.com/spaceship-prompt/spaceship-prompt/commit/107429ce5ea936d25fc8cbf813fcf256be75c683)) -* rendering docker context ([b6a49f8](https://github.com/spaceship-prompt/spaceship-prompt/commit/b6a49f8e00f28f265c13340183d102a1bbe5252f)) -* Resolve newline issue with command expansion ([bcfce70](https://github.com/spaceship-prompt/spaceship-prompt/commit/bcfce70c8552d4b8e378e7b542754da4115ce7b8)) -* **scripts:** Stop on errors ([ccee8e9](https://github.com/spaceship-prompt/spaceship-prompt/commit/ccee8e994d5bd1ddda8c3ed89e9d6767792a7b67)) -* set proper message if no account ([#1099](https://github.com/spaceship-prompt/spaceship-prompt/issues/1099)) ([69f906c](https://github.com/spaceship-prompt/spaceship-prompt/commit/69f906caa21af14b7ae199f2252629331485b8cd)) -* support CLOUDSDK_CONFIG env ([#1122](https://github.com/spaceship-prompt/spaceship-prompt/issues/1122)) ([ae348f9](https://github.com/spaceship-prompt/spaceship-prompt/commit/ae348f9a3df50b13134f1dc7f5eaa574f215cf74)), closes [#1117](https://github.com/spaceship-prompt/spaceship-prompt/issues/1117) -* **tests:** render prefixes and suffixes only when they are not empty ([73c2c71](https://github.com/spaceship-prompt/spaceship-prompt/commit/73c2c7135edfeadb92b285c7db70af63566f7852)) -* **upsearch:** Check repo properly ([4764ed9](https://github.com/spaceship-prompt/spaceship-prompt/commit/4764ed921d2b6a78c2ea72641ba91ed072e7b3b5)) - - -### Code Refactoring - -* **ember:** remove ember from built-in sections ([05beb8b](https://github.com/spaceship-prompt/spaceship-prompt/commit/05beb8b56f6203d215c50c0b26ff27174b9104ab)) -* **gradle:** migrate Gradle to a separate repo ([984bc01](https://github.com/spaceship-prompt/spaceship-prompt/commit/984bc01c073c399dfb7484c5ecdff672062a213f)) -* **install:** simplify the installation process ([824f876](https://github.com/spaceship-prompt/spaceship-prompt/commit/824f87657309b1f2579173252667a3cfb88c881e)) -* **maven:** migrate Maven to a separate repo ([3efd48b](https://github.com/spaceship-prompt/spaceship-prompt/commit/3efd48b55029ae2c68bbf4e3a43fb922c8b3e942)) -* **vi_mode:** move vi_mode to external section ([9ce611b](https://github.com/spaceship-prompt/spaceship-prompt/commit/9ce611b10ba3766f149abe8a1c1d27f488845b6e)), closes [#586](https://github.com/spaceship-prompt/spaceship-prompt/issues/586) - - -### Features - -* add ability to forcefully render a section synchronously ([216f0f2](https://github.com/spaceship-prompt/spaceship-prompt/commit/216f0f2c710191b1f3436c744c52b7de21129b4b)) -* add IBM Cloud CLI section ([#912](https://github.com/spaceship-prompt/spaceship-prompt/issues/912)) ([30b4b60](https://github.com/spaceship-prompt/spaceship-prompt/commit/30b4b60176e727cbf7b1fc7d1bccadcd61139c0b)) -* Add is_async util ([d539ee5](https://github.com/spaceship-prompt/spaceship-prompt/commit/d539ee5d61714addb80ba2d531a36d1029cc3d18)) -* Add java section ([713f406](https://github.com/spaceship-prompt/spaceship-prompt/commit/713f406a3f1bdbeda50bf6924dbf957230361595)) -* **async:** add an option to globaly disable/enable async rendering ([0ca1463](https://github.com/spaceship-prompt/spaceship-prompt/commit/0ca1463b1891edfcad0d25897a0c733dfdd19d73)) -* **async:** introduce async jobs indicator ([f0a75ce](https://github.com/spaceship-prompt/spaceship-prompt/commit/f0a75cece5361963b4c9a39fbd9151093ec3502d)) -* **cli:** add a print command for CLI ([6843105](https://github.com/spaceship-prompt/spaceship-prompt/commit/6843105f2a061629cc912d255f6e9ace98cc485b)) -* **cli:** add CLI ([205cb16](https://github.com/spaceship-prompt/spaceship-prompt/commit/205cb16eef6783d6e37af47d2492861d5c5aba7a)) -* **cli:** add command completions for cli ([2ae45a4](https://github.com/spaceship-prompt/spaceship-prompt/commit/2ae45a4ec0c4231b69c2090d3a7ed2211051945a)) -* **cli:** Add edit command ([b029587](https://github.com/spaceship-prompt/spaceship-prompt/commit/b029587ed9473ba9b8efc19ddaf8135636ae2d08)) -* **cli:** CLI for inserting and removing sections ([5dcce40](https://github.com/spaceship-prompt/spaceship-prompt/commit/5dcce40e99e0595453133862b95720882ab07fe7)), closes [#318](https://github.com/spaceship-prompt/spaceship-prompt/issues/318) -* **config:** Add ability to store config in ~/.config/spaceship ([b5dee37](https://github.com/spaceship-prompt/spaceship-prompt/commit/b5dee377c85b54e4f70071de42bc1cff52816f82)) -* **config:** introduce config file resolution ([e087459](https://github.com/spaceship-prompt/spaceship-prompt/commit/e087459d316aa445506cf41b3d58be4b0b4b854a)), closes [#508](https://github.com/spaceship-prompt/spaceship-prompt/issues/508) -* **docker:** add docker image and publishing it to ghcr.io ([77d7457](https://github.com/spaceship-prompt/spaceship-prompt/commit/77d74570b7a68c934bb4e5c5ac1a7b36e9fd96cb)) -* **exec_time:** display exec time with precision ([7b04aed](https://github.com/spaceship-prompt/spaceship-prompt/commit/7b04aed499175e22ec37b9af55fb3375d5fd48b1)) -* **git:** add ability to customize git and hg orders ([8a54cb3](https://github.com/spaceship-prompt/spaceship-prompt/commit/8a54cb39036b173be143b134f1ce00760813fe2d)), closes [#391](https://github.com/spaceship-prompt/spaceship-prompt/issues/391) -* **haskell:** Look for .hs files ([b2eb8a3](https://github.com/spaceship-prompt/spaceship-prompt/commit/b2eb8a35f3c41b73a7d48787a3f4f413c390407f)) -* **ibmcloud:** Enable async rendering for ibmcloud ([8391054](https://github.com/spaceship-prompt/spaceship-prompt/commit/8391054c79bacd68c87032ae9011f9c8deb424c6)) -* **package:** Add composer and julia support ([3f8bb1e](https://github.com/spaceship-prompt/spaceship-prompt/commit/3f8bb1e5a41ad33f55f5c078ed893a4ef7cee214)) -* **perf:** Compile to zwc ([3549bbf](https://github.com/spaceship-prompt/spaceship-prompt/commit/3549bbf9050670b70f79b61c6c90755022448b7e)) -* **registry:** Add custom sections registry ([86d64dd](https://github.com/spaceship-prompt/spaceship-prompt/commit/86d64ddbba4c42092a6fcb98dc06822726531a49)) -* **renderer:** render sync section on every render ([4e93ae0](https://github.com/spaceship-prompt/spaceship-prompt/commit/4e93ae0ccbb7cd692995b5e78942e783bb25aa71)) -* **section:** migrate default section to v4 ([0684171](https://github.com/spaceship-prompt/spaceship-prompt/commit/0684171c41783c278cfaa84fbc844a18a1b4a7ed)) -* **section:** Migrate sections to new signature ([b3249fb](https://github.com/spaceship-prompt/spaceship-prompt/commit/b3249fb756a31dec21f1c11beca1a37bf961332d)) -* **section:** Named arguments for section ([201496b](https://github.com/spaceship-prompt/spaceship-prompt/commit/201496b4311852e070b315b473dcfbe1d9a792cc)) -* **testkit:** add a simple testkit ([1ceca85](https://github.com/spaceship-prompt/spaceship-prompt/commit/1ceca858ddfe8888418e7096e3f863df5d611d6e)) -* Upsearch for project files up the tree ([08f6d70](https://github.com/spaceship-prompt/spaceship-prompt/commit/08f6d70e972fc56fa47dccb42f1e44b0bdce352b)) -* **vsc:** Make git and hg async ([9ddb9be](https://github.com/spaceship-prompt/spaceship-prompt/commit/9ddb9be29df8058e06b43a4a7504b4faa87cd677)) - - -### Performance Improvements - -* **zwc:** Precompile root file and async ([ee5afc5](https://github.com/spaceship-prompt/spaceship-prompt/commit/ee5afc5caf87b22bf3467679f8a6849c04956b03)) -* **zwc:** spaceship::precompile compiles sources to zwc ([58758e7](https://github.com/spaceship-prompt/spaceship-prompt/commit/58758e785d948ba3d5a1718dc5cc11321339ab81)) - - -### BREAKING CHANGES - -* **section:** spaceship::section:v4 uses flags instead of arguments order to pass section params. -* **vi_mode:** vi_mode section is not include in core anymore -* **gradle:** Gradle section is not included by default. It can be installed additionally from: -https://github.com/spaceship-prompt/spaceship-gradle -* **maven:** Maven section is no longer available by default. It can be additionally installed -from: https://github.com/spaceship-prompt/spaceship-maven -* **install:** Now users have to manually enable prompt system and choose spaceship -* **ember:** ember section is no longer available out of the box. It needs to be installed -additionally. - -## [3.16.7](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.16.6...v3.16.7) (2022-05-10) - - -### Bug Fixes - -* revert problem with publishing to brew ([d76cc7b](https://github.com/spaceship-prompt/spaceship-prompt/commit/d76cc7ba804471c78dfc1d471f688019a65934a6)) - -## [3.16.6](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.16.5...v3.16.6) (2022-05-09) - - -### Bug Fixes - -* **brew:** Attempt to bump homebrew formula with main release ([5f476b1](https://github.com/spaceship-prompt/spaceship-prompt/commit/5f476b1d2942c778a9ca4d7609f4db2526c9430d)) - -## [3.16.5](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.16.4...v3.16.5) (2022-03-28) - - -### Bug Fixes - -* support CLOUDSDK_CONFIG env ([#1122](https://github.com/spaceship-prompt/spaceship-prompt/issues/1122)) ([6358eaf](https://github.com/spaceship-prompt/spaceship-prompt/commit/6358eaff0a2ad954445c169335d89ef00602aee1)), closes [#1117](https://github.com/spaceship-prompt/spaceship-prompt/issues/1117) - -## [3.16.4](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.16.3...v3.16.4) (2022-02-24) - - -### Bug Fixes - -* **readme:** Add notice about Ukraine ([93f328f](https://github.com/spaceship-prompt/spaceship-prompt/commit/93f328ffc049ac0c847d697b0792487b616f4496)) - -## [3.16.3](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.16.2...v3.16.3) (2022-02-16) - - -### Bug Fixes - -* set proper message if no account ([#1099](https://github.com/spaceship-prompt/spaceship-prompt/issues/1099)) ([15d2279](https://github.com/spaceship-prompt/spaceship-prompt/commit/15d227994e003a9a3ddd30596f8a675acc212f29)) - -## [3.16.2](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.16.1...v3.16.2) (2022-01-15) - - -### Bug Fixes - -* don't show docker section when using colima ([#1101](https://github.com/spaceship-prompt/spaceship-prompt/issues/1101)) ([9b6e88b](https://github.com/spaceship-prompt/spaceship-prompt/commit/9b6e88b0d2c1d76961c59c1f5476830a2ce44293)) - -## [3.16.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.16.0...v3.16.1) (2021-11-05) - - -### Bug Fixes - -* fix aws section bug ([#1089](https://github.com/spaceship-prompt/spaceship-prompt/issues/1089)) ([642f645](https://github.com/spaceship-prompt/spaceship-prompt/commit/642f645d5f3d73504bd4c3045077c0354315c113)) - -# [3.16.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.15.0...v3.16.0) (2021-10-25) - - -### Features - -* **aws:** Add support to aws-vault ([#1078](https://github.com/spaceship-prompt/spaceship-prompt/issues/1078)) ([ca8e8f0](https://github.com/spaceship-prompt/spaceship-prompt/commit/ca8e8f0a7da7b84c0cdeca98aa8351a6cc1f48d2)) - -# [3.15.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.14.1...v3.15.0) (2021-10-11) - - -### Features - -* add IBM Cloud CLI section ([#912](https://github.com/spaceship-prompt/spaceship-prompt/issues/912)) ([6433544](https://github.com/spaceship-prompt/spaceship-prompt/commit/64335447e0b2f250ca6d145a3343a3613853c00a)) - -## [3.14.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.14.0...v3.14.1) (2021-08-30) - - -### Bug Fixes - -* **docs:** fix discord announcement color ([91af763](https://github.com/spaceship-prompt/spaceship-prompt/commit/91af7638aadb94bb3f2ff8d924d47c4001d07709)) - -# [3.14.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.13.4...v3.14.0) (2021-07-28) - - -### Features - -* **node:** Added support for fnm ([#1058](https://github.com/spaceship-prompt/spaceship-prompt/issues/1058)) ([b92b7d2](https://github.com/spaceship-prompt/spaceship-prompt/commit/b92b7d2ecb8ded6b1a0ff72617f0106bbe8dcc69)) - -## [3.13.4](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.13.3...v3.13.4) (2021-07-28) - - -### Bug Fixes - -* Prevent unintended output when `dotnet --version` fails ([#1054](https://github.com/spaceship-prompt/spaceship-prompt/issues/1054)) ([d18449a](https://github.com/spaceship-prompt/spaceship-prompt/commit/d18449a93600b20c2b318beafcabb584b4d3c3d5)) - -## [3.13.3](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.13.2...v3.13.3) (2021-07-21) - - -### Bug Fixes - -* fix maven 3.5.0 bug ([#1053](https://github.com/spaceship-prompt/spaceship-prompt/issues/1053)) ([c24ff52](https://github.com/spaceship-prompt/spaceship-prompt/commit/c24ff52e7a1256900fce9ca6750fdaa9c1958129)) - -## [3.13.2](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.13.1...v3.13.2) (2021-07-12) - - -### Bug Fixes - -* get GCLOUD_ACTIVE_CONFIG from ENVIRONMENT, if set ([#1046](https://github.com/spaceship-prompt/spaceship-prompt/issues/1046)) ([349240e](https://github.com/spaceship-prompt/spaceship-prompt/commit/349240e01506672380a3c5c5a04343348329dd5b)) - -## [3.13.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.13.0...v3.13.1) (2021-07-12) - - -### Bug Fixes - -* docker section bug and optimize package section ([#1045](https://github.com/spaceship-prompt/spaceship-prompt/issues/1045)) ([b459a1a](https://github.com/spaceship-prompt/spaceship-prompt/commit/b459a1aabd71f93bf3c3adc1b8a3527ab9da5647)) - -# [3.13.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.26...v3.13.0) (2021-07-09) - - -### Features - -* **package:** add support for package version from lerna.json instead of package.json ([f09b9da](https://github.com/spaceship-prompt/spaceship-prompt/commit/f09b9da70cd6e9f072e68ed02921ee59b515bcbf)) - -## [3.12.26](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.25...v3.12.26) (2021-07-08) - - -### Bug Fixes - -* **php:** Unalias grep for PHP version ([#1030](https://github.com/spaceship-prompt/spaceship-prompt/issues/1030)) ([354ae0f](https://github.com/spaceship-prompt/spaceship-prompt/commit/354ae0f13192f1da66ad0e21c917ae8859a7e926)), closes [#857](https://github.com/spaceship-prompt/spaceship-prompt/issues/857) - -## [3.12.8-3.12.25](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.8...v3.12.25) (2021-07-01) - - -### Bug Fixes - -* **ci:** Attempt to fix release for Homebrew ([a1af3f6](https://github.com/spaceship-prompt/spaceship-prompt/commit/a1af3f60c96a07927fad49ad66d4fd1fe5f73bca)) -* **ci:** Move Homebrew formula to a separate job ([741bc3e](https://github.com/spaceship-prompt/spaceship-prompt/commit/741bc3e5b1118379c4c5112f2670e56b04dc5773)) -* **ci:** Bump Homebrew only if new releaes is published. Pass tag-name. ([4412f68](https://github.com/spaceship-prompt/spaceship-prompt/commit/4412f68dcb838e130b388613528a6ae47dcf3620)) -* **ci:** Fix syntax error in workflow file ([9119f46](https://github.com/spaceship-prompt/spaceship-prompt/commit/9119f461f3058424cf3d0cf794b30d115fa40e99)) -* **ci:** Move homebrew to a separate file ([554f065](https://github.com/spaceship-prompt/spaceship-prompt/commit/554f06504138c8d6baf1ad9ba92dd0517c1b71d2)) -* **ci:** Attempt to fix Homebrew ([7d17060](https://github.com/spaceship-prompt/spaceship-prompt/commit/7d17060dfd4b4ad7e4dd2214492698b0a1f8b959)) -* **ci:** Attempt to fix homebrew with tags as array ([278a87d](https://github.com/spaceship-prompt/spaceship-prompt/commit/278a87d8ef5fb4fbd9699d4bbfe9faebd0941781)) -* **ci:** wrap tags in quotes ([742a310](https://github.com/spaceship-prompt/spaceship-prompt/commit/742a310ea72781433d0936c6eb77951c65e46c48)) -* **ci:** trigger homebrew on every tag push ([3e40ef8](https://github.com/spaceship-prompt/spaceship-prompt/commit/3e40ef83e93ab1696906b310033aed04b5843fc8)) -* **ci:** move homebrew back to ci workflow ([1c90270](https://github.com/spaceship-prompt/spaceship-prompt/commit/1c902701b35d475bd8c79cae7aa3de28c24ed21d)) -* **ci:** Update download url for Homebrew ([ab95d19](https://github.com/spaceship-prompt/spaceship-prompt/commit/ab95d19809dc96b76267da45f1a9830a484f5a38)) -* **ci:** Update download-url for homebrew once again ([838b68e](https://github.com/spaceship-prompt/spaceship-prompt/commit/838b68eaf7ad41546a525323a5846fa2c560613c)) -* **ci:** Try dawidd6/action-homebrew-bump-formula ([002b9f7](https://github.com/spaceship-prompt/spaceship-prompt/commit/002b9f70f29ce56423aebff4d7c55452913c4077)) -* **ci:** Try using PAT for publishing releases ([89e52f5](https://github.com/spaceship-prompt/spaceship-prompt/commit/89e52f5d463cf0ba15f319ca27e9d8cf2f642115)) -* **ci:** Provide tag-name ([5238054](https://github.com/spaceship-prompt/spaceship-prompt/commit/5238054a97f08a6e4bf41998b70f4a4b9a290194)) -* **ci:** Homebrew in separate file. Trigger via PAT ([30d4f74](https://github.com/spaceship-prompt/spaceship-prompt/commit/30d4f74019bc6edaf5e739cc31abeffdfb3f703c)) -* **ci:** tags trigger as array ([57e46df](https://github.com/spaceship-prompt/spaceship-prompt/commit/57e46df89bfc79816b4086b383960a08f2d94192)) -* **ci:** Try using release as a trigger ([af38f82](https://github.com/spaceship-prompt/spaceship-prompt/commit/af38f82b661ca609146acd43ac5dd483405aa13b)) -* **ci:** Add a comment and jobs canceling ([dbfaa0c](https://github.com/spaceship-prompt/spaceship-prompt/commit/dbfaa0cca1e74a209c8adb2805505106946c4075)) - -## [3.12.7](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.6...v3.12.7) (2021-06-30) - - -### Bug Fixes - -* **ruby:** Update ruby asdf version finder, asdf was updated to print version second ([#864](https://github.com/spaceship-prompt/spaceship-prompt/issues/864)) ([24a75d8](https://github.com/spaceship-prompt/spaceship-prompt/commit/24a75d8a8a5b461fe47f2abc7523a62806e457e2)) - -## [3.12.6](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.5...v3.12.6) (2021-06-17) - - -### Bug Fixes - -* Revert changes from aaf35d562118e2074d8eaff89c749e1560776e44 ([d35eb19](https://github.com/spaceship-prompt/spaceship-prompt/commit/d35eb1912559dd29ff387376aa62ea27a22c3bd9)) - -## [3.12.5](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.4...v3.12.5) (2021-06-17) - - -### Bug Fixes - -* Do not add a newline before prompt when terminal opens ([#1016](https://github.com/spaceship-prompt/spaceship-prompt/issues/1016)) ([aaf35d5](https://github.com/spaceship-prompt/spaceship-prompt/commit/aaf35d562118e2074d8eaff89c749e1560776e44)) - -## [3.12.4](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.3...v3.12.4) (2021-06-09) - - -### Bug Fixes - -* fix maven section bug ([#960](https://github.com/spaceship-prompt/spaceship-prompt/issues/960)) ([1c8348d](https://github.com/spaceship-prompt/spaceship-prompt/commit/1c8348d87329a746a67d9841d0b372317c09fd09)) - -## [3.12.3](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.2...v3.12.3) (2021-06-07) - - -### Bug Fixes - -* **license:** Fix years in license ([da7984a](https://github.com/spaceship-prompt/spaceship-prompt/commit/da7984aeede599b919c5c551b8b981a12de46312)) - -## [3.12.2](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.1...v3.12.2) (2021-06-07) - - -### Bug Fixes - -* tweak CI ([#958](https://github.com/spaceship-prompt/spaceship-prompt/issues/958)) ([e9055c2](https://github.com/spaceship-prompt/spaceship-prompt/commit/e9055c2de2ffd72f6d4e568ceb00453afb5f0598)) - -## [3.12.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.12.0...v3.12.1) (2021-06-04) - - -### Bug Fixes - -* **ci:** Fix typo in .releaserc.json ([4f19ada](https://github.com/spaceship-prompt/spaceship-prompt/commit/4f19ada63c36a41eb144969a684b04b9aafb80d5)) -* **ci:** Specify which files to commit on release ([631df26](https://github.com/spaceship-prompt/spaceship-prompt/commit/631df26c6c0e1348d2a9790477cc8e2a38e91850)) - -# [3.12.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v3.11.2...v3.12.0) (2021-06-04) - - -### Bug Fixes - -* **ci:** Fix workflow syntax error ([fcdf5c2](https://github.com/spaceship-prompt/spaceship-prompt/commit/fcdf5c298b50602ed5ebbd54d8d35a09de8e9557)) -* **ci:** Remove obsolete Node.js steps ([d74944f](https://github.com/spaceship-prompt/spaceship-prompt/commit/d74944fae7bba847803ea87b2d3b3829454b266f)) -* change wrong env variables ([#817](https://github.com/spaceship-prompt/spaceship-prompt/issues/817)) ([1d88d3f](https://github.com/spaceship-prompt/spaceship-prompt/commit/1d88d3f56029364afdcd00f340a15ebf46765080)) -* change wrong env variables ([#817](https://github.com/spaceship-prompt/spaceship-prompt/issues/817)) ([56c7e5d](https://github.com/spaceship-prompt/spaceship-prompt/commit/56c7e5d349229e643cf3dd334bd063bb35881c35)) -* Fix acpi output bug ([75dd4ff](https://github.com/spaceship-prompt/spaceship-prompt/commit/75dd4ffd63d2e524839869d45b0f29246e2117b2)) -* Fix battery section bug because match function is supported at gawk ([#780](https://github.com/spaceship-prompt/spaceship-prompt/issues/780)) ([1266cd9](https://github.com/spaceship-prompt/spaceship-prompt/commit/1266cd9a9544d336090f65060630be2bf78393a1)) -* Hardened the Docker context checking logic ([a853780](https://github.com/spaceship-prompt/spaceship-prompt/commit/a8537807f4edd74756805ce6dfb7d1234e75fdc4)) -* Hardened the Docker version checking logic ([e075f08](https://github.com/spaceship-prompt/spaceship-prompt/commit/e075f084c093ba289a6328edeb42660d28355e52)) -* reformat ([51e6cf3](https://github.com/spaceship-prompt/spaceship-prompt/commit/51e6cf3d4252c635f6b4c4c4d5a18fadde1da1cc)) -* typo ([dc5c4d2](https://github.com/spaceship-prompt/spaceship-prompt/commit/dc5c4d2441d982d2505367d3c9af7d5c6f461ae5)) - - -### Features - -* Add Runrioter as a maintainer ([b71f6ae](https://github.com/spaceship-prompt/spaceship-prompt/commit/b71f6ae71da4fe127c272d8824e4bc67786f5846)), closes [#747](https://github.com/spaceship-prompt/spaceship-prompt/issues/747) -* Add semantic release cycle ([#956](https://github.com/spaceship-prompt/spaceship-prompt/issues/956)) ([6220873](https://github.com/spaceship-prompt/spaceship-prompt/commit/622087366a86d0478d6b38b3edb7024c500b9b4f)) diff --git a/.zsh/themes/spaceship-prompt/CODE_OF_CONDUCT.md b/.zsh/themes/spaceship-prompt/CODE_OF_CONDUCT.md deleted file mode 100644 index 50a7058..0000000 --- a/.zsh/themes/spaceship-prompt/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,128 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity -and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the - overall community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or - advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email - address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -coc@spaceship-prompt.sh. -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series -of actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or -permanent ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within -the community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, available at -https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. - -Community Impact Guidelines were inspired by [Mozilla's code of conduct -enforcement ladder](https://github.com/mozilla/diversity). - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. diff --git a/.zsh/themes/spaceship-prompt/CONTRIBUTING.md b/.zsh/themes/spaceship-prompt/CONTRIBUTING.md deleted file mode 100644 index 7e00e93..0000000 --- a/.zsh/themes/spaceship-prompt/CONTRIBUTING.md +++ /dev/null @@ -1,94 +0,0 @@ -# Contributing - -First, thank you for contributing 💖 - -Any contribution of any skill level is highly appreciated and welcome. - -## Philosophy - -There's a simple philosophy behind the Spaceship: - -* **Show only what's needed.** The prompt should not be overloaded, it shows only what user needs at the moment (current directory, git branch, etc). -* **Work out of the box.** The prompt should work right after installation without any additional configuration. Install it and use it. -* **Be configurable.** It works without configuration, but if a configuration is needed, it provides an easy-to-use interface for customization. -* **Maintain performance.** Any change should be made with performance in mind. We aim to keep the prompt fast and robust. If you spot any point where performance could be improved, we will gladly accept your contribution. - -## Architecture - -The project begins in [`spaceship.zsh`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/spaceship.zsh) file. It sources files from the `lib` folders, registers Zsh hooks and kicks off the section loading. - -We use [`zsh-async`](https://github.com/mafredri/zsh-async) for asynchronous rendering of sections. We always keep a copy of this library as a fallback in case a user doesn't have `zsh-async` installed. - -## Section Checklist - -The simplest way to create a section is to follow this guide: - -[**➡️ Creating a custom section**](https://spaceship-prompt.sh/advanced/creating-section) - -Spaceship aims to show only necessary information to the user, so we carefully consider the inclusion of new sections. Commonly we accept sections that are showing the contextual information, like runtime version, current directory, git status, compiler version, etc. - -Sections for the version of frameworks, libraries, versions of CLI tools, etc can be included, but with considerations. It's better to make such section as an external one, so it can be installed optionally. - -When adding a new section to Spaceship, here's a checklist you should follow: - -- [ ] Add a section to `sections` folder. -- [ ] Include a section to prompt order options in `spaceship.zsh` file. -- [ ] Add tests for section in `tests` folder. You can use [crystal](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/tests/crystal.test.zsh) or [deno](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/tests/deno.test.zsh) tests as examples. -- [ ] Add documentation for a section in `docs/sections` folder. - - [ ] Include a reference for section in `mkdocs.yml` file. - - [ ] Include a reference for section in `config/prompt.md` file. -- [ ] Add a section to the registry in `docs/registry/internal.json` - -> **Note:** Do not add translation files for a section manually. Those should and will be added via Crowdin automatically. - -## Setup - -1. **Fork** this repo (click the _fork_ button) -1. **Clone** your fork to your working machine (via `git clone`) -1. **Update submodules** in your fork (via `git submodule update --init --recursive`) -1. **Make your changes**. Check our [API](https://spaceship-prompt.sh/api) for more information (we suggest you to check out a new branch for changes). -1. **Test** your code (via `make tests`) -1. **Add and commit** your contributions -1. **Push** your changes to your remote fork -1. **Open a pull-request** to our primary repo and target `master` branch. -1. **Wait for review**, get your PR reviewed and merged. - -## Testing - -We use [`shunit2`](https://github.com/kward/shunit2) as a testing framework. In order to run all the tests, execute: - -```zsh -make tests -``` - -## Documentation - -The documentation website is built using [mkdocs-material](https://squidfunk.github.io/mkdocs-material). - -Start a local development server for the website using the following commands: - -```zsh -# Install website dependencies -pip3 install -r requirements.txt - -# Start a server -make docs -``` - -### Translations - -We use Crowdin to translate the documentation. Please do not edit the translations directly. If you want to contribute to the translations, please visit our translation page: - -[➡**️ Spaceship Crowdin**](https://translate.spaceship-prompt.sh/) - -## For maintainers - -A few notes for current and future maintainers of Spaceship: - -- The version, changelog and release notes are generated automatically based on commit history. -- This repository adheres to [semver](https://semver.org/), using [conventional commits](https://www.conventionalcommits.org/) via [semantic-release](https://github.com/semantic-release/semantic-release). -- Issues and PRs must be replied in first 24 hours. At least a simple message that we've noticed that issue was reported. -- Every issue and a PR should have a label. -- Issues containing questions should be moved to discussions. - -_Thanks for reading this contribution guide! Happy hacking!_ diff --git a/.zsh/themes/spaceship-prompt/Dockerfile b/.zsh/themes/spaceship-prompt/Dockerfile deleted file mode 100644 index a4e7a20..0000000 --- a/.zsh/themes/spaceship-prompt/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM frapsoft/zsh - -# Installing utils -RUN apk add --update --no-cache git curl - -# Change workdir to root's home -WORKDIR /root - -# Coppying Spaceship to the image -COPY . /spaceship - -# Setting up .zshrc -RUN echo "export TERM=xterm-256color" >> /root/.zshrc -RUN echo "source spaceship/spaceship.zsh" >> /root/.zshrc - -# zsh as an entrypoint -ENTRYPOINT ["/bin/zsh"] diff --git a/.zsh/themes/spaceship-prompt/LICENSE.md b/.zsh/themes/spaceship-prompt/LICENSE.md deleted file mode 100644 index 4964df2..0000000 --- a/.zsh/themes/spaceship-prompt/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022-2016 [Denys Dovhan](https://denysdovhan.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/.zsh/themes/spaceship-prompt/Makefile b/.zsh/themes/spaceship-prompt/Makefile deleted file mode 100644 index 77ba9ff..0000000 --- a/.zsh/themes/spaceship-prompt/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -.PHONY: zwc clean compile tests install uninstall docs - -ZSH := $(shell command -v zsh 2> /dev/null) - -# Compile to zwc -zwc: - $(ZSH) -fc 'for f in *.zsh-theme *.zsh lib/*.zsh sections/*.zsh; do zcompile -R -- $$f.zwc $$f || exit; done' - -# Clean up zwc -clean: - find . -name "*.zwc" -type f -delete - -# Compile everything -compile: zwc - -# Run all tests with a nice reporer -tests: - ./scripts/tests - -# Link spaceship to site-functions -install: - ./scripts/install - -# Unlink spaceship from site-functions -uninstall: - ./scripts/uninstall - -# Serve the docs -docs: - @mkdocs serve diff --git a/.zsh/themes/spaceship-prompt/README.md b/.zsh/themes/spaceship-prompt/README.md deleted file mode 100644 index dad9120..0000000 --- a/.zsh/themes/spaceship-prompt/README.md +++ /dev/null @@ -1,325 +0,0 @@ -[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua/) - -<h1 align="center"> - <a href="https://github.com/spaceship-prompt/spaceship-prompt"> - <img alt="spaceship →~ prompt" src="https://cloud.githubusercontent.com/assets/3459374/21679181/46e24706-d34b-11e6-82ee-5efb3d2ba70f.png" width="400"> - </a> - <br>Spaceship Prompt 🚀⭐<br> -</h1> - -<h4 align="center"> - Minimalistic, powerful and extremely customizable <a href="http://zsh.org" target="_blank"><code>Zsh</code></a> prompt -</h4> - -<p align="center"> - <a href="https://npmjs.org/package/spaceship-prompt"> - <img src="https://img.shields.io/npm/v/spaceship-prompt.svg?style=flat-square" - alt="NPM Version" /> - </a> - - <a href="https://github.com/spaceship-prompt/spaceship-prompt/actions"> - <img src="https://img.shields.io/github/workflow/status/spaceship-prompt/spaceship-prompt/ci?style=flat-square" - alt="GitHub Workflow Status" /> - </a> - - <a href="http://zsh.org/"> - <img src="https://img.shields.io/badge/zsh-%3E%3Dv5.2-777777.svg?style=flat-square" - alt="Zsh Version" /> - </a> - - <a href="https://twitter.com/SpaceshipPrompt"> - <img src="https://img.shields.io/badge/twitter-%40SpaceshipZSH-00ACEE.svg?style=flat-square" - alt="Spaceship Twitter" /> - </a> - - <a href="https://discord.gg/NTQWz8Dyt9"> - <img - src="https://img.shields.io/discord/859409950999707668?label=discord&logoColor=white&style=flat-square" - alt="Chat on Discord" - /> - </a> - - <a href="https://patreon.com/denysdovhan"> - <img src="https://img.shields.io/badge/support-patreon-F96854.svg?style=flat-square" - alt="Donate" /> - </a> -</p> - -<div align="center"> - <h4> - <a href="https://spaceship-prompt.sh">Website</a> | - <a href="https://spaceship-prompt.sh/getting-started">Installation</a> | - <a href="https://spaceship-prompt.sh/config/intro">Configuration</a> | - <a href="https://spaceship-prompt.sh/advanced/creating-section">Advanced Usage</a> - </h4> -</div> - -<div align="center"> - <sub>Built with ❤︎ by - <a href="https://denysdovhan.com">Denys Dovhan</a> and - <a href="https://github.com/spaceship-prompt/spaceship-prompt/graphs/contributors">contributors </a> -</div> -<br> - -Spaceship is a minimalistic, powerful and extremely customizable [Zsh][zsh-url] prompt. Prompt is what you see when you type a command. It can show a lot of useful tips, saving your time and making user experience smooth and pleasant. It combines everything you may need for convenient work, without unnecessary complications, like a real spaceship. - -<p align="center"> - <a href="https://asciinema.org/a/513451"> - <img alt="Spaceship with One Dark, zsh-autosuggestions and zsh-syntax-highlight" src="https://user-images.githubusercontent.com/3459374/183478313-5aa02cbe-fafc-42e0-a791-ea08a0902f56.gif" width="80%"> - </a> - <br> - <sup>Visit <a href="https://deploy-preview-963--spaceship-prompt.netlify.app/faq/#why-doesnt-my-prompt-look-like-the-preview">Frequently Asked Question</a> for similar setup and find more examples with different color schemes in <a href="https://github.com/spaceship-prompt/spaceship-prompt/wiki/Screenshots">Screenshots </a>wiki-page. - </sup> -</p> - -## ✨ Features - -Here are some sneak picks of what **Spaceship** can show: - -- Clever hostname and username displaying -- Repository statuses (Git and Mercurial are supported) -- Runtime environments for various languages (Node.js, Rust, Python, Ruby, Swift, Go, PHP and many others) -- Docker version, Kubernetes context and connected machine -- Package version (npm, lerna, cargo, composer and others) -- Battery level and status -- Indicator for jobs in the background `✦` -- A lot of [useful information](https://spaceship-prompt.sh/sections) -- Custom [information of your choice](https://spaceship-prompt.sh/advanced/creating-section) - -Want more features? Please, [open an issue](https://github.com/spaceship-prompt/spaceship-prompt/issues/new/choose) or send pull request. - -## 🤝 Requirements - -Before we begin, let's make sure you have the following installed: - -- [Zsh](http://www.zsh.org/) (v5.2 or recent) must be installed. Run the following command to check you version of Zsh: - ```zsh - echo $ZSH_VERSION #> 5.8.1 - ``` -- [Powerline Font](https://github.com/powerline/fonts) or [Nerd Font](https://www.nerdfonts.com/) (even better) must be installed and used in your terminal. [Fira Code](https://github.com/tonsky/FiraCode) is a popular choice. To check if Powerline Font works for you, run: - ```zsh - echo -e "\xee\x82\xa0" #>  - ``` - -## 🚀 Installation - -Here's a few popular methods to install Spaceship. Select the one you use from the list below: - -<details> -<summary>Homebrew</summary> -Installing Spaceship via Homebrew is a simple command: - -```zsh title="Terminal" -brew install spaceship -``` - -Add prompt initialization to your `.zshrc`: - -```zsh title="Terminal" -echo "source $(brew --prefix)/opt/spaceship/spaceship.zsh" >>! ~/.zshrc -``` -</details> - -<details> -<summary>Oh-My-Zsh</summary> -Clone this repo: - -```zsh -git clone https://github.com/spaceship-prompt/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" --depth=1 -``` - -Symlink `spaceship.zsh-theme` to your oh-my-zsh custom themes directory: - -```zsh -ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme" -``` - -Set `ZSH_THEME="spaceship"` in your `.zshrc`. -</details> - -<details> -<summary>npm</summary> -Install Spaceship via npm as you would with any other global package: - -``` -npm install -g spaceship-prompt -``` - -This command will download Spaceship. It will also ask you to source Spaceship in your `~/.zshrc` file. - -</details> - -<details> -<summary>prezto</summary> - -- Follow [prezto-contrib#usage](https://github.com/belak/prezto-contrib#usage) to clone `prezto-contrib` to the proper location. -- Enable the `contrib-prompt` module (before the `prompt` module). -- Set `zstyle ':prezto:module:prompt' theme 'spaceship'` in your `.zpreztorc`. - -</details> - -<details> -<summary>zim</summary> -Add Spaceship to your `.zimrc`: - -```zsh -zmodule spaceship-prompt/spaceship-prompt --name spaceship --no-submodules -``` - -Then install Spaceship: - -```zsh -zimfw install -``` -</details> - -<details> -<summary>antigen</summary> -Add the following snippet in your `.zshrc`: - -```zsh -antigen theme spaceship-prompt/spaceship-prompt -``` -</details> - -<details> -<summary>antibody</summary> -Update your `.zshrc` file with the following line: - -```zsh -antibody bundle spaceship-prompt/spaceship-prompt -``` -</details> - -<details> -<summary>zinit</summary> -Add the following line to your `.zshrc` where you're adding your other Zsh plugins: - -```zsh -zinit light spaceship-prompt/spaceship-prompt -``` -</details> - -<details> -<summary>zgen</summary> -Add the following line to your `.zshrc` where you're adding your other Zsh plugins: - -```zsh -zgen load spaceship-prompt/spaceship-prompt spaceship -``` -</details> - -<details> -<summary>zplug</summary> -Use this command in your `.zshrc` to load Spaceship as prompt theme: - -```zsh -zplug "spaceship-prompt/spaceship-prompt", use:spaceship.zsh, from:github, as:theme -``` -</details> - -<details> -<summary>sheldon</summary> -Add the following to your `plugins.toml` file (open it with `sheldon edit`): - -```toml -[plugins.spaceship] -github = "spaceship-prompt/spaceship-prompt" -``` - -Or run the following to automatically add it: - -```zsh -sheldon add spaceship --github spaceship-prompt/spaceship-prompt -``` -</details> - -<details> -<summary>Arch</summary> -Install the latest master from the AUR package [`spaceship-prompt-git`](https://aur.archlinux.org/packages/spaceship-prompt-git/): - -``` -git clone https://aur.archlinux.org/spaceship-prompt-git.git --depth=1 -cd spaceship-prompt-git -makepkg -si -``` -</details> - -<details> -<summary>Manual</summary> - -If none of the above methods works for you, you can install Spaceship manually. - -1. Clone this repo somewhere, for example to `$HOME/.zsh/spaceship`. -2. Source Spaceship in your `~/.zshrc`. - -### Example - -```zsh -mkdir -p "$HOME/.zsh" -git clone --depth=1 https://github.com/spaceship-prompt/spaceship-prompt.git "$HOME/.zsh/spaceship" -``` - -For initializing prompt system add this to your `.zshrc`: - -```zsh title=".zshrc" -source "$HOME/.zsh/spaceship/spaceship.zsh" -``` -</details> - -## ⚙️ Configuration - -Spaceship works well out of the box, but you can customize almost everything if you want. - -- [**⚙️ Configuration**](https://spaceship-prompt.sh/config/intro) — Tweak section's behavior with tons of options. -- [**😎 Advanced Usage**](https://spaceship-prompt.sh/advanced/creating-section) — Learn how to create a custom section, benefit of per-directory configuration and more. - -Additionally, join our community in [Discord](https://discord.gg/NTQWz8Dyt9) and follow our [Twitter](https//twitter.com/SpaceshipPrompt) for updates. - -## 🫶 Contributing - -We're glad to accept contributions from developers of **all skill levels**! If you are interested in contributing to Spaceship, please take a look at our [Contribution Guide](./CONTRIBUTING.md) for more details. If you're looking for an easy way into the project, take one of the issues with [**good first issue**](https://github.com/spaceship-prompt/spaceship-prompt/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label. - -If you are fluent in any other language besides English, we greatly appreciate any help with translating our documentation in other languages. If you would like to help, join the [team of translators on our Crowdin](https://translate.spaceship-prompt.sh). - -If you're interested in helping other people, answer questions asked by other users of Spaceship and help to solve their issues. Additionally, join our [**Discord**](https://discord.gg/NTQWz8Dyt9) to discuss Spaceship and help people who need help. - -## 💌 Sponsoring - -If you really enjoy this project, you can contribute financially. Any contribution is highly appreciated, even the smallest one. There are several ways to donate: - -* **Recurring donations**: - * [GitHub Sponsors](https://github.com/sponsors/denysdovhan?frequency=recurring) - * [Open Collective](https://opencollective.com/spaceship-prompt) - * [Patreon](https://patreon.com/denysdovhan) -* **One-time donations**: - * [GitHub Sponsors](https://github.com/sponsors/denysdovhan?frequency=one-time) - * [Buy Me A Coffee](https://buymeacoffee.com/denysdovhan) - * [Monobank Jar](https://send.monobank.ua/jar/2N46sWTaZZ) -* **Crypto donations**: - * Ethereum: `0x5C9496De5E51D48daf28354DC04d8f9D33955559` - * Bitcoin: `bc1q5ezjvpgftmx42f9qgdf5lscjz43uh4jf02uvje` - -## 🤔 Having trouble? - -Find answers on our troubleshooting page or get help by our community. - -[**Issues**](https://github.com/spaceship-prompt/spaceship-prompt/issues) • [**Discussions**](https://github.com/spaceship-prompt/spaceship-prompt/discussions/) • [**Discord**](https://discord.gg/NTQWz8Dyt9) - -Still struggling? Please, [*file an issue*](https://github.com/spaceship-prompt/spaceship-prompt/issues/new/choose), describe your problem, and we will gladly help you. - -## 👀 Derived Projects - -Here's a list of related projects that have been inspired by Spaceship ZSH. - -- [**denysdovhan/dotfiles**](https://github.com/denysdovhan/dotfiles) - Dotfiles of Spaceship's author from which Spaceship is originated. -- [**matchai/spacefish**](https://github.com/matchai/spacefish) - A port of Spaceship ZSH for fish shell intending to achieve complete feature parity. -- [**starship/starship**](https://github.com/starship/starship) - A blazing-fast, cross-shell prompt written in Rust, heavily inspired by Spaceship ZSH. - -## 📄 License - -MIT © [Denys Dovhan](http://denysdovhan.com) - -<!-- References --> -[zsh-url]: http://zsh.org/ -[patreon-url]: https://www.patreon.com/denysdovhan diff --git a/.zsh/themes/spaceship-prompt/async b/.zsh/themes/spaceship-prompt/async deleted file mode 100644 index 1a73d08..0000000 --- a/.zsh/themes/spaceship-prompt/async +++ /dev/null @@ -1,669 +0,0 @@ -#!/usr/bin/env zsh - -# -# zsh-async -# -# version: v1.8.5 -# author: Mathias Fredriksson -# url: https://github.com/mafredri/zsh-async -# - -typeset -g ASYNC_VERSION=1.8.5 -# Produce debug output from zsh-async when set to 1. -typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0} - -# Execute commands that can manipulate the environment inside the async worker. Return output via callback. -_async_eval() { - local ASYNC_JOB_NAME - # Rename job to _async_eval and redirect all eval output to cat running - # in _async_job. Here, stdout and stderr are not separated for - # simplicity, this could be improved in the future. - { - eval "$@" - } &> >(ASYNC_JOB_NAME=[async/eval] _async_job 'cat') -} - -# Wrapper for jobs executed by the async worker, gives output in parseable format with execution time -_async_job() { - # Disable xtrace as it would mangle the output. - setopt localoptions noxtrace - - # Store start time for job. - float -F duration=$EPOCHREALTIME - - # Run the command and capture both stdout (`eval`) and stderr (`cat`) in - # separate subshells. When the command is complete, we grab write lock - # (mutex token) and output everything except stderr inside the command - # block, after the command block has completed, the stdin for `cat` is - # closed, causing stderr to be appended with a $'\0' at the end to mark the - # end of output from this job. - local jobname=${ASYNC_JOB_NAME:-$1} out - out="$( - local stdout stderr ret tok - { - stdout=$(eval "$@") - ret=$? - duration=$(( EPOCHREALTIME - duration )) # Calculate duration. - - print -r -n - $'\0'${(q)jobname} $ret ${(q)stdout} $duration - } 2> >(stderr=$(cat) && print -r -n - " "${(q)stderr}$'\0') - )" - if [[ $out != $'\0'*$'\0' ]]; then - # Corrupted output (aborted job?), skipping. - return - fi - - # Grab mutex lock, stalls until token is available. - read -r -k 1 -p tok || return 1 - - # Return output (<job_name> <return_code> <stdout> <duration> <stderr>). - print -r -n - "$out" - - # Unlock mutex by inserting a token. - print -n -p $tok -} - -# The background worker manages all tasks and runs them without interfering with other processes -_async_worker() { - # Reset all options to defaults inside async worker. - emulate -R zsh - - # Make sure monitor is unset to avoid printing the - # pids of child processes. - unsetopt monitor - - # Redirect stderr to `/dev/null` in case unforseen errors produced by the - # worker. For example: `fork failed: resource temporarily unavailable`. - # Some older versions of zsh might also print malloc errors (know to happen - # on at least zsh 5.0.2 and 5.0.8) likely due to kill signals. - exec 2>/dev/null - - # When a zpty is deleted (using -d) all the zpty instances created before - # the one being deleted receive a SIGHUP, unless we catch it, the async - # worker would simply exit (stop working) even though visible in the list - # of zpty's (zpty -L). This has been fixed around the time of Zsh 5.4 - # (not released). - if ! is-at-least 5.4.1; then - TRAPHUP() { - return 0 # Return 0, indicating signal was handled. - } - fi - - local -A storage - local unique=0 - local notify_parent=0 - local parent_pid=0 - local coproc_pid=0 - local processing=0 - - local -a zsh_hooks zsh_hook_functions - zsh_hooks=(chpwd periodic precmd preexec zshexit zshaddhistory) - zsh_hook_functions=(${^zsh_hooks}_functions) - unfunction $zsh_hooks &>/dev/null # Deactivate all zsh hooks inside the worker. - unset $zsh_hook_functions # And hooks with registered functions. - unset zsh_hooks zsh_hook_functions # Cleanup. - - close_idle_coproc() { - local -a pids - pids=(${${(v)jobstates##*:*:}%\=*}) - - # If coproc (cat) is the only child running, we close it to avoid - # leaving it running indefinitely and cluttering the process tree. - if (( ! processing )) && [[ $#pids = 1 ]] && [[ $coproc_pid = $pids[1] ]]; then - coproc : - coproc_pid=0 - fi - } - - child_exit() { - close_idle_coproc - - # On older version of zsh (pre 5.2) we notify the parent through a - # SIGWINCH signal because `zpty` did not return a file descriptor (fd) - # prior to that. - if (( notify_parent )); then - # We use SIGWINCH for compatibility with older versions of zsh - # (pre 5.1.1) where other signals (INFO, ALRM, USR1, etc.) could - # cause a deadlock in the shell under certain circumstances. - kill -WINCH $parent_pid - fi - } - - # Register a SIGCHLD trap to handle the completion of child processes. - trap child_exit CHLD - - # Process option parameters passed to worker. - while getopts "np:uz" opt; do - case $opt in - n) notify_parent=1;; - p) parent_pid=$OPTARG;; - u) unique=1;; - z) notify_parent=0;; # Uses ZLE watcher instead. - esac - done - - # Terminate all running jobs, note that this function does not - # reinstall the child trap. - terminate_jobs() { - trap - CHLD # Ignore child exits during kill. - coproc : # Quit coproc. - coproc_pid=0 # Reset pid. - - if is-at-least 5.4.1; then - trap '' HUP # Catch the HUP sent to this process. - kill -HUP -$$ # Send to entire process group. - trap - HUP # Disable HUP trap. - else - # We already handle HUP for Zsh < 5.4.1. - kill -HUP -$$ # Send to entire process group. - fi - } - - killjobs() { - local tok - local -a pids - pids=(${${(v)jobstates##*:*:}%\=*}) - - # No need to send SIGHUP if no jobs are running. - (( $#pids == 0 )) && continue - (( $#pids == 1 )) && [[ $coproc_pid = $pids[1] ]] && continue - - # Grab lock to prevent half-written output in case a child - # process is in the middle of writing to stdin during kill. - (( coproc_pid )) && read -r -k 1 -p tok - - terminate_jobs - trap child_exit CHLD # Reinstall child trap. - } - - local request do_eval=0 - local -a cmd - while :; do - # Wait for jobs sent by async_job. - read -r -d $'\0' request || { - # Unknown error occurred while reading from stdin, the zpty - # worker is likely in a broken state, so we shut down. - terminate_jobs - - # Stdin is broken and in case this was an unintended - # crash, we try to report it as a last hurrah. - print -r -n $'\0'"'[async]'" $(( 127 + 3 )) "''" 0 "'$0:$LINENO: zpty fd died, exiting'"$'\0' - - # We use `return` to abort here because using `exit` may - # result in an infinite loop that never exits and, as a - # result, high CPU utilization. - return $(( 127 + 1 )) - } - - # We need to clean the input here because sometimes when a zpty - # has died and been respawned, messages will be prefixed with a - # carraige return (\r, or \C-M). - request=${request#$'\C-M'} - - # Check for non-job commands sent to worker - case $request in - _killjobs) killjobs; continue;; - _async_eval*) do_eval=1;; - esac - - # Parse the request using shell parsing (z) to allow commands - # to be parsed from single strings and multi-args alike. - cmd=("${(z)request}") - - # Name of the job (first argument). - local job=$cmd[1] - - # Check if a worker should perform unique jobs, unless - # this is an eval since they run synchronously. - if (( !do_eval )) && (( unique )); then - # Check if a previous job is still running, if yes, - # skip this job and let the previous one finish. - for pid in ${${(v)jobstates##*:*:}%\=*}; do - if [[ ${storage[$job]} == $pid ]]; then - continue 2 - fi - done - fi - - # Guard against closing coproc from trap before command has started. - processing=1 - - # Because we close the coproc after the last job has completed, we must - # recreate it when there are no other jobs running. - if (( ! coproc_pid )); then - # Use coproc as a mutex for synchronized output between children. - coproc cat - coproc_pid="$!" - # Insert token into coproc - print -n -p "t" - fi - - if (( do_eval )); then - shift cmd # Strip _async_eval from cmd. - _async_eval $cmd - else - # Run job in background, completed jobs are printed to stdout. - _async_job $cmd & - # Store pid because zsh job manager is extremely unflexible (show jobname as non-unique '$job')... - storage[$job]="$!" - fi - - processing=0 # Disable guard. - - if (( do_eval )); then - do_eval=0 - - # When there are no active jobs we can't rely on the CHLD trap to - # manage the coproc lifetime. - close_idle_coproc - fi - done -} - -# -# Get results from finished jobs and pass it to the to callback function. This is the only way to reliably return the -# job name, return code, output and execution time and with minimal effort. -# -# If the async process buffer becomes corrupt, the callback will be invoked with the first argument being `[async]` (job -# name), non-zero return code and fifth argument describing the error (stderr). -# -# usage: -# async_process_results <worker_name> <callback_function> -# -# callback_function is called with the following parameters: -# $1 = job name, e.g. the function passed to async_job -# $2 = return code -# $3 = resulting stdout from execution -# $4 = execution time, floating point e.g. 2.05 seconds -# $5 = resulting stderr from execution -# $6 = has next result in buffer (0 = buffer empty, 1 = yes) -# -async_process_results() { - setopt localoptions unset noshwordsplit noksharrays noposixidentifiers noposixstrings - - local worker=$1 - local callback=$2 - local caller=$3 - local -a items - local null=$'\0' data - integer -l len pos num_processed has_next - - typeset -gA ASYNC_PROCESS_BUFFER - - # Read output from zpty and parse it if available. - while zpty -r -t $worker data 2>/dev/null; do - ASYNC_PROCESS_BUFFER[$worker]+=$data - len=${#ASYNC_PROCESS_BUFFER[$worker]} - pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). - - # Keep going until we find a NULL-character. - if (( ! len )) || (( pos > len )); then - continue - fi - - while (( pos <= len )); do - # Take the content from the beginning, until the NULL-character and - # perform shell parsing (z) and unquoting (Q) as an array (@). - items=("${(@Q)${(z)ASYNC_PROCESS_BUFFER[$worker][1,$pos-1]}}") - - # Remove the extracted items from the buffer. - ASYNC_PROCESS_BUFFER[$worker]=${ASYNC_PROCESS_BUFFER[$worker][$pos+1,$len]} - - len=${#ASYNC_PROCESS_BUFFER[$worker]} - if (( len > 1 )); then - pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). - fi - - has_next=$(( len != 0 )) - if (( $#items == 5 )); then - items+=($has_next) - $callback "${(@)items}" # Send all parsed items to the callback. - (( num_processed++ )) - elif [[ -z $items ]]; then - # Empty items occur between results due to double-null ($'\0\0') - # caused by commands being both pre and suffixed with null. - else - # In case of corrupt data, invoke callback with *async* as job - # name, non-zero exit status and an error message on stderr. - $callback "[async]" 1 "" 0 "$0:$LINENO: error: bad format, got ${#items} items (${(q)items})" $has_next - fi - done - done - - (( num_processed )) && return 0 - - # Avoid printing exit value when `setopt printexitvalue` is active.` - [[ $caller = trap || $caller = watcher ]] && return 0 - - # No results were processed - return 1 -} - -# Watch worker for output -_async_zle_watcher() { - setopt localoptions noshwordsplit - typeset -gA ASYNC_PTYS ASYNC_CALLBACKS - local worker=$ASYNC_PTYS[$1] - local callback=$ASYNC_CALLBACKS[$worker] - - if [[ -n $2 ]]; then - # from man zshzle(1): - # `hup' for a disconnect, `nval' for a closed or otherwise - # invalid descriptor, or `err' for any other condition. - # Systems that support only the `select' system call always use - # `err'. - - # this has the side effect to unregister the broken file descriptor - async_stop_worker $worker - - if [[ -n $callback ]]; then - $callback '[async]' 2 "" 0 "$0:$LINENO: error: fd for $worker failed: zle -F $1 returned error $2" 0 - fi - return - fi; - - if [[ -n $callback ]]; then - async_process_results $worker $callback watcher - fi -} - -_async_send_job() { - setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings - - local caller=$1 - local worker=$2 - shift 2 - - zpty -t $worker &>/dev/null || { - typeset -gA ASYNC_CALLBACKS - local callback=$ASYNC_CALLBACKS[$worker] - - if [[ -n $callback ]]; then - $callback '[async]' 3 "" 0 "$0:$LINENO: error: no such worker: $worker" 0 - else - print -u2 "$caller: no such async worker: $worker" - fi - return 1 - } - - zpty -w $worker "$@"$'\0' -} - -# -# Start a new asynchronous job on specified worker, assumes the worker is running. -# -# usage: -# async_job <worker_name> <my_function> [<function_params>] -# -async_job() { - setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings - - local worker=$1; shift - - local -a cmd - cmd=("$@") - if (( $#cmd > 1 )); then - cmd=(${(q)cmd}) # Quote special characters in multi argument commands. - fi - - _async_send_job $0 $worker "$cmd" -} - -# -# Evaluate a command (like async_job) inside the async worker, then worker environment can be manipulated. For example, -# issuing a cd command will change the PWD of the worker which will then be inherited by all future async jobs. -# -# Output will be returned via callback, job name will be [async/eval]. -# -# usage: -# async_worker_eval <worker_name> <my_function> [<function_params>] -# -async_worker_eval() { - setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings - - local worker=$1; shift - - local -a cmd - cmd=("$@") - if (( $#cmd > 1 )); then - cmd=(${(q)cmd}) # Quote special characters in multi argument commands. - fi - - # Quote the cmd in case RC_EXPAND_PARAM is set. - _async_send_job $0 $worker "_async_eval $cmd" -} - -# This function traps notification signals and calls all registered callbacks -_async_notify_trap() { - setopt localoptions noshwordsplit - - local k - for k in ${(k)ASYNC_CALLBACKS}; do - async_process_results $k ${ASYNC_CALLBACKS[$k]} trap - done -} - -# -# Register a callback for completed jobs. As soon as a job is finnished, async_process_results will be called with the -# specified callback function. This requires that a worker is initialized with the -n (notify) option. -# -# usage: -# async_register_callback <worker_name> <callback_function> -# -async_register_callback() { - setopt localoptions noshwordsplit nolocaltraps - - typeset -gA ASYNC_PTYS ASYNC_CALLBACKS - local worker=$1; shift - - ASYNC_CALLBACKS[$worker]="$*" - - # Enable trap when the ZLE watcher is unavailable, allows - # workers to notify (via -n) when a job is done. - if [[ ! -o interactive ]] || [[ ! -o zle ]]; then - trap '_async_notify_trap' WINCH - elif [[ -o interactive ]] && [[ -o zle ]]; then - local fd w - for fd w in ${(@kv)ASYNC_PTYS}; do - if [[ $w == $worker ]]; then - zle -F $fd _async_zle_watcher # Register the ZLE handler. - break - fi - done - fi -} - -# -# Unregister the callback for a specific worker. -# -# usage: -# async_unregister_callback <worker_name> -# -async_unregister_callback() { - typeset -gA ASYNC_CALLBACKS - - unset "ASYNC_CALLBACKS[$1]" -} - -# -# Flush all current jobs running on a worker. This will terminate any and all running processes under the worker, use -# with caution. -# -# usage: -# async_flush_jobs <worker_name> -# -async_flush_jobs() { - setopt localoptions noshwordsplit - - local worker=$1; shift - - # Check if the worker exists - zpty -t $worker &>/dev/null || return 1 - - # Send kill command to worker - async_job $worker "_killjobs" - - # Clear the zpty buffer. - local junk - if zpty -r -t $worker junk '*'; then - (( ASYNC_DEBUG )) && print -n "async_flush_jobs $worker: ${(V)junk}" - while zpty -r -t $worker junk '*'; do - (( ASYNC_DEBUG )) && print -n "${(V)junk}" - done - (( ASYNC_DEBUG )) && print - fi - - # Finally, clear the process buffer in case of partially parsed responses. - typeset -gA ASYNC_PROCESS_BUFFER - unset "ASYNC_PROCESS_BUFFER[$worker]" -} - -# -# Start a new async worker with optional parameters, a worker can be told to only run unique tasks and to notify a -# process when tasks are complete. -# -# usage: -# async_start_worker <worker_name> [-u] [-n] [-p <pid>] -# -# opts: -# -u unique (only unique job names can run) -# -n notify through SIGWINCH signal -# -p pid to notify (defaults to current pid) -# -async_start_worker() { - setopt localoptions noshwordsplit noclobber - - local worker=$1; shift - local -a args - args=("$@") - zpty -t $worker &>/dev/null && return - - typeset -gA ASYNC_PTYS - typeset -h REPLY - typeset has_xtrace=0 - - if [[ -o interactive ]] && [[ -o zle ]]; then - # Inform the worker to ignore the notify flag and that we're - # using a ZLE watcher instead. - args+=(-z) - - if (( ! ASYNC_ZPTY_RETURNS_FD )); then - # When zpty doesn't return a file descriptor (on older versions of zsh) - # we try to guess it anyway. - integer -l zptyfd - exec {zptyfd}>&1 # Open a new file descriptor (above 10). - exec {zptyfd}>&- # Close it so it's free to be used by zpty. - fi - fi - - # Workaround for stderr in the main shell sometimes (incorrectly) being - # reassigned to /dev/null by the reassignment done inside the async - # worker. - # See https://github.com/mafredri/zsh-async/issues/35. - integer errfd=-1 - - # Redirect of errfd is broken on zsh 5.0.2. - if is-at-least 5.0.8; then - exec {errfd}>&2 - fi - - # Make sure async worker is started without xtrace - # (the trace output interferes with the worker). - [[ -o xtrace ]] && { - has_xtrace=1 - unsetopt xtrace - } - - if (( errfd != -1 )); then - zpty -b $worker _async_worker -p $$ $args 2>&$errfd - else - zpty -b $worker _async_worker -p $$ $args - fi - local ret=$? - - # Re-enable it if it was enabled, for debugging. - (( has_xtrace )) && setopt xtrace - (( errfd != -1 )) && exec {errfd}>& - - - if (( ret )); then - async_stop_worker $worker - return 1 - fi - - if ! is-at-least 5.0.8; then - # For ZSH versions older than 5.0.8 we delay a bit to give - # time for the worker to start before issuing commands, - # otherwise it will not be ready to receive them. - sleep 0.001 - fi - - if [[ -o interactive ]] && [[ -o zle ]]; then - if (( ! ASYNC_ZPTY_RETURNS_FD )); then - REPLY=$zptyfd # Use the guessed value for the file desciptor. - fi - - ASYNC_PTYS[$REPLY]=$worker # Map the file desciptor to the worker. - fi -} - -# -# Stop one or multiple workers that are running, all unfetched and incomplete work will be lost. -# -# usage: -# async_stop_worker <worker_name_1> [<worker_name_2>] -# -async_stop_worker() { - setopt localoptions noshwordsplit - - local ret=0 worker k v - for worker in $@; do - # Find and unregister the zle handler for the worker - for k v in ${(@kv)ASYNC_PTYS}; do - if [[ $v == $worker ]]; then - zle -F $k - unset "ASYNC_PTYS[$k]" - fi - done - async_unregister_callback $worker - zpty -d $worker 2>/dev/null || ret=$? - - # Clear any partial buffers. - typeset -gA ASYNC_PROCESS_BUFFER - unset "ASYNC_PROCESS_BUFFER[$worker]" - done - - return $ret -} - -# -# Initialize the required modules for zsh-async. To be called before using the zsh-async library. -# -# usage: -# async_init -# -async_init() { - (( ASYNC_INIT_DONE )) && return - typeset -g ASYNC_INIT_DONE=1 - - zmodload zsh/zpty - zmodload zsh/datetime - - # Load is-at-least for reliable version check. - autoload -Uz is-at-least - - # Check if zsh/zpty returns a file descriptor or not, - # shell must also be interactive with zle enabled. - typeset -g ASYNC_ZPTY_RETURNS_FD=0 - [[ -o interactive ]] && [[ -o zle ]] && { - typeset -h REPLY - zpty _async_test : - (( REPLY )) && ASYNC_ZPTY_RETURNS_FD=1 - zpty -d _async_test - } -} - -async() { - async_init -} - -async "$@" diff --git a/.zsh/themes/spaceship-prompt/async.zsh b/.zsh/themes/spaceship-prompt/async.zsh deleted file mode 100644 index 1a73d08..0000000 --- a/.zsh/themes/spaceship-prompt/async.zsh +++ /dev/null @@ -1,669 +0,0 @@ -#!/usr/bin/env zsh - -# -# zsh-async -# -# version: v1.8.5 -# author: Mathias Fredriksson -# url: https://github.com/mafredri/zsh-async -# - -typeset -g ASYNC_VERSION=1.8.5 -# Produce debug output from zsh-async when set to 1. -typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0} - -# Execute commands that can manipulate the environment inside the async worker. Return output via callback. -_async_eval() { - local ASYNC_JOB_NAME - # Rename job to _async_eval and redirect all eval output to cat running - # in _async_job. Here, stdout and stderr are not separated for - # simplicity, this could be improved in the future. - { - eval "$@" - } &> >(ASYNC_JOB_NAME=[async/eval] _async_job 'cat') -} - -# Wrapper for jobs executed by the async worker, gives output in parseable format with execution time -_async_job() { - # Disable xtrace as it would mangle the output. - setopt localoptions noxtrace - - # Store start time for job. - float -F duration=$EPOCHREALTIME - - # Run the command and capture both stdout (`eval`) and stderr (`cat`) in - # separate subshells. When the command is complete, we grab write lock - # (mutex token) and output everything except stderr inside the command - # block, after the command block has completed, the stdin for `cat` is - # closed, causing stderr to be appended with a $'\0' at the end to mark the - # end of output from this job. - local jobname=${ASYNC_JOB_NAME:-$1} out - out="$( - local stdout stderr ret tok - { - stdout=$(eval "$@") - ret=$? - duration=$(( EPOCHREALTIME - duration )) # Calculate duration. - - print -r -n - $'\0'${(q)jobname} $ret ${(q)stdout} $duration - } 2> >(stderr=$(cat) && print -r -n - " "${(q)stderr}$'\0') - )" - if [[ $out != $'\0'*$'\0' ]]; then - # Corrupted output (aborted job?), skipping. - return - fi - - # Grab mutex lock, stalls until token is available. - read -r -k 1 -p tok || return 1 - - # Return output (<job_name> <return_code> <stdout> <duration> <stderr>). - print -r -n - "$out" - - # Unlock mutex by inserting a token. - print -n -p $tok -} - -# The background worker manages all tasks and runs them without interfering with other processes -_async_worker() { - # Reset all options to defaults inside async worker. - emulate -R zsh - - # Make sure monitor is unset to avoid printing the - # pids of child processes. - unsetopt monitor - - # Redirect stderr to `/dev/null` in case unforseen errors produced by the - # worker. For example: `fork failed: resource temporarily unavailable`. - # Some older versions of zsh might also print malloc errors (know to happen - # on at least zsh 5.0.2 and 5.0.8) likely due to kill signals. - exec 2>/dev/null - - # When a zpty is deleted (using -d) all the zpty instances created before - # the one being deleted receive a SIGHUP, unless we catch it, the async - # worker would simply exit (stop working) even though visible in the list - # of zpty's (zpty -L). This has been fixed around the time of Zsh 5.4 - # (not released). - if ! is-at-least 5.4.1; then - TRAPHUP() { - return 0 # Return 0, indicating signal was handled. - } - fi - - local -A storage - local unique=0 - local notify_parent=0 - local parent_pid=0 - local coproc_pid=0 - local processing=0 - - local -a zsh_hooks zsh_hook_functions - zsh_hooks=(chpwd periodic precmd preexec zshexit zshaddhistory) - zsh_hook_functions=(${^zsh_hooks}_functions) - unfunction $zsh_hooks &>/dev/null # Deactivate all zsh hooks inside the worker. - unset $zsh_hook_functions # And hooks with registered functions. - unset zsh_hooks zsh_hook_functions # Cleanup. - - close_idle_coproc() { - local -a pids - pids=(${${(v)jobstates##*:*:}%\=*}) - - # If coproc (cat) is the only child running, we close it to avoid - # leaving it running indefinitely and cluttering the process tree. - if (( ! processing )) && [[ $#pids = 1 ]] && [[ $coproc_pid = $pids[1] ]]; then - coproc : - coproc_pid=0 - fi - } - - child_exit() { - close_idle_coproc - - # On older version of zsh (pre 5.2) we notify the parent through a - # SIGWINCH signal because `zpty` did not return a file descriptor (fd) - # prior to that. - if (( notify_parent )); then - # We use SIGWINCH for compatibility with older versions of zsh - # (pre 5.1.1) where other signals (INFO, ALRM, USR1, etc.) could - # cause a deadlock in the shell under certain circumstances. - kill -WINCH $parent_pid - fi - } - - # Register a SIGCHLD trap to handle the completion of child processes. - trap child_exit CHLD - - # Process option parameters passed to worker. - while getopts "np:uz" opt; do - case $opt in - n) notify_parent=1;; - p) parent_pid=$OPTARG;; - u) unique=1;; - z) notify_parent=0;; # Uses ZLE watcher instead. - esac - done - - # Terminate all running jobs, note that this function does not - # reinstall the child trap. - terminate_jobs() { - trap - CHLD # Ignore child exits during kill. - coproc : # Quit coproc. - coproc_pid=0 # Reset pid. - - if is-at-least 5.4.1; then - trap '' HUP # Catch the HUP sent to this process. - kill -HUP -$$ # Send to entire process group. - trap - HUP # Disable HUP trap. - else - # We already handle HUP for Zsh < 5.4.1. - kill -HUP -$$ # Send to entire process group. - fi - } - - killjobs() { - local tok - local -a pids - pids=(${${(v)jobstates##*:*:}%\=*}) - - # No need to send SIGHUP if no jobs are running. - (( $#pids == 0 )) && continue - (( $#pids == 1 )) && [[ $coproc_pid = $pids[1] ]] && continue - - # Grab lock to prevent half-written output in case a child - # process is in the middle of writing to stdin during kill. - (( coproc_pid )) && read -r -k 1 -p tok - - terminate_jobs - trap child_exit CHLD # Reinstall child trap. - } - - local request do_eval=0 - local -a cmd - while :; do - # Wait for jobs sent by async_job. - read -r -d $'\0' request || { - # Unknown error occurred while reading from stdin, the zpty - # worker is likely in a broken state, so we shut down. - terminate_jobs - - # Stdin is broken and in case this was an unintended - # crash, we try to report it as a last hurrah. - print -r -n $'\0'"'[async]'" $(( 127 + 3 )) "''" 0 "'$0:$LINENO: zpty fd died, exiting'"$'\0' - - # We use `return` to abort here because using `exit` may - # result in an infinite loop that never exits and, as a - # result, high CPU utilization. - return $(( 127 + 1 )) - } - - # We need to clean the input here because sometimes when a zpty - # has died and been respawned, messages will be prefixed with a - # carraige return (\r, or \C-M). - request=${request#$'\C-M'} - - # Check for non-job commands sent to worker - case $request in - _killjobs) killjobs; continue;; - _async_eval*) do_eval=1;; - esac - - # Parse the request using shell parsing (z) to allow commands - # to be parsed from single strings and multi-args alike. - cmd=("${(z)request}") - - # Name of the job (first argument). - local job=$cmd[1] - - # Check if a worker should perform unique jobs, unless - # this is an eval since they run synchronously. - if (( !do_eval )) && (( unique )); then - # Check if a previous job is still running, if yes, - # skip this job and let the previous one finish. - for pid in ${${(v)jobstates##*:*:}%\=*}; do - if [[ ${storage[$job]} == $pid ]]; then - continue 2 - fi - done - fi - - # Guard against closing coproc from trap before command has started. - processing=1 - - # Because we close the coproc after the last job has completed, we must - # recreate it when there are no other jobs running. - if (( ! coproc_pid )); then - # Use coproc as a mutex for synchronized output between children. - coproc cat - coproc_pid="$!" - # Insert token into coproc - print -n -p "t" - fi - - if (( do_eval )); then - shift cmd # Strip _async_eval from cmd. - _async_eval $cmd - else - # Run job in background, completed jobs are printed to stdout. - _async_job $cmd & - # Store pid because zsh job manager is extremely unflexible (show jobname as non-unique '$job')... - storage[$job]="$!" - fi - - processing=0 # Disable guard. - - if (( do_eval )); then - do_eval=0 - - # When there are no active jobs we can't rely on the CHLD trap to - # manage the coproc lifetime. - close_idle_coproc - fi - done -} - -# -# Get results from finished jobs and pass it to the to callback function. This is the only way to reliably return the -# job name, return code, output and execution time and with minimal effort. -# -# If the async process buffer becomes corrupt, the callback will be invoked with the first argument being `[async]` (job -# name), non-zero return code and fifth argument describing the error (stderr). -# -# usage: -# async_process_results <worker_name> <callback_function> -# -# callback_function is called with the following parameters: -# $1 = job name, e.g. the function passed to async_job -# $2 = return code -# $3 = resulting stdout from execution -# $4 = execution time, floating point e.g. 2.05 seconds -# $5 = resulting stderr from execution -# $6 = has next result in buffer (0 = buffer empty, 1 = yes) -# -async_process_results() { - setopt localoptions unset noshwordsplit noksharrays noposixidentifiers noposixstrings - - local worker=$1 - local callback=$2 - local caller=$3 - local -a items - local null=$'\0' data - integer -l len pos num_processed has_next - - typeset -gA ASYNC_PROCESS_BUFFER - - # Read output from zpty and parse it if available. - while zpty -r -t $worker data 2>/dev/null; do - ASYNC_PROCESS_BUFFER[$worker]+=$data - len=${#ASYNC_PROCESS_BUFFER[$worker]} - pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). - - # Keep going until we find a NULL-character. - if (( ! len )) || (( pos > len )); then - continue - fi - - while (( pos <= len )); do - # Take the content from the beginning, until the NULL-character and - # perform shell parsing (z) and unquoting (Q) as an array (@). - items=("${(@Q)${(z)ASYNC_PROCESS_BUFFER[$worker][1,$pos-1]}}") - - # Remove the extracted items from the buffer. - ASYNC_PROCESS_BUFFER[$worker]=${ASYNC_PROCESS_BUFFER[$worker][$pos+1,$len]} - - len=${#ASYNC_PROCESS_BUFFER[$worker]} - if (( len > 1 )); then - pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). - fi - - has_next=$(( len != 0 )) - if (( $#items == 5 )); then - items+=($has_next) - $callback "${(@)items}" # Send all parsed items to the callback. - (( num_processed++ )) - elif [[ -z $items ]]; then - # Empty items occur between results due to double-null ($'\0\0') - # caused by commands being both pre and suffixed with null. - else - # In case of corrupt data, invoke callback with *async* as job - # name, non-zero exit status and an error message on stderr. - $callback "[async]" 1 "" 0 "$0:$LINENO: error: bad format, got ${#items} items (${(q)items})" $has_next - fi - done - done - - (( num_processed )) && return 0 - - # Avoid printing exit value when `setopt printexitvalue` is active.` - [[ $caller = trap || $caller = watcher ]] && return 0 - - # No results were processed - return 1 -} - -# Watch worker for output -_async_zle_watcher() { - setopt localoptions noshwordsplit - typeset -gA ASYNC_PTYS ASYNC_CALLBACKS - local worker=$ASYNC_PTYS[$1] - local callback=$ASYNC_CALLBACKS[$worker] - - if [[ -n $2 ]]; then - # from man zshzle(1): - # `hup' for a disconnect, `nval' for a closed or otherwise - # invalid descriptor, or `err' for any other condition. - # Systems that support only the `select' system call always use - # `err'. - - # this has the side effect to unregister the broken file descriptor - async_stop_worker $worker - - if [[ -n $callback ]]; then - $callback '[async]' 2 "" 0 "$0:$LINENO: error: fd for $worker failed: zle -F $1 returned error $2" 0 - fi - return - fi; - - if [[ -n $callback ]]; then - async_process_results $worker $callback watcher - fi -} - -_async_send_job() { - setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings - - local caller=$1 - local worker=$2 - shift 2 - - zpty -t $worker &>/dev/null || { - typeset -gA ASYNC_CALLBACKS - local callback=$ASYNC_CALLBACKS[$worker] - - if [[ -n $callback ]]; then - $callback '[async]' 3 "" 0 "$0:$LINENO: error: no such worker: $worker" 0 - else - print -u2 "$caller: no such async worker: $worker" - fi - return 1 - } - - zpty -w $worker "$@"$'\0' -} - -# -# Start a new asynchronous job on specified worker, assumes the worker is running. -# -# usage: -# async_job <worker_name> <my_function> [<function_params>] -# -async_job() { - setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings - - local worker=$1; shift - - local -a cmd - cmd=("$@") - if (( $#cmd > 1 )); then - cmd=(${(q)cmd}) # Quote special characters in multi argument commands. - fi - - _async_send_job $0 $worker "$cmd" -} - -# -# Evaluate a command (like async_job) inside the async worker, then worker environment can be manipulated. For example, -# issuing a cd command will change the PWD of the worker which will then be inherited by all future async jobs. -# -# Output will be returned via callback, job name will be [async/eval]. -# -# usage: -# async_worker_eval <worker_name> <my_function> [<function_params>] -# -async_worker_eval() { - setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings - - local worker=$1; shift - - local -a cmd - cmd=("$@") - if (( $#cmd > 1 )); then - cmd=(${(q)cmd}) # Quote special characters in multi argument commands. - fi - - # Quote the cmd in case RC_EXPAND_PARAM is set. - _async_send_job $0 $worker "_async_eval $cmd" -} - -# This function traps notification signals and calls all registered callbacks -_async_notify_trap() { - setopt localoptions noshwordsplit - - local k - for k in ${(k)ASYNC_CALLBACKS}; do - async_process_results $k ${ASYNC_CALLBACKS[$k]} trap - done -} - -# -# Register a callback for completed jobs. As soon as a job is finnished, async_process_results will be called with the -# specified callback function. This requires that a worker is initialized with the -n (notify) option. -# -# usage: -# async_register_callback <worker_name> <callback_function> -# -async_register_callback() { - setopt localoptions noshwordsplit nolocaltraps - - typeset -gA ASYNC_PTYS ASYNC_CALLBACKS - local worker=$1; shift - - ASYNC_CALLBACKS[$worker]="$*" - - # Enable trap when the ZLE watcher is unavailable, allows - # workers to notify (via -n) when a job is done. - if [[ ! -o interactive ]] || [[ ! -o zle ]]; then - trap '_async_notify_trap' WINCH - elif [[ -o interactive ]] && [[ -o zle ]]; then - local fd w - for fd w in ${(@kv)ASYNC_PTYS}; do - if [[ $w == $worker ]]; then - zle -F $fd _async_zle_watcher # Register the ZLE handler. - break - fi - done - fi -} - -# -# Unregister the callback for a specific worker. -# -# usage: -# async_unregister_callback <worker_name> -# -async_unregister_callback() { - typeset -gA ASYNC_CALLBACKS - - unset "ASYNC_CALLBACKS[$1]" -} - -# -# Flush all current jobs running on a worker. This will terminate any and all running processes under the worker, use -# with caution. -# -# usage: -# async_flush_jobs <worker_name> -# -async_flush_jobs() { - setopt localoptions noshwordsplit - - local worker=$1; shift - - # Check if the worker exists - zpty -t $worker &>/dev/null || return 1 - - # Send kill command to worker - async_job $worker "_killjobs" - - # Clear the zpty buffer. - local junk - if zpty -r -t $worker junk '*'; then - (( ASYNC_DEBUG )) && print -n "async_flush_jobs $worker: ${(V)junk}" - while zpty -r -t $worker junk '*'; do - (( ASYNC_DEBUG )) && print -n "${(V)junk}" - done - (( ASYNC_DEBUG )) && print - fi - - # Finally, clear the process buffer in case of partially parsed responses. - typeset -gA ASYNC_PROCESS_BUFFER - unset "ASYNC_PROCESS_BUFFER[$worker]" -} - -# -# Start a new async worker with optional parameters, a worker can be told to only run unique tasks and to notify a -# process when tasks are complete. -# -# usage: -# async_start_worker <worker_name> [-u] [-n] [-p <pid>] -# -# opts: -# -u unique (only unique job names can run) -# -n notify through SIGWINCH signal -# -p pid to notify (defaults to current pid) -# -async_start_worker() { - setopt localoptions noshwordsplit noclobber - - local worker=$1; shift - local -a args - args=("$@") - zpty -t $worker &>/dev/null && return - - typeset -gA ASYNC_PTYS - typeset -h REPLY - typeset has_xtrace=0 - - if [[ -o interactive ]] && [[ -o zle ]]; then - # Inform the worker to ignore the notify flag and that we're - # using a ZLE watcher instead. - args+=(-z) - - if (( ! ASYNC_ZPTY_RETURNS_FD )); then - # When zpty doesn't return a file descriptor (on older versions of zsh) - # we try to guess it anyway. - integer -l zptyfd - exec {zptyfd}>&1 # Open a new file descriptor (above 10). - exec {zptyfd}>&- # Close it so it's free to be used by zpty. - fi - fi - - # Workaround for stderr in the main shell sometimes (incorrectly) being - # reassigned to /dev/null by the reassignment done inside the async - # worker. - # See https://github.com/mafredri/zsh-async/issues/35. - integer errfd=-1 - - # Redirect of errfd is broken on zsh 5.0.2. - if is-at-least 5.0.8; then - exec {errfd}>&2 - fi - - # Make sure async worker is started without xtrace - # (the trace output interferes with the worker). - [[ -o xtrace ]] && { - has_xtrace=1 - unsetopt xtrace - } - - if (( errfd != -1 )); then - zpty -b $worker _async_worker -p $$ $args 2>&$errfd - else - zpty -b $worker _async_worker -p $$ $args - fi - local ret=$? - - # Re-enable it if it was enabled, for debugging. - (( has_xtrace )) && setopt xtrace - (( errfd != -1 )) && exec {errfd}>& - - - if (( ret )); then - async_stop_worker $worker - return 1 - fi - - if ! is-at-least 5.0.8; then - # For ZSH versions older than 5.0.8 we delay a bit to give - # time for the worker to start before issuing commands, - # otherwise it will not be ready to receive them. - sleep 0.001 - fi - - if [[ -o interactive ]] && [[ -o zle ]]; then - if (( ! ASYNC_ZPTY_RETURNS_FD )); then - REPLY=$zptyfd # Use the guessed value for the file desciptor. - fi - - ASYNC_PTYS[$REPLY]=$worker # Map the file desciptor to the worker. - fi -} - -# -# Stop one or multiple workers that are running, all unfetched and incomplete work will be lost. -# -# usage: -# async_stop_worker <worker_name_1> [<worker_name_2>] -# -async_stop_worker() { - setopt localoptions noshwordsplit - - local ret=0 worker k v - for worker in $@; do - # Find and unregister the zle handler for the worker - for k v in ${(@kv)ASYNC_PTYS}; do - if [[ $v == $worker ]]; then - zle -F $k - unset "ASYNC_PTYS[$k]" - fi - done - async_unregister_callback $worker - zpty -d $worker 2>/dev/null || ret=$? - - # Clear any partial buffers. - typeset -gA ASYNC_PROCESS_BUFFER - unset "ASYNC_PROCESS_BUFFER[$worker]" - done - - return $ret -} - -# -# Initialize the required modules for zsh-async. To be called before using the zsh-async library. -# -# usage: -# async_init -# -async_init() { - (( ASYNC_INIT_DONE )) && return - typeset -g ASYNC_INIT_DONE=1 - - zmodload zsh/zpty - zmodload zsh/datetime - - # Load is-at-least for reliable version check. - autoload -Uz is-at-least - - # Check if zsh/zpty returns a file descriptor or not, - # shell must also be interactive with zle enabled. - typeset -g ASYNC_ZPTY_RETURNS_FD=0 - [[ -o interactive ]] && [[ -o zle ]] && { - typeset -h REPLY - zpty _async_test : - (( REPLY )) && ASYNC_ZPTY_RETURNS_FD=1 - zpty -d _async_test - } -} - -async() { - async_init -} - -async "$@" diff --git a/.zsh/themes/spaceship-prompt/crowdin.yml b/.zsh/themes/spaceship-prompt/crowdin.yml deleted file mode 100644 index f1ee265..0000000 --- a/.zsh/themes/spaceship-prompt/crowdin.yml +++ /dev/null @@ -1,12 +0,0 @@ -pull_request_title: 'docs(i18n): New Crowdin updates' -pull_request_labels: - - docs - - translations -commit_message: 'docs(i18n): New translations for %original_file_name% (%language%)' -append_commit_message: false -files: - - source: /docs/**/*.md - translation: /docs/**/%file_name%.%two_letters_code%.%file_extension% - ignore: - - /docs/**/%file_name%.%two_letters_code%.%file_extension% - - /docs/blog/**/* diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.de.md b/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.de.md deleted file mode 100644 index 22346ba..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.de.md +++ /dev/null @@ -1,135 +0,0 @@ -# Creating a custom section - -This guide aims to help you create your first custom section. - -## Rules for sections - -Here are recommendations to follow when creating a section to maintain Spaceship slick and clean. - -### Section should not clutter the prompt - -Having too much in prompt looks ugly. It's better to keep it to a minimum of necessary information. - -* **Good:** `🚀 v1.2.3` -* **Bad:** `🚀 spasheship#c3BhY2VzaGlw` - -### Section should be worth to be aware of - -Is value changes quite often, so it needs to be shown in prompt? Would it be useful for other users? Maybe there's a reason to execute a command instead of cluttering prompt. - -* **Good:** git status/branch, runtime version via version manager, etc -* **Bad:** version of language-specific framework, settled projects versions, etc - -### Section should be fast - -If your section performs any heavy checking, find a way to make it faster. Use async rendering for performing heavy tasks. Section should be: - -* **Async:** if it executes external commands, perform complex calculations, reading large files -* **Sync:** if it checks command availability, checks the value of environment variable - -### Follow naming convention for options - -All options of prompt follow a specific pattern so that it is easy to remember: `SPACESHIP_SECTION_<OPTION>[_PROPERTY]`. The rule is simple: when naming new properties, keep unique parts of the name to the end. - -* **Good:** - ``` - SPACESHIP_GIT_STATUS_COLOR_BEHIND - SPACESHIP_GIT_STATUS_COLOR_DIVERGED - ``` -* **Bad:** - ``` - SPACESHIP_GIT_STATUS_BEHIND_COLOR - SPACESHIP_GIT_STATUS_DIVERGED_COLOR - ``` - - Here, `GIT_STATUS` is *section*, `COLOR` is *option* and `BEHIND` or `DIVERGED` is *property*. - -## Create a section - -The simplest way to create a section is to use a template repo for Spaceship section. - -[:fontawesome-brands-github: Use a section template](https://github.com/spaceship-prompt/spaceship-section ""){.md-button} - -This boilerplate repo contains a template for a section and its documentation, has configured release and testing workflow. Explore the repo to learn more. - -Open a [`spaceship-section.plugin.zsh` file](https://github.com/spaceship-prompt/spaceship-section/blob/main/spaceship-section.plugin.zsh) for a custom section example. - -## Typical section breakdown - -Below is an example of a typical section for Spaceship. Pay attention to a few crucial moments: - -- Define options for customization. Their names should start with `SPACESHIP_`. -- Every Spaceship section name should start with `spaceship_` (for example `spaceship_node`). This is a convention that is used to identify the section. -- Show section only where it's needed (in directories which contains specific files, when a specific command is available, etc). - -Sections are defined by [`spaceship::section` API](/api/section/). You can use [general purpose utilities](/api/utils/) for performing common tasks in a section. - -Typical section might look like this: - -```zsh -# -# Foobar -# -# Foobar is a supa-dupa cool tool for making you development easier. -# Link: https://www.foobar.xyz - -# ------------------------------------------------------------------------------ -# Configuration -# ------------------------------------------------------------------------------ - -SPACESHIP_FOOBAR_SHOW="${SPACESHIP_FOOBAR_SHOW=true}" -SPACESHIP_FOOBAR_ASYNC="${SPACESHIP_FOOBAR_ASYNC=true}" -SPACESHIP_FOOBAR_PREFIX="${SPACESHIP_FOOBAR_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" -SPACESHIP_FOOBAR_SUFFIX="${SPACESHIP_FOOBAR_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" -SPACESHIP_FOOBAR_SYMBOL="${SPACESHIP_FOOBAR_SYMBOL="🍷 "}" -SPACESHIP_FOOBAR_COLOR="${SPACESHIP_FOOBAR_COLOR="white"}" - -# ------------------------------------------------------------------------------ -# Section -# ------------------------------------------------------------------------------ - -# Show foobar status -# spaceship_ prefix before section's name is required! -# Otherwise this section won't be loaded. -spaceship_foobar() { - # If SPACESHIP_FOOBAR_SHOW is false, don't show foobar section - [[ $SPACESHIP_FOOBAR_SHOW == false ]] && return - - # Check if foobar command is available for execution - spaceship::exists foobar || return - - # Show foobar section only when there are foobar-specific files in current - # working directory. - - # spaceship::upsearch utility helps finding files up in the directory tree. - local is_foobar_context="$(spaceship::upsearch foobar.conf)" - # Here glob qualifiers are used to check if files with specific extension are - # present in directory. Read more about them here: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html - [[ -n "$is_foobar_context" || -n *.foo(#qN^/) || -n *.bar(#qN^/) ]] || return - - local foobar_version="$(foobar --version)" - - # Check if tool version is correct - [[ $tool_version == "system" ]] && return - - # Display foobar section - # spaceship::section utility composes sections. Flags are optional - spaceship::section::v4 \ - --color "$SPACESHIP_FOOBAR_COLOR" \ - --prefix "$SPACESHIP_FOOBAR_PREFIX" \ - --suffix "$SPACESHIP_FOOBAR_SUFFIX" \ - --symbol "$SPACESHIP_FOOBAR_SYMBOL" \ - "$foobar_status" -} -``` - -Take a look at [Contribution guidelines](//github.com/spaceship-prompt/spaceship-prompt/blob/master/CONTRIBUTING.md) for further information. - -## Share your section with others - -The next step is to share your section with the community. - -Open a discussion topic on our Discussion forum: - -[Add to Registry](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/docs/registry/external.json ""){.md-button} [Share on forum](https://github.com/spaceship-prompt/spaceship-prompt/discussions/new?category=show-and-tell&title=Section%20for%20[tool] ""){.md-button} diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.fr.md b/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.fr.md deleted file mode 100644 index 0d8045d..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.fr.md +++ /dev/null @@ -1,135 +0,0 @@ -# Créé une section spéciale - -Ce guide vise à vous aider à créer votre première section personnalisée. - -## Règles pour les sections - -Voici les recommandations à suivre lors de la création d'une section pour maintenir la fluidité et la propreté du vaisseau spatial. - -### La section ne doit pas encombrer l'invite - -Avoir trop en prompt semble laid. Il est préférable de le limiter au minimum des informations nécessaires. - -* **Bien :** `🚀 v1.2.3` -* **Mauvais :** `🚀 spasheship#c3BhY2VzaGlw` - -### La section devrait être utile pour être au courant de - -Les changements de valeur sont-ils assez fréquents, donc ils doivent être affichés rapidement ? Serait-il utile pour d'autres utilisateurs ? Peut-être qu'il y a une raison d'exécuter une commande au lieu de l'encombrement. - -* **Bon :** git statut/branche, version d'exécution via le gestionnaire de version, etc -* **Mauvaise :** version du cadre linguistique, des versions de projets réglées, etc - -### La section devrait être rapide - -Si votre section effectue un contrôle minutieux, trouvez un moyen de le rendre plus rapide. Utiliser un rendu asynchrone pour effectuer des tâches lourdes. La section devrait être rapide: - -* **Asynchro :** s'il exécute des commandes externes, effectue des calculs complexes, lisant des fichiers volumineux -* **Synchronisation :** si elle vérifie la disponibilité de la commande, vérifie la valeur de la variable d'environnement - -### Suivre la convention de nommage pour les options - -Toutes les options de l'invite suivent une pratique spécifique pour qu'il soit facile à retenir : `SPACESHIP_SECTION_<OPTION>[_PROPERTY]`. La règle est simple : lorsque vous nommez de nouvelles propriétés, gardez des parties uniques du nom jusqu'à la fin. - -* **Bon:** - ``` - SPACESHIP_GIT_STATUS_COLOR_BEHIND - SPACESHIP_GIT_STATUS_COLOR_DIVERGED - ``` -* **Mauvais:** - ``` - SPACESHIP_GIT_STATUS_BEHIND_COLOR - SPACESHIP_GIT_STATUS_DIVERGED_COLOR - ``` - - Ici, `GIT_STATUS` est *section*, `COLOR` est *option* et `BEHIND` ou `DIVERGÉ` est *propriété*. - -## Créer une section - -La façon la plus simple de créer une section est d'utiliser un dépôt de template pour la section Spaceship. - -[:fontawesome-brands-github: Utiliser un modèle de section](https://github.com/spaceship-prompt/spaceship-section ""){.md-button} - -Ce dépôt de boilerplate contient un modèle pour une section et sa documentation, a configuré la version et le flux de travail de test. Explorez le dépôt pour en savoir plus. - -Ouvrez un fichier [`spaceship-section.plugin.zsh`](https://github.com/spaceship-prompt/spaceship-section/blob/main/spaceship-section.plugin.zsh) pour un exemple de section personnalisée. - -## Répartition typique de la section - -Voici un exemple de section typique pour le vaisseau spatial. Faites attention à quelques moments cruciaux : - -- Définir les options pour la personnalisation. Leurs noms devraient commencer par `SPACESHIP_`. -- Chaque nom de section de vaisseau spatial doit commencer par `vaisseau spatial_` (par exemple `vaisseau spatial`). Il s'agit d'une convention qui sert à identifier la section. -- Afficher la section seulement là où elle est nécessaire (dans les répertoires qui contiennent des fichiers spécifiques, quand une commande spécifique est disponible, etc). - -Les sections sont définies par [`spaceship::section` API](/api/section/). Vous pouvez utiliser des [utilitaires généraux](/api/utils/) pour exécuter des tâches communes dans une section. - -Une configuration type pourrait ressembler à ceci : - -```zsh -# -# Foobar -# -# Foobar est un outil cool supa-dupa pour vous faciliter le développement. -# Link: https://www.foobar.xyz - -# ------------------------------------------------------------------------------ -# Configuration -# ------------------------------------------------------------------------------ - -SPACESHIP_FOOBAR_SHOW="${SPACESHIP_FOOBAR_SHOW=true}" -SPACESHIP_FOOBAR_ASYNC="${SPACESHIP_FOOBAR_ASYNC=true}" -SPACESHIP_FOOBAR_PREFIX="${SPACESHIP_FOOBAR_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" -SPACESHIP_FOOBAR_SUFFIX="${SPACESHIP_FOOBAR_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" -SPACESHIP_FOOBAR_SYMBOL="${SPACESHIP_FOOBAR_SYMBOL="🍷 "}" -SPACESHIP_FOOBAR_COLOR="${SPACESHIP_FOOBAR_COLOR="white"}" - -# ------------------------------------------------------------------------------ -# Section -# ------------------------------------------------------------------------------ - -# Show foobar status -# spaceship_ prefix before section's name is required! -# Sinon cette section ne sera pas chargée. -spaceship_foobar() { - # If SPACESHIP_FOOBAR_SHOW is false, don't show foobar section - [[ $SPACESHIP_FOOBAR_SHOW == false ]] && return - - # Check if foobar command is available for execution - spaceship::exists foobar || return - - # Show foobar section only when there are foobar-specific files in current - # working directory. - - # spaceship::upsearch utility helps finding files up in the directory tree. - local is_foobar_context="$(spaceship::upsearch foobar.conf)" - # Here glob qualifiers are used to check if files with specific extension are - # present in directory. Read more about them here: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html - [[ -n "$is_foobar_context" || -n *.foo(#qN^/) || -n *.bar(#qN^/) ]] || return - - local foobar_version="$(foobar --version)" - - # Check if tool version is correct - [[ $tool_version == "system" ]] && return - - # Display foobar section - # spaceship::section utility composes sections. Flags are optional - spaceship::section::v4 \ - --color "$SPACESHIP_FOOBAR_COLOR" \ - --prefix "$SPACESHIP_FOOBAR_PREFIX" \ - --suffix "$SPACESHIP_FOOBAR_SUFFIX" \ - --symbol "$SPACESHIP_FOOBAR_SYMBOL" \ - "$foobar_status" -} -``` - -Take a look at [Contribution guidelines](//github.com/spaceship-prompt/spaceship-prompt/blob/master/CONTRIBUTING.md) for further information. - -## Share your section with others - -The next step is to share your section with the community. - -Open a discussion topic on our Discussion forum: - -[Add to Registry](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/docs/registry/external.json ""){.md-button} [Share on forum](https://github.com/spaceship-prompt/spaceship-prompt/discussions/new?category=show-and-tell&title=Section%20for%20[tool] ""){.md-button} diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.md b/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.md deleted file mode 100644 index b0c88b4..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.md +++ /dev/null @@ -1,136 +0,0 @@ -# Creating a custom section - -This guide aims to help you create your first custom section. - -## Rules for sections - -Here are recommendations to follow when creating a section to maintain Spaceship slick and clean. - -### Section should not clutter the prompt - -Having too much in prompt looks ugly. It's better to keep it to a minimum of necessary information. - -* **Good:** `🚀 v1.2.3` -* **Bad:** `🚀 spasheship#c3BhY2VzaGlw` - -### Section should be worth to be aware of - -Is value changes quite often, so it needs to be shown in prompt? Would it be useful for other users? Maybe there's a reason to execute a command instead of cluttering prompt. - -* **Good:** git status/branch, runtime version via version manager, etc -* **Bad:** version of language-specific framework, settled projects versions, etc - -### Section should be fast - -If your section performs any heavy checking, find a way to make it faster. Use async rendering for performing heavy tasks. Section should be: - -* **Async:** if it executes external commands, perform complex calculations, reading large files -* **Sync:** if it checks command availability, checks the value of environment variable - -### Follow naming convention for options - -All options of prompt follow a specific pattern so that it is easy to remember: `SPACESHIP_SECTION_<OPTION>[_PROPERTY]`. The rule is simple: when naming new properties, keep unique parts of the name to the end. - -* **Good:** - ``` - SPACESHIP_GIT_STATUS_COLOR_BEHIND - SPACESHIP_GIT_STATUS_COLOR_DIVERGED - ``` -* **Bad:** - ``` - SPACESHIP_GIT_STATUS_BEHIND_COLOR - SPACESHIP_GIT_STATUS_DIVERGED_COLOR - ``` - - Here, `GIT_STATUS` is *section*, `COLOR` is *option* and `BEHIND` or `DIVERGED` is *property*. - -## Create a section - -The simplest way to create a section is to use a template repo for Spaceship section. - -[:fontawesome-brands-github: Use a section template](https://github.com/spaceship-prompt/spaceship-section){ .md-button } - -This boilerplate repo contains a template for a section and its documentation, has configured release and testing workflow. Explore the repo to learn more. - -Open a [`spaceship-section.plugin.zsh` file](https://github.com/spaceship-prompt/spaceship-section/blob/main/spaceship-section.plugin.zsh) for a custom section example. - -## Typical section breakdown - -Below is an example of a typical section for Spaceship. Pay attention to a few crucial moments: - -- Define options for customization. Their names should start with `SPACESHIP_`. -- Every Spaceship section name should start with `spaceship_` (for example `spaceship_node`). This is a convention that is used to identify the section. -- Show section only where it's needed (in directories which contains specific files, when a specific command is available, etc). - -Sections are defined by [`spaceship::section` API](/api/section/). You can use [general purpose utilities](/api/utils/) for performing common tasks in a section. - -Typical section might look like this: - -```zsh -# -# Foobar -# -# Foobar is a supa-dupa cool tool for making you development easier. -# Link: https://www.foobar.xyz - -# ------------------------------------------------------------------------------ -# Configuration -# ------------------------------------------------------------------------------ - -SPACESHIP_FOOBAR_SHOW="${SPACESHIP_FOOBAR_SHOW=true}" -SPACESHIP_FOOBAR_ASYNC="${SPACESHIP_FOOBAR_ASYNC=true}" -SPACESHIP_FOOBAR_PREFIX="${SPACESHIP_FOOBAR_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" -SPACESHIP_FOOBAR_SUFFIX="${SPACESHIP_FOOBAR_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" -SPACESHIP_FOOBAR_SYMBOL="${SPACESHIP_FOOBAR_SYMBOL="🍷 "}" -SPACESHIP_FOOBAR_COLOR="${SPACESHIP_FOOBAR_COLOR="white"}" - -# ------------------------------------------------------------------------------ -# Section -# ------------------------------------------------------------------------------ - -# Show foobar status -# spaceship_ prefix before section's name is required! -# Otherwise this section won't be loaded. -spaceship_foobar() { - # If SPACESHIP_FOOBAR_SHOW is false, don't show foobar section - [[ $SPACESHIP_FOOBAR_SHOW == false ]] && return - - # Check if foobar command is available for execution - spaceship::exists foobar || return - - # Show foobar section only when there are foobar-specific files in current - # working directory. - - # spaceship::upsearch utility helps finding files up in the directory tree. - local is_foobar_context="$(spaceship::upsearch foobar.conf)" - # Here glob qualifiers are used to check if files with specific extension are - # present in directory. Read more about them here: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html - [[ -n "$is_foobar_context" || -n *.foo(#qN^/) || -n *.bar(#qN^/) ]] || return - - local foobar_version="$(foobar --version)" - - # Check if tool version is correct - [[ $tool_version == "system" ]] && return - - # Display foobar section - # spaceship::section utility composes sections. Flags are optional - spaceship::section::v4 \ - --color "$SPACESHIP_FOOBAR_COLOR" \ - --prefix "$SPACESHIP_FOOBAR_PREFIX" \ - --suffix "$SPACESHIP_FOOBAR_SUFFIX" \ - --symbol "$SPACESHIP_FOOBAR_SYMBOL" \ - "$foobar_status" -} -``` - -Take a look at [Contribution guidelines](//github.com/spaceship-prompt/spaceship-prompt/blob/master/CONTRIBUTING.md) for further information. - -## Share your section with others - -The next step is to share your section with the community. - -Open a discussion topic on our Discussion forum: - -[Add to Registry](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/docs/registry/external.json){ .md-button } -[Share on forum](https://github.com/spaceship-prompt/spaceship-prompt/discussions/new?category=show-and-tell&title=Section%20for%20[tool]){ .md-button } diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.uk.md b/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.uk.md deleted file mode 100644 index 458dc8d..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.uk.md +++ /dev/null @@ -1,135 +0,0 @@ -# Створення власної секції - -Ця інструкція спрямована на те, щоб допомогти вам створити свою першу користувацьку секцію. - -## Правила для секцій - -Рекомендації для створення секцій, які допоможуть підтримувати Spaseship швидким та зрозумілим. - -### Секція не повинна засмічувати командний рядок - -Having too much in prompt looks ugly. Краще притримуватись необхідного мінімуму. - -* **Добре:** `🚀 v1.2.3` -* **Погано:** `🚀 spasheship#c3BhY2VzaGlw` - -### Секція має бути вартою того, щоб її бачити - -Чи достатньо часто змінюється значення, що його постійно треба показувати в командному рядку? Чи це буде корисним для інших користувачів? Можливо, є підстави виконати команду замість засмічення командного рядка. - -* **Good:** git status/branch, runtime version via version manager, etc -* **Bad:** version of language-specific framework, settled projects versions, etc - -### Секція повинна бути швидкою - -Якщо ваш розділ виконає складну перевірку, знайдіть спосіб зробити її швидше. Використовувати асинхронний рендер для виконання важких задач. Секція має бути: - -* **Асинхронна:** якщо вона виконує зовнішні команди, виконує складні обчислення, читання великих файлів -* **Синхронна:** якщо перевіряє доступність команди, перевіряє значення змінної середовища - -### Follow naming convention for options - -All options of prompt follow a specific pattern so that it is easy to remember: `SPACESHIP_SECTION_<OPTION>[_PROPERTY]`. The rule is simple: when naming new properties, keep unique parts of the name to the end. - -* **Good:** - ``` - SPACESHIP_GIT_STATUS_COLOR_BEHIND - SPACESHIP_GIT_STATUS_COLOR_DIVERGED - ``` -* **Bad:** - ``` - SPACESHIP_GIT_STATUS_BEHIND_COLOR - SPACESHIP_GIT_STATUS_DIVERGED_COLOR - ``` - - Here, `GIT_STATUS` is *section*, `COLOR` is *option* and `BEHIND` or `DIVERGED` is *property*. - -## Create a section - -The simplest way to create a section is to use a template repo for Spaceship section. - -[:fontawesome-brands-github: Use a section template](https://github.com/spaceship-prompt/spaceship-section ""){.md-button} - -This boilerplate repo contains a template for a section and its documentation, has configured release and testing workflow. Explore the repo to learn more. - -Open a [`spaceship-section.plugin.zsh` file](https://github.com/spaceship-prompt/spaceship-section/blob/main/spaceship-section.plugin.zsh) for a custom section example. - -## Typical section breakdown - -Below is an example of a typical section for Spaceship. Pay attention to a few crucial moments: - -- Define options for customization. Their names should start with `SPACESHIP_`. -- Every Spaceship section name should start with `spaceship_` (for example `spaceship_node`). This is a convention that is used to identify the section. -- Show section only where it's needed (in directories which contains specific files, when a specific command is available, etc). - -Sections are defined by [`spaceship::section` API](/api/section/). You can use [general purpose utilities](/api/utils/) for performing common tasks in a section. - -Typical section might look like this: - -```zsh -# -# Foobar -# -# Foobar is a supa-dupa cool tool for making you development easier. -# Link: https://www.foobar.xyz - -# ------------------------------------------------------------------------------ -# Configuration -# ------------------------------------------------------------------------------ - -SPACESHIP_FOOBAR_SHOW="${SPACESHIP_FOOBAR_SHOW=true}" -SPACESHIP_FOOBAR_ASYNC="${SPACESHIP_FOOBAR_ASYNC=true}" -SPACESHIP_FOOBAR_PREFIX="${SPACESHIP_FOOBAR_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" -SPACESHIP_FOOBAR_SUFFIX="${SPACESHIP_FOOBAR_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" -SPACESHIP_FOOBAR_SYMBOL="${SPACESHIP_FOOBAR_SYMBOL="🍷 "}" -SPACESHIP_FOOBAR_COLOR="${SPACESHIP_FOOBAR_COLOR="white"}" - -# ------------------------------------------------------------------------------ -# Section -# ------------------------------------------------------------------------------ - -# Show foobar status -# spaceship_ prefix before section's name is required! -# Otherwise this section won't be loaded. -spaceship_foobar() { - # If SPACESHIP_FOOBAR_SHOW is false, don't show foobar section - [[ $SPACESHIP_FOOBAR_SHOW == false ]] && return - - # Check if foobar command is available for execution - spaceship::exists foobar || return - - # Show foobar section only when there are foobar-specific files in current - # working directory. - - # spaceship::upsearch utility helps finding files up in the directory tree. - local is_foobar_context="$(spaceship::upsearch foobar.conf)" - # Here glob qualifiers are used to check if files with specific extension are - # present in directory. Read more about them here: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html - [[ -n "$is_foobar_context" || -n *.foo(#qN^/) || -n *.bar(#qN^/) ]] || return - - local foobar_version="$(foobar --version)" - - # Check if tool version is correct - [[ $tool_version == "system" ]] && return - - # Display foobar section - # spaceship::section utility composes sections. Flags are optional - spaceship::section::v4 \ - --color "$SPACESHIP_FOOBAR_COLOR" \ - --prefix "$SPACESHIP_FOOBAR_PREFIX" \ - --suffix "$SPACESHIP_FOOBAR_SUFFIX" \ - --symbol "$SPACESHIP_FOOBAR_SYMBOL" \ - "$foobar_status" -} -``` - -Take a look at [Contribution guidelines](//github.com/spaceship-prompt/spaceship-prompt/blob/master/CONTRIBUTING.md) for further information. - -## Share your section with others - -The next step is to share your section with the community. - -Open a discussion topic on our Discussion forum: - -[Add to Registry](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/docs/registry/external.json ""){.md-button} [Share on forum](https://github.com/spaceship-prompt/spaceship-prompt/discussions/new?category=show-and-tell&title=Section%20for%20[tool] ""){.md-button} diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.zh.md b/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.zh.md deleted file mode 100644 index 22346ba..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/creating-section.zh.md +++ /dev/null @@ -1,135 +0,0 @@ -# Creating a custom section - -This guide aims to help you create your first custom section. - -## Rules for sections - -Here are recommendations to follow when creating a section to maintain Spaceship slick and clean. - -### Section should not clutter the prompt - -Having too much in prompt looks ugly. It's better to keep it to a minimum of necessary information. - -* **Good:** `🚀 v1.2.3` -* **Bad:** `🚀 spasheship#c3BhY2VzaGlw` - -### Section should be worth to be aware of - -Is value changes quite often, so it needs to be shown in prompt? Would it be useful for other users? Maybe there's a reason to execute a command instead of cluttering prompt. - -* **Good:** git status/branch, runtime version via version manager, etc -* **Bad:** version of language-specific framework, settled projects versions, etc - -### Section should be fast - -If your section performs any heavy checking, find a way to make it faster. Use async rendering for performing heavy tasks. Section should be: - -* **Async:** if it executes external commands, perform complex calculations, reading large files -* **Sync:** if it checks command availability, checks the value of environment variable - -### Follow naming convention for options - -All options of prompt follow a specific pattern so that it is easy to remember: `SPACESHIP_SECTION_<OPTION>[_PROPERTY]`. The rule is simple: when naming new properties, keep unique parts of the name to the end. - -* **Good:** - ``` - SPACESHIP_GIT_STATUS_COLOR_BEHIND - SPACESHIP_GIT_STATUS_COLOR_DIVERGED - ``` -* **Bad:** - ``` - SPACESHIP_GIT_STATUS_BEHIND_COLOR - SPACESHIP_GIT_STATUS_DIVERGED_COLOR - ``` - - Here, `GIT_STATUS` is *section*, `COLOR` is *option* and `BEHIND` or `DIVERGED` is *property*. - -## Create a section - -The simplest way to create a section is to use a template repo for Spaceship section. - -[:fontawesome-brands-github: Use a section template](https://github.com/spaceship-prompt/spaceship-section ""){.md-button} - -This boilerplate repo contains a template for a section and its documentation, has configured release and testing workflow. Explore the repo to learn more. - -Open a [`spaceship-section.plugin.zsh` file](https://github.com/spaceship-prompt/spaceship-section/blob/main/spaceship-section.plugin.zsh) for a custom section example. - -## Typical section breakdown - -Below is an example of a typical section for Spaceship. Pay attention to a few crucial moments: - -- Define options for customization. Their names should start with `SPACESHIP_`. -- Every Spaceship section name should start with `spaceship_` (for example `spaceship_node`). This is a convention that is used to identify the section. -- Show section only where it's needed (in directories which contains specific files, when a specific command is available, etc). - -Sections are defined by [`spaceship::section` API](/api/section/). You can use [general purpose utilities](/api/utils/) for performing common tasks in a section. - -Typical section might look like this: - -```zsh -# -# Foobar -# -# Foobar is a supa-dupa cool tool for making you development easier. -# Link: https://www.foobar.xyz - -# ------------------------------------------------------------------------------ -# Configuration -# ------------------------------------------------------------------------------ - -SPACESHIP_FOOBAR_SHOW="${SPACESHIP_FOOBAR_SHOW=true}" -SPACESHIP_FOOBAR_ASYNC="${SPACESHIP_FOOBAR_ASYNC=true}" -SPACESHIP_FOOBAR_PREFIX="${SPACESHIP_FOOBAR_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" -SPACESHIP_FOOBAR_SUFFIX="${SPACESHIP_FOOBAR_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" -SPACESHIP_FOOBAR_SYMBOL="${SPACESHIP_FOOBAR_SYMBOL="🍷 "}" -SPACESHIP_FOOBAR_COLOR="${SPACESHIP_FOOBAR_COLOR="white"}" - -# ------------------------------------------------------------------------------ -# Section -# ------------------------------------------------------------------------------ - -# Show foobar status -# spaceship_ prefix before section's name is required! -# Otherwise this section won't be loaded. -spaceship_foobar() { - # If SPACESHIP_FOOBAR_SHOW is false, don't show foobar section - [[ $SPACESHIP_FOOBAR_SHOW == false ]] && return - - # Check if foobar command is available for execution - spaceship::exists foobar || return - - # Show foobar section only when there are foobar-specific files in current - # working directory. - - # spaceship::upsearch utility helps finding files up in the directory tree. - local is_foobar_context="$(spaceship::upsearch foobar.conf)" - # Here glob qualifiers are used to check if files with specific extension are - # present in directory. Read more about them here: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html - [[ -n "$is_foobar_context" || -n *.foo(#qN^/) || -n *.bar(#qN^/) ]] || return - - local foobar_version="$(foobar --version)" - - # Check if tool version is correct - [[ $tool_version == "system" ]] && return - - # Display foobar section - # spaceship::section utility composes sections. Flags are optional - spaceship::section::v4 \ - --color "$SPACESHIP_FOOBAR_COLOR" \ - --prefix "$SPACESHIP_FOOBAR_PREFIX" \ - --suffix "$SPACESHIP_FOOBAR_SUFFIX" \ - --symbol "$SPACESHIP_FOOBAR_SYMBOL" \ - "$foobar_status" -} -``` - -Take a look at [Contribution guidelines](//github.com/spaceship-prompt/spaceship-prompt/blob/master/CONTRIBUTING.md) for further information. - -## Share your section with others - -The next step is to share your section with the community. - -Open a discussion topic on our Discussion forum: - -[Add to Registry](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/docs/registry/external.json ""){.md-button} [Share on forum](https://github.com/spaceship-prompt/spaceship-prompt/discussions/new?category=show-and-tell&title=Section%20for%20[tool] ""){.md-button} diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.de.md b/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.de.md deleted file mode 100644 index a3933cd..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.de.md +++ /dev/null @@ -1,50 +0,0 @@ -# Per-directory configuration - -Many users asked us how to change Spaceship options only for a specific directory. There are plenty solutions for this. We will show how to do that with a tool called `direnv`. - -`direnv` is a tool that allows you to manage environment variables for a directory. It is a simple wrapper around `.envrc` files. It can load and unload variables defined in `.envrc` based on current directory. It also works not only with Zsh, but with other popular shells. - -## Installing `direnv` - -Install `direnv` with the package manager of your choice. Or use a script to install a binary build of `direnv`. - -[Installation guide](https://github.com/direnv/direnv/blob/master/docs/installation.md ""){.md-button} - -After successful installation of `direnv` you need to hook it to your shell. - -## Hooking `direnv` into Zsh - -Add the following line somewhere at the end of your `.zshrc` file: - -```zsh title=".zhrc" -eval "$(direnv hook zsh)" -``` - -## Setting per-directory environment variables - -As soon as you've installed `direnv` and hooked it to the Zsh, you can set environment variables for any directory in a `.envrc` file within that directory. - -```zsh title=".envrc" -export SPACESHIP_USER_SHOW='always' -``` - -After that you need explicitly grant permissions to source `.envrc` files in the directory. - -``` -direnv allow /path/to/directory -``` - -Here is a live example of how `direnv` works: - -<div class="terminal-demo"> - <script id="asciicast-l6jOkth3csJQGkJRGV8A6DLl0" src="https://asciinema.org/a/l6jOkth3csJQGkJRGV8A6DLl0.js" data-autoplay="true" data-loop="true" data-preload="true" async></script> -</div> - -## Alternatives to `direnv` - -Besides `direnv` there are many other tools that allow you to manage environment variables for a directory. Here's a list of the most popular of them: - -* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) -* [asdf-direnv](https://github.com/asdf-community/asdf-direnv) -* [shadowenv](https://shopify.github.io/shadowenv/) -* [quickenv](https://github.com/untitaker/quickenv) diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.fr.md b/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.fr.md deleted file mode 100644 index a3933cd..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.fr.md +++ /dev/null @@ -1,50 +0,0 @@ -# Per-directory configuration - -Many users asked us how to change Spaceship options only for a specific directory. There are plenty solutions for this. We will show how to do that with a tool called `direnv`. - -`direnv` is a tool that allows you to manage environment variables for a directory. It is a simple wrapper around `.envrc` files. It can load and unload variables defined in `.envrc` based on current directory. It also works not only with Zsh, but with other popular shells. - -## Installing `direnv` - -Install `direnv` with the package manager of your choice. Or use a script to install a binary build of `direnv`. - -[Installation guide](https://github.com/direnv/direnv/blob/master/docs/installation.md ""){.md-button} - -After successful installation of `direnv` you need to hook it to your shell. - -## Hooking `direnv` into Zsh - -Add the following line somewhere at the end of your `.zshrc` file: - -```zsh title=".zhrc" -eval "$(direnv hook zsh)" -``` - -## Setting per-directory environment variables - -As soon as you've installed `direnv` and hooked it to the Zsh, you can set environment variables for any directory in a `.envrc` file within that directory. - -```zsh title=".envrc" -export SPACESHIP_USER_SHOW='always' -``` - -After that you need explicitly grant permissions to source `.envrc` files in the directory. - -``` -direnv allow /path/to/directory -``` - -Here is a live example of how `direnv` works: - -<div class="terminal-demo"> - <script id="asciicast-l6jOkth3csJQGkJRGV8A6DLl0" src="https://asciinema.org/a/l6jOkth3csJQGkJRGV8A6DLl0.js" data-autoplay="true" data-loop="true" data-preload="true" async></script> -</div> - -## Alternatives to `direnv` - -Besides `direnv` there are many other tools that allow you to manage environment variables for a directory. Here's a list of the most popular of them: - -* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) -* [asdf-direnv](https://github.com/asdf-community/asdf-direnv) -* [shadowenv](https://shopify.github.io/shadowenv/) -* [quickenv](https://github.com/untitaker/quickenv) diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.md b/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.md deleted file mode 100644 index ebaf474..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.md +++ /dev/null @@ -1,50 +0,0 @@ -# Per-directory configuration - -Many users asked us how to change Spaceship options only for a specific directory. There are plenty solutions for this. We will show how to do that with a tool called `direnv`. - -`direnv` is a tool that allows you to manage environment variables for a directory. It is a simple wrapper around `.envrc` files. It can load and unload variables defined in `.envrc` based on current directory. It also works not only with Zsh, but with other popular shells. - -## Installing `direnv` - -Install `direnv` with the package manager of your choice. Or use a script to install a binary build of `direnv`. - -[Installation guide](https://github.com/direnv/direnv/blob/master/docs/installation.md){ .md-button } - -After successful installation of `direnv` you need to hook it to your shell. - -## Hooking `direnv` into Zsh - -Add the following line somewhere at the end of your `.zshrc` file: - -```zsh title=".zhrc" -eval "$(direnv hook zsh)" -``` - -## Setting per-directory environment variables - -As soon as you've installed `direnv` and hooked it to the Zsh, you can set environment variables for any directory in a `.envrc` file within that directory. - -```zsh title=".envrc" -export SPACESHIP_USER_SHOW='always' -``` - -After that you need explicitly grant permissions to source `.envrc` files in the directory. - -``` -direnv allow /path/to/directory -``` - -Here is a live example of how `direnv` works: - -<div class="terminal-demo"> - <script id="asciicast-l6jOkth3csJQGkJRGV8A6DLl0" src="https://asciinema.org/a/l6jOkth3csJQGkJRGV8A6DLl0.js" data-autoplay="true" data-loop="true" data-preload="true" async></script> -</div> - -## Alternatives to `direnv` - -Besides `direnv` there are many other tools that allow you to manage environment variables for a directory. Here's a list of the most popular of them: - -* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) -* [asdf-direnv](https://github.com/asdf-community/asdf-direnv) -* [shadowenv](https://shopify.github.io/shadowenv/) -* [quickenv](https://github.com/untitaker/quickenv) diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.uk.md b/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.uk.md deleted file mode 100644 index a3933cd..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.uk.md +++ /dev/null @@ -1,50 +0,0 @@ -# Per-directory configuration - -Many users asked us how to change Spaceship options only for a specific directory. There are plenty solutions for this. We will show how to do that with a tool called `direnv`. - -`direnv` is a tool that allows you to manage environment variables for a directory. It is a simple wrapper around `.envrc` files. It can load and unload variables defined in `.envrc` based on current directory. It also works not only with Zsh, but with other popular shells. - -## Installing `direnv` - -Install `direnv` with the package manager of your choice. Or use a script to install a binary build of `direnv`. - -[Installation guide](https://github.com/direnv/direnv/blob/master/docs/installation.md ""){.md-button} - -After successful installation of `direnv` you need to hook it to your shell. - -## Hooking `direnv` into Zsh - -Add the following line somewhere at the end of your `.zshrc` file: - -```zsh title=".zhrc" -eval "$(direnv hook zsh)" -``` - -## Setting per-directory environment variables - -As soon as you've installed `direnv` and hooked it to the Zsh, you can set environment variables for any directory in a `.envrc` file within that directory. - -```zsh title=".envrc" -export SPACESHIP_USER_SHOW='always' -``` - -After that you need explicitly grant permissions to source `.envrc` files in the directory. - -``` -direnv allow /path/to/directory -``` - -Here is a live example of how `direnv` works: - -<div class="terminal-demo"> - <script id="asciicast-l6jOkth3csJQGkJRGV8A6DLl0" src="https://asciinema.org/a/l6jOkth3csJQGkJRGV8A6DLl0.js" data-autoplay="true" data-loop="true" data-preload="true" async></script> -</div> - -## Alternatives to `direnv` - -Besides `direnv` there are many other tools that allow you to manage environment variables for a directory. Here's a list of the most popular of them: - -* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) -* [asdf-direnv](https://github.com/asdf-community/asdf-direnv) -* [shadowenv](https://shopify.github.io/shadowenv/) -* [quickenv](https://github.com/untitaker/quickenv) diff --git a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.zh.md b/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.zh.md deleted file mode 100644 index a3933cd..0000000 --- a/.zsh/themes/spaceship-prompt/docs/advanced/per-directory-config.zh.md +++ /dev/null @@ -1,50 +0,0 @@ -# Per-directory configuration - -Many users asked us how to change Spaceship options only for a specific directory. There are plenty solutions for this. We will show how to do that with a tool called `direnv`. - -`direnv` is a tool that allows you to manage environment variables for a directory. It is a simple wrapper around `.envrc` files. It can load and unload variables defined in `.envrc` based on current directory. It also works not only with Zsh, but with other popular shells. - -## Installing `direnv` - -Install `direnv` with the package manager of your choice. Or use a script to install a binary build of `direnv`. - -[Installation guide](https://github.com/direnv/direnv/blob/master/docs/installation.md ""){.md-button} - -After successful installation of `direnv` you need to hook it to your shell. - -## Hooking `direnv` into Zsh - -Add the following line somewhere at the end of your `.zshrc` file: - -```zsh title=".zhrc" -eval "$(direnv hook zsh)" -``` - -## Setting per-directory environment variables - -As soon as you've installed `direnv` and hooked it to the Zsh, you can set environment variables for any directory in a `.envrc` file within that directory. - -```zsh title=".envrc" -export SPACESHIP_USER_SHOW='always' -``` - -After that you need explicitly grant permissions to source `.envrc` files in the directory. - -``` -direnv allow /path/to/directory -``` - -Here is a live example of how `direnv` works: - -<div class="terminal-demo"> - <script id="asciicast-l6jOkth3csJQGkJRGV8A6DLl0" src="https://asciinema.org/a/l6jOkth3csJQGkJRGV8A6DLl0.js" data-autoplay="true" data-loop="true" data-preload="true" async></script> -</div> - -## Alternatives to `direnv` - -Besides `direnv` there are many other tools that allow you to manage environment variables for a directory. Here's a list of the most popular of them: - -* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) -* [asdf-direnv](https://github.com/asdf-community/asdf-direnv) -* [shadowenv](https://shopify.github.io/shadowenv/) -* [quickenv](https://github.com/untitaker/quickenv) diff --git a/.zsh/themes/spaceship-prompt/docs/api/environment.de.md b/.zsh/themes/spaceship-prompt/docs/api/environment.de.md deleted file mode 100644 index 6e3d8d0..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/environment.de.md +++ /dev/null @@ -1,132 +0,0 @@ -# Environment - -Spaceship uses `SPACESHIP_` prefix for variables and `spaceship::` prefix for a function to avoid conflicts with global environment. All section, including custom ones, are being required to use `spaceship_` prefix before their name to load properly. - -## Prompt variables - -### `SPACESHIP_VERSION` - -An environment variable that defines the version of currently running Spaceship prompt version. Can be used for issue reporting or debugging purposes. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_VERSION -#> 3.0.0 -``` - -### `SPACESHIP_ROOT` - -<!-- prettier-ignore --> -!!! danger - This variable is read only. Changing the value may cause the damage to Spaceship installation! - -An environment variable that defines the path to Spaceship prompt installation. Spaceship uses this variable for resolving path to sections and utils. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_ROOT -#> /path/to/spaceship-prompt -``` - -### `SPACESHIP_CONFIG_PATH` - -An array of path to configuration files. Spaceship will look for configuration file in the order of the array. The first file that exists will be used. - -The default locations are: - -```zsh -$HOME/.spaceshiprc -$HOME/.spaceshiprc.zsh -$HOME/.config/spaceship.zsh -$HOME/.config/spaceship/spaceship.zsh -$XDG_CONFIG_HOME/spaceship.zsh -/etc/xdg/spaceship.zsh -$XDG_CONFIG_DIRS/spaceship.zsh -``` - -### `SPACESHIP_CONFIG` - -A variable storing the path to the configuration file. Usually, this variable stores one of the paths from the [`SPACESHIP_CONFIG_PATH`](#spaceship_config_path) array. - -You can specify custom path to the configuration file by setting the `SPACESHIP_CONFIG_FILE` environment variable, for example: - -```zsh title="$HOME/.zshrc" -export SPACESHIP_CONFIG_FILE="$HOME/.dotfiles/path/to/spaceship.zsh" -``` - -The variable is empty when no configuration file is found. - -### `SPACESHIP_CACHE` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An associative array that stores the cached values of the sections. The cache stores data between renders and is cleared on every prompt. - -The cache should not be manipulated directly. - -### `SPACESHIP_JOBS` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An array of currently processing asynchronous sections. Can be used to check what asynchronous sections are being rendered. - -The section name is added to the array when the asynchronous section is being rendered. Upon completion of the asynchronouse job, the name is removed from the array. - -## Asynchronous runtime - -Spaceship uses [`zsh-async`](https://github.com/mafredri/zsh-async) library to perform asynchronous tasks. This library comes along with Spaceship and is regularly updated to the latest version. - -`zsh-async` is loaded automatically when Spaceship loads sections, when all of these conditions are true: - -1. Asynchronous rendering is turned on (see [Asynchronous rendering](/config/prompt/#asynchronous-rendering)) -2. There's at least one section that is rendered asynchronously. -3. `zsh-async` was not loaded before. - -Otherwise, Spaceship will skip the loading of `zsh-async`. - -### Loading `zsh-async` manually - -If you plan on using `zsh-async` for purposes other than just rendering Spaceship, it's recommended to load it explicitly, before loading Spaceship. - -Here's an example of how to load `zsh-async` manually: - -=== "antigen" - - ```zsh title=".zshrc" - antigen bundle mafredri/zsh-async - ``` - -=== "antibody" - - ```zsh title=".zshrc" - antibody bundle mafredri/zsh-async - ``` - -=== "zinit" - - ```zsh title=".zshrc" - zinit light mafredri/zsh-async - ``` - -=== "zgen" - - ```zsh title=".zshrc" - zgen load mafredri/zsh-async - ``` - -=== "zplug" - - ```zsh title=".zshrc" - zplug mafredri/zsh-async, from:github - ``` - -=== "sheldon" - - ```zsh title=".sheldon/plugins.toml" - [plugins.zsh-async] - github = 'mafredri/zsh-async' - ``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/environment.fr.md b/.zsh/themes/spaceship-prompt/docs/api/environment.fr.md deleted file mode 100644 index 6e3d8d0..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/environment.fr.md +++ /dev/null @@ -1,132 +0,0 @@ -# Environment - -Spaceship uses `SPACESHIP_` prefix for variables and `spaceship::` prefix for a function to avoid conflicts with global environment. All section, including custom ones, are being required to use `spaceship_` prefix before their name to load properly. - -## Prompt variables - -### `SPACESHIP_VERSION` - -An environment variable that defines the version of currently running Spaceship prompt version. Can be used for issue reporting or debugging purposes. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_VERSION -#> 3.0.0 -``` - -### `SPACESHIP_ROOT` - -<!-- prettier-ignore --> -!!! danger - This variable is read only. Changing the value may cause the damage to Spaceship installation! - -An environment variable that defines the path to Spaceship prompt installation. Spaceship uses this variable for resolving path to sections and utils. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_ROOT -#> /path/to/spaceship-prompt -``` - -### `SPACESHIP_CONFIG_PATH` - -An array of path to configuration files. Spaceship will look for configuration file in the order of the array. The first file that exists will be used. - -The default locations are: - -```zsh -$HOME/.spaceshiprc -$HOME/.spaceshiprc.zsh -$HOME/.config/spaceship.zsh -$HOME/.config/spaceship/spaceship.zsh -$XDG_CONFIG_HOME/spaceship.zsh -/etc/xdg/spaceship.zsh -$XDG_CONFIG_DIRS/spaceship.zsh -``` - -### `SPACESHIP_CONFIG` - -A variable storing the path to the configuration file. Usually, this variable stores one of the paths from the [`SPACESHIP_CONFIG_PATH`](#spaceship_config_path) array. - -You can specify custom path to the configuration file by setting the `SPACESHIP_CONFIG_FILE` environment variable, for example: - -```zsh title="$HOME/.zshrc" -export SPACESHIP_CONFIG_FILE="$HOME/.dotfiles/path/to/spaceship.zsh" -``` - -The variable is empty when no configuration file is found. - -### `SPACESHIP_CACHE` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An associative array that stores the cached values of the sections. The cache stores data between renders and is cleared on every prompt. - -The cache should not be manipulated directly. - -### `SPACESHIP_JOBS` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An array of currently processing asynchronous sections. Can be used to check what asynchronous sections are being rendered. - -The section name is added to the array when the asynchronous section is being rendered. Upon completion of the asynchronouse job, the name is removed from the array. - -## Asynchronous runtime - -Spaceship uses [`zsh-async`](https://github.com/mafredri/zsh-async) library to perform asynchronous tasks. This library comes along with Spaceship and is regularly updated to the latest version. - -`zsh-async` is loaded automatically when Spaceship loads sections, when all of these conditions are true: - -1. Asynchronous rendering is turned on (see [Asynchronous rendering](/config/prompt/#asynchronous-rendering)) -2. There's at least one section that is rendered asynchronously. -3. `zsh-async` was not loaded before. - -Otherwise, Spaceship will skip the loading of `zsh-async`. - -### Loading `zsh-async` manually - -If you plan on using `zsh-async` for purposes other than just rendering Spaceship, it's recommended to load it explicitly, before loading Spaceship. - -Here's an example of how to load `zsh-async` manually: - -=== "antigen" - - ```zsh title=".zshrc" - antigen bundle mafredri/zsh-async - ``` - -=== "antibody" - - ```zsh title=".zshrc" - antibody bundle mafredri/zsh-async - ``` - -=== "zinit" - - ```zsh title=".zshrc" - zinit light mafredri/zsh-async - ``` - -=== "zgen" - - ```zsh title=".zshrc" - zgen load mafredri/zsh-async - ``` - -=== "zplug" - - ```zsh title=".zshrc" - zplug mafredri/zsh-async, from:github - ``` - -=== "sheldon" - - ```zsh title=".sheldon/plugins.toml" - [plugins.zsh-async] - github = 'mafredri/zsh-async' - ``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/environment.md b/.zsh/themes/spaceship-prompt/docs/api/environment.md deleted file mode 100644 index 6e3d8d0..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/environment.md +++ /dev/null @@ -1,132 +0,0 @@ -# Environment - -Spaceship uses `SPACESHIP_` prefix for variables and `spaceship::` prefix for a function to avoid conflicts with global environment. All section, including custom ones, are being required to use `spaceship_` prefix before their name to load properly. - -## Prompt variables - -### `SPACESHIP_VERSION` - -An environment variable that defines the version of currently running Spaceship prompt version. Can be used for issue reporting or debugging purposes. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_VERSION -#> 3.0.0 -``` - -### `SPACESHIP_ROOT` - -<!-- prettier-ignore --> -!!! danger - This variable is read only. Changing the value may cause the damage to Spaceship installation! - -An environment variable that defines the path to Spaceship prompt installation. Spaceship uses this variable for resolving path to sections and utils. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_ROOT -#> /path/to/spaceship-prompt -``` - -### `SPACESHIP_CONFIG_PATH` - -An array of path to configuration files. Spaceship will look for configuration file in the order of the array. The first file that exists will be used. - -The default locations are: - -```zsh -$HOME/.spaceshiprc -$HOME/.spaceshiprc.zsh -$HOME/.config/spaceship.zsh -$HOME/.config/spaceship/spaceship.zsh -$XDG_CONFIG_HOME/spaceship.zsh -/etc/xdg/spaceship.zsh -$XDG_CONFIG_DIRS/spaceship.zsh -``` - -### `SPACESHIP_CONFIG` - -A variable storing the path to the configuration file. Usually, this variable stores one of the paths from the [`SPACESHIP_CONFIG_PATH`](#spaceship_config_path) array. - -You can specify custom path to the configuration file by setting the `SPACESHIP_CONFIG_FILE` environment variable, for example: - -```zsh title="$HOME/.zshrc" -export SPACESHIP_CONFIG_FILE="$HOME/.dotfiles/path/to/spaceship.zsh" -``` - -The variable is empty when no configuration file is found. - -### `SPACESHIP_CACHE` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An associative array that stores the cached values of the sections. The cache stores data between renders and is cleared on every prompt. - -The cache should not be manipulated directly. - -### `SPACESHIP_JOBS` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An array of currently processing asynchronous sections. Can be used to check what asynchronous sections are being rendered. - -The section name is added to the array when the asynchronous section is being rendered. Upon completion of the asynchronouse job, the name is removed from the array. - -## Asynchronous runtime - -Spaceship uses [`zsh-async`](https://github.com/mafredri/zsh-async) library to perform asynchronous tasks. This library comes along with Spaceship and is regularly updated to the latest version. - -`zsh-async` is loaded automatically when Spaceship loads sections, when all of these conditions are true: - -1. Asynchronous rendering is turned on (see [Asynchronous rendering](/config/prompt/#asynchronous-rendering)) -2. There's at least one section that is rendered asynchronously. -3. `zsh-async` was not loaded before. - -Otherwise, Spaceship will skip the loading of `zsh-async`. - -### Loading `zsh-async` manually - -If you plan on using `zsh-async` for purposes other than just rendering Spaceship, it's recommended to load it explicitly, before loading Spaceship. - -Here's an example of how to load `zsh-async` manually: - -=== "antigen" - - ```zsh title=".zshrc" - antigen bundle mafredri/zsh-async - ``` - -=== "antibody" - - ```zsh title=".zshrc" - antibody bundle mafredri/zsh-async - ``` - -=== "zinit" - - ```zsh title=".zshrc" - zinit light mafredri/zsh-async - ``` - -=== "zgen" - - ```zsh title=".zshrc" - zgen load mafredri/zsh-async - ``` - -=== "zplug" - - ```zsh title=".zshrc" - zplug mafredri/zsh-async, from:github - ``` - -=== "sheldon" - - ```zsh title=".sheldon/plugins.toml" - [plugins.zsh-async] - github = 'mafredri/zsh-async' - ``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/environment.uk.md b/.zsh/themes/spaceship-prompt/docs/api/environment.uk.md deleted file mode 100644 index 6e3d8d0..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/environment.uk.md +++ /dev/null @@ -1,132 +0,0 @@ -# Environment - -Spaceship uses `SPACESHIP_` prefix for variables and `spaceship::` prefix for a function to avoid conflicts with global environment. All section, including custom ones, are being required to use `spaceship_` prefix before their name to load properly. - -## Prompt variables - -### `SPACESHIP_VERSION` - -An environment variable that defines the version of currently running Spaceship prompt version. Can be used for issue reporting or debugging purposes. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_VERSION -#> 3.0.0 -``` - -### `SPACESHIP_ROOT` - -<!-- prettier-ignore --> -!!! danger - This variable is read only. Changing the value may cause the damage to Spaceship installation! - -An environment variable that defines the path to Spaceship prompt installation. Spaceship uses this variable for resolving path to sections and utils. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_ROOT -#> /path/to/spaceship-prompt -``` - -### `SPACESHIP_CONFIG_PATH` - -An array of path to configuration files. Spaceship will look for configuration file in the order of the array. The first file that exists will be used. - -The default locations are: - -```zsh -$HOME/.spaceshiprc -$HOME/.spaceshiprc.zsh -$HOME/.config/spaceship.zsh -$HOME/.config/spaceship/spaceship.zsh -$XDG_CONFIG_HOME/spaceship.zsh -/etc/xdg/spaceship.zsh -$XDG_CONFIG_DIRS/spaceship.zsh -``` - -### `SPACESHIP_CONFIG` - -A variable storing the path to the configuration file. Usually, this variable stores one of the paths from the [`SPACESHIP_CONFIG_PATH`](#spaceship_config_path) array. - -You can specify custom path to the configuration file by setting the `SPACESHIP_CONFIG_FILE` environment variable, for example: - -```zsh title="$HOME/.zshrc" -export SPACESHIP_CONFIG_FILE="$HOME/.dotfiles/path/to/spaceship.zsh" -``` - -The variable is empty when no configuration file is found. - -### `SPACESHIP_CACHE` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An associative array that stores the cached values of the sections. The cache stores data between renders and is cleared on every prompt. - -The cache should not be manipulated directly. - -### `SPACESHIP_JOBS` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An array of currently processing asynchronous sections. Can be used to check what asynchronous sections are being rendered. - -The section name is added to the array when the asynchronous section is being rendered. Upon completion of the asynchronouse job, the name is removed from the array. - -## Asynchronous runtime - -Spaceship uses [`zsh-async`](https://github.com/mafredri/zsh-async) library to perform asynchronous tasks. This library comes along with Spaceship and is regularly updated to the latest version. - -`zsh-async` is loaded automatically when Spaceship loads sections, when all of these conditions are true: - -1. Asynchronous rendering is turned on (see [Asynchronous rendering](/config/prompt/#asynchronous-rendering)) -2. There's at least one section that is rendered asynchronously. -3. `zsh-async` was not loaded before. - -Otherwise, Spaceship will skip the loading of `zsh-async`. - -### Loading `zsh-async` manually - -If you plan on using `zsh-async` for purposes other than just rendering Spaceship, it's recommended to load it explicitly, before loading Spaceship. - -Here's an example of how to load `zsh-async` manually: - -=== "antigen" - - ```zsh title=".zshrc" - antigen bundle mafredri/zsh-async - ``` - -=== "antibody" - - ```zsh title=".zshrc" - antibody bundle mafredri/zsh-async - ``` - -=== "zinit" - - ```zsh title=".zshrc" - zinit light mafredri/zsh-async - ``` - -=== "zgen" - - ```zsh title=".zshrc" - zgen load mafredri/zsh-async - ``` - -=== "zplug" - - ```zsh title=".zshrc" - zplug mafredri/zsh-async, from:github - ``` - -=== "sheldon" - - ```zsh title=".sheldon/plugins.toml" - [plugins.zsh-async] - github = 'mafredri/zsh-async' - ``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/environment.zh.md b/.zsh/themes/spaceship-prompt/docs/api/environment.zh.md deleted file mode 100644 index 6e3d8d0..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/environment.zh.md +++ /dev/null @@ -1,132 +0,0 @@ -# Environment - -Spaceship uses `SPACESHIP_` prefix for variables and `spaceship::` prefix for a function to avoid conflicts with global environment. All section, including custom ones, are being required to use `spaceship_` prefix before their name to load properly. - -## Prompt variables - -### `SPACESHIP_VERSION` - -An environment variable that defines the version of currently running Spaceship prompt version. Can be used for issue reporting or debugging purposes. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_VERSION -#> 3.0.0 -``` - -### `SPACESHIP_ROOT` - -<!-- prettier-ignore --> -!!! danger - This variable is read only. Changing the value may cause the damage to Spaceship installation! - -An environment variable that defines the path to Spaceship prompt installation. Spaceship uses this variable for resolving path to sections and utils. - -Accessible to any program or script running in a current shell session. - -```zsh -echo $SPACESHIP_ROOT -#> /path/to/spaceship-prompt -``` - -### `SPACESHIP_CONFIG_PATH` - -An array of path to configuration files. Spaceship will look for configuration file in the order of the array. The first file that exists will be used. - -The default locations are: - -```zsh -$HOME/.spaceshiprc -$HOME/.spaceshiprc.zsh -$HOME/.config/spaceship.zsh -$HOME/.config/spaceship/spaceship.zsh -$XDG_CONFIG_HOME/spaceship.zsh -/etc/xdg/spaceship.zsh -$XDG_CONFIG_DIRS/spaceship.zsh -``` - -### `SPACESHIP_CONFIG` - -A variable storing the path to the configuration file. Usually, this variable stores one of the paths from the [`SPACESHIP_CONFIG_PATH`](#spaceship_config_path) array. - -You can specify custom path to the configuration file by setting the `SPACESHIP_CONFIG_FILE` environment variable, for example: - -```zsh title="$HOME/.zshrc" -export SPACESHIP_CONFIG_FILE="$HOME/.dotfiles/path/to/spaceship.zsh" -``` - -The variable is empty when no configuration file is found. - -### `SPACESHIP_CACHE` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An associative array that stores the cached values of the sections. The cache stores data between renders and is cleared on every prompt. - -The cache should not be manipulated directly. - -### `SPACESHIP_JOBS` - -!!! danger - This variable should be used only for reading. Changing the value may cause the incorrect behavior of Spaceship prompt. - -An array of currently processing asynchronous sections. Can be used to check what asynchronous sections are being rendered. - -The section name is added to the array when the asynchronous section is being rendered. Upon completion of the asynchronouse job, the name is removed from the array. - -## Asynchronous runtime - -Spaceship uses [`zsh-async`](https://github.com/mafredri/zsh-async) library to perform asynchronous tasks. This library comes along with Spaceship and is regularly updated to the latest version. - -`zsh-async` is loaded automatically when Spaceship loads sections, when all of these conditions are true: - -1. Asynchronous rendering is turned on (see [Asynchronous rendering](/config/prompt/#asynchronous-rendering)) -2. There's at least one section that is rendered asynchronously. -3. `zsh-async` was not loaded before. - -Otherwise, Spaceship will skip the loading of `zsh-async`. - -### Loading `zsh-async` manually - -If you plan on using `zsh-async` for purposes other than just rendering Spaceship, it's recommended to load it explicitly, before loading Spaceship. - -Here's an example of how to load `zsh-async` manually: - -=== "antigen" - - ```zsh title=".zshrc" - antigen bundle mafredri/zsh-async - ``` - -=== "antibody" - - ```zsh title=".zshrc" - antibody bundle mafredri/zsh-async - ``` - -=== "zinit" - - ```zsh title=".zshrc" - zinit light mafredri/zsh-async - ``` - -=== "zgen" - - ```zsh title=".zshrc" - zgen load mafredri/zsh-async - ``` - -=== "zplug" - - ```zsh title=".zshrc" - zplug mafredri/zsh-async, from:github - ``` - -=== "sheldon" - - ```zsh title=".sheldon/plugins.toml" - [plugins.zsh-async] - github = 'mafredri/zsh-async' - ``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/section.de.md b/.zsh/themes/spaceship-prompt/docs/api/section.de.md deleted file mode 100644 index 98d5607..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/section.de.md +++ /dev/null @@ -1,106 +0,0 @@ -# Sections - -Sections are defined using `spaceship::section` function. This section takes the content of the section parameters for displaying, like prefix, suffix, color and symbol for the section. These values will be used for displaying the section. - -The `spaceship::section` is used to pack the section data into a data tuple. This data tuple is stored in the cache. During the rendering process, the data tuple for each section is being rendered into a section via `spaceship::section::render` function. - -## `spaceship::section` - -!!! tip - For creating a custom section, prefer using the [`spaceship::section::v4` function](#spaceshipsectionv4). The versioned function will ensure compatibility with new versions of Spaceship. - -This is the main function for defining a section. This takes section parameters and its content and transforms it into a data tuple. - -``` title="Signature" -spaceship::section [--color color] [--prefix prefix] [--suffix suffix] [--symbol symbol] <content> -``` - -It takes a single argument `content` which is the content of the section. Additionally, the function takes the following optional parameters: - -* `--color` — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -* `--prefix` — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -* `--symbol` — the symbol of the section. Can be any valid value or result of command execution. Will be rendered before the content. -* `--suffix` — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -The order of the parameters is not important. All of them are default to empty strings. - -!!! help - The `content`, `--prefix`, `--suffix` and `--symbol` can contain escapes to set additional foreground color, background color and other visual effects. - - Read more about escapes in [13 Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -## `spaceship::section::v4` - -This is an alias of `spaceship::section` function. It's the versioned function for creating a custom section. - -The signature of this function is the same as for `spaceship::section` function. - -Here is an example usage: - -```zsh -local content="value" - -spaceship::section::v4 \ - --color "$SPACESHIP_SECTION_COLOR" \ - --prefix "$SPACESHIP_SECTION_PREFIX" \ - --suffix "$SPACESHIP_SECTION_SUFFIX" \ - --symbol "$SPACESHIP_SECTION_SYMBOL" \ - "$content" -``` - -## `spaceship::section::v3` - -!!! warning - This function is introduced for compatibility with Spaceship v3 sections. It's recommended to use the [`spaceship::section::v4` function](#spaceshipsectionv4) instead. - -This is a replacement for the `spaceship::section` function used in Spaceship v3. Use it for backward compatibility only. - -``` title="Signature" -spaceship::section <color> [prefix] <content> [suffix] -``` - -The `spaceship::section:v3` relies on the following arguments order: - -1. `color` _Required_ — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -2. `prefix` _Optional_ — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -3. `content` _Required_ — the content of the section. Can be any valid value or result of command execution. -4. `suffix` _Optional_ — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -Here is a simple example: - -```zsh -# Display prompt section with prefix and suffix -# Backslash is used to escape line ending -spaceship::section \ - "$SPACESHIP_SECTION_COLOR" \ - "$SPACESHIP_SECTION_PREFIX" \ - "$SPACESHIP_SECTION_SYMBOL$section_content" \ - "$SPACESHIP_SECTION_SUFFIX" - -# Display prompt section without prefix and suffix -spaceship::section "$color" "$SPACESHIP_CHAR_SYMBOL" -``` - -## `spaceship::section::render` - -This function renders the section from the data tuple provided by [`spaceship::section`](#spaceshipsection). - -``` title="Signature" -spaceship::render section <data> -``` - -If `SPACESHIP_PROMPT_PREFIXES_SHOW` is `false` or if the section is not the first in the prompt, then prefix will be omitted. - -If `SPACESHIP_PROMPT_SUFFIXES_SHOW` is `false`, then suffix will be omitted. - -The `data` is a result of the `spaceship::section` function. For example: - -```zsh -local color="red" content="value" - -spaceship::section::render "$(spaceship::section --color "$color" "$content")" -#> %{%B%F{red}%}value%{%b%f%} -``` - -!!! tip - You can use for rendering subsections within complex sections. See the sources of [`git`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/git.zsh) or [`docker`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/docker.zsh) sections for an example. diff --git a/.zsh/themes/spaceship-prompt/docs/api/section.fr.md b/.zsh/themes/spaceship-prompt/docs/api/section.fr.md deleted file mode 100644 index 98d5607..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/section.fr.md +++ /dev/null @@ -1,106 +0,0 @@ -# Sections - -Sections are defined using `spaceship::section` function. This section takes the content of the section parameters for displaying, like prefix, suffix, color and symbol for the section. These values will be used for displaying the section. - -The `spaceship::section` is used to pack the section data into a data tuple. This data tuple is stored in the cache. During the rendering process, the data tuple for each section is being rendered into a section via `spaceship::section::render` function. - -## `spaceship::section` - -!!! tip - For creating a custom section, prefer using the [`spaceship::section::v4` function](#spaceshipsectionv4). The versioned function will ensure compatibility with new versions of Spaceship. - -This is the main function for defining a section. This takes section parameters and its content and transforms it into a data tuple. - -``` title="Signature" -spaceship::section [--color color] [--prefix prefix] [--suffix suffix] [--symbol symbol] <content> -``` - -It takes a single argument `content` which is the content of the section. Additionally, the function takes the following optional parameters: - -* `--color` — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -* `--prefix` — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -* `--symbol` — the symbol of the section. Can be any valid value or result of command execution. Will be rendered before the content. -* `--suffix` — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -The order of the parameters is not important. All of them are default to empty strings. - -!!! help - The `content`, `--prefix`, `--suffix` and `--symbol` can contain escapes to set additional foreground color, background color and other visual effects. - - Read more about escapes in [13 Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -## `spaceship::section::v4` - -This is an alias of `spaceship::section` function. It's the versioned function for creating a custom section. - -The signature of this function is the same as for `spaceship::section` function. - -Here is an example usage: - -```zsh -local content="value" - -spaceship::section::v4 \ - --color "$SPACESHIP_SECTION_COLOR" \ - --prefix "$SPACESHIP_SECTION_PREFIX" \ - --suffix "$SPACESHIP_SECTION_SUFFIX" \ - --symbol "$SPACESHIP_SECTION_SYMBOL" \ - "$content" -``` - -## `spaceship::section::v3` - -!!! warning - This function is introduced for compatibility with Spaceship v3 sections. It's recommended to use the [`spaceship::section::v4` function](#spaceshipsectionv4) instead. - -This is a replacement for the `spaceship::section` function used in Spaceship v3. Use it for backward compatibility only. - -``` title="Signature" -spaceship::section <color> [prefix] <content> [suffix] -``` - -The `spaceship::section:v3` relies on the following arguments order: - -1. `color` _Required_ — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -2. `prefix` _Optional_ — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -3. `content` _Required_ — the content of the section. Can be any valid value or result of command execution. -4. `suffix` _Optional_ — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -Here is a simple example: - -```zsh -# Display prompt section with prefix and suffix -# Backslash is used to escape line ending -spaceship::section \ - "$SPACESHIP_SECTION_COLOR" \ - "$SPACESHIP_SECTION_PREFIX" \ - "$SPACESHIP_SECTION_SYMBOL$section_content" \ - "$SPACESHIP_SECTION_SUFFIX" - -# Display prompt section without prefix and suffix -spaceship::section "$color" "$SPACESHIP_CHAR_SYMBOL" -``` - -## `spaceship::section::render` - -This function renders the section from the data tuple provided by [`spaceship::section`](#spaceshipsection). - -``` title="Signature" -spaceship::render section <data> -``` - -If `SPACESHIP_PROMPT_PREFIXES_SHOW` is `false` or if the section is not the first in the prompt, then prefix will be omitted. - -If `SPACESHIP_PROMPT_SUFFIXES_SHOW` is `false`, then suffix will be omitted. - -The `data` is a result of the `spaceship::section` function. For example: - -```zsh -local color="red" content="value" - -spaceship::section::render "$(spaceship::section --color "$color" "$content")" -#> %{%B%F{red}%}value%{%b%f%} -``` - -!!! tip - You can use for rendering subsections within complex sections. See the sources of [`git`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/git.zsh) or [`docker`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/docker.zsh) sections for an example. diff --git a/.zsh/themes/spaceship-prompt/docs/api/section.md b/.zsh/themes/spaceship-prompt/docs/api/section.md deleted file mode 100644 index 98d5607..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/section.md +++ /dev/null @@ -1,106 +0,0 @@ -# Sections - -Sections are defined using `spaceship::section` function. This section takes the content of the section parameters for displaying, like prefix, suffix, color and symbol for the section. These values will be used for displaying the section. - -The `spaceship::section` is used to pack the section data into a data tuple. This data tuple is stored in the cache. During the rendering process, the data tuple for each section is being rendered into a section via `spaceship::section::render` function. - -## `spaceship::section` - -!!! tip - For creating a custom section, prefer using the [`spaceship::section::v4` function](#spaceshipsectionv4). The versioned function will ensure compatibility with new versions of Spaceship. - -This is the main function for defining a section. This takes section parameters and its content and transforms it into a data tuple. - -``` title="Signature" -spaceship::section [--color color] [--prefix prefix] [--suffix suffix] [--symbol symbol] <content> -``` - -It takes a single argument `content` which is the content of the section. Additionally, the function takes the following optional parameters: - -* `--color` — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -* `--prefix` — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -* `--symbol` — the symbol of the section. Can be any valid value or result of command execution. Will be rendered before the content. -* `--suffix` — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -The order of the parameters is not important. All of them are default to empty strings. - -!!! help - The `content`, `--prefix`, `--suffix` and `--symbol` can contain escapes to set additional foreground color, background color and other visual effects. - - Read more about escapes in [13 Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -## `spaceship::section::v4` - -This is an alias of `spaceship::section` function. It's the versioned function for creating a custom section. - -The signature of this function is the same as for `spaceship::section` function. - -Here is an example usage: - -```zsh -local content="value" - -spaceship::section::v4 \ - --color "$SPACESHIP_SECTION_COLOR" \ - --prefix "$SPACESHIP_SECTION_PREFIX" \ - --suffix "$SPACESHIP_SECTION_SUFFIX" \ - --symbol "$SPACESHIP_SECTION_SYMBOL" \ - "$content" -``` - -## `spaceship::section::v3` - -!!! warning - This function is introduced for compatibility with Spaceship v3 sections. It's recommended to use the [`spaceship::section::v4` function](#spaceshipsectionv4) instead. - -This is a replacement for the `spaceship::section` function used in Spaceship v3. Use it for backward compatibility only. - -``` title="Signature" -spaceship::section <color> [prefix] <content> [suffix] -``` - -The `spaceship::section:v3` relies on the following arguments order: - -1. `color` _Required_ — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -2. `prefix` _Optional_ — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -3. `content` _Required_ — the content of the section. Can be any valid value or result of command execution. -4. `suffix` _Optional_ — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -Here is a simple example: - -```zsh -# Display prompt section with prefix and suffix -# Backslash is used to escape line ending -spaceship::section \ - "$SPACESHIP_SECTION_COLOR" \ - "$SPACESHIP_SECTION_PREFIX" \ - "$SPACESHIP_SECTION_SYMBOL$section_content" \ - "$SPACESHIP_SECTION_SUFFIX" - -# Display prompt section without prefix and suffix -spaceship::section "$color" "$SPACESHIP_CHAR_SYMBOL" -``` - -## `spaceship::section::render` - -This function renders the section from the data tuple provided by [`spaceship::section`](#spaceshipsection). - -``` title="Signature" -spaceship::render section <data> -``` - -If `SPACESHIP_PROMPT_PREFIXES_SHOW` is `false` or if the section is not the first in the prompt, then prefix will be omitted. - -If `SPACESHIP_PROMPT_SUFFIXES_SHOW` is `false`, then suffix will be omitted. - -The `data` is a result of the `spaceship::section` function. For example: - -```zsh -local color="red" content="value" - -spaceship::section::render "$(spaceship::section --color "$color" "$content")" -#> %{%B%F{red}%}value%{%b%f%} -``` - -!!! tip - You can use for rendering subsections within complex sections. See the sources of [`git`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/git.zsh) or [`docker`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/docker.zsh) sections for an example. diff --git a/.zsh/themes/spaceship-prompt/docs/api/section.uk.md b/.zsh/themes/spaceship-prompt/docs/api/section.uk.md deleted file mode 100644 index 98d5607..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/section.uk.md +++ /dev/null @@ -1,106 +0,0 @@ -# Sections - -Sections are defined using `spaceship::section` function. This section takes the content of the section parameters for displaying, like prefix, suffix, color and symbol for the section. These values will be used for displaying the section. - -The `spaceship::section` is used to pack the section data into a data tuple. This data tuple is stored in the cache. During the rendering process, the data tuple for each section is being rendered into a section via `spaceship::section::render` function. - -## `spaceship::section` - -!!! tip - For creating a custom section, prefer using the [`spaceship::section::v4` function](#spaceshipsectionv4). The versioned function will ensure compatibility with new versions of Spaceship. - -This is the main function for defining a section. This takes section parameters and its content and transforms it into a data tuple. - -``` title="Signature" -spaceship::section [--color color] [--prefix prefix] [--suffix suffix] [--symbol symbol] <content> -``` - -It takes a single argument `content` which is the content of the section. Additionally, the function takes the following optional parameters: - -* `--color` — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -* `--prefix` — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -* `--symbol` — the symbol of the section. Can be any valid value or result of command execution. Will be rendered before the content. -* `--suffix` — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -The order of the parameters is not important. All of them are default to empty strings. - -!!! help - The `content`, `--prefix`, `--suffix` and `--symbol` can contain escapes to set additional foreground color, background color and other visual effects. - - Read more about escapes in [13 Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -## `spaceship::section::v4` - -This is an alias of `spaceship::section` function. It's the versioned function for creating a custom section. - -The signature of this function is the same as for `spaceship::section` function. - -Here is an example usage: - -```zsh -local content="value" - -spaceship::section::v4 \ - --color "$SPACESHIP_SECTION_COLOR" \ - --prefix "$SPACESHIP_SECTION_PREFIX" \ - --suffix "$SPACESHIP_SECTION_SUFFIX" \ - --symbol "$SPACESHIP_SECTION_SYMBOL" \ - "$content" -``` - -## `spaceship::section::v3` - -!!! warning - This function is introduced for compatibility with Spaceship v3 sections. It's recommended to use the [`spaceship::section::v4` function](#spaceshipsectionv4) instead. - -This is a replacement for the `spaceship::section` function used in Spaceship v3. Use it for backward compatibility only. - -``` title="Signature" -spaceship::section <color> [prefix] <content> [suffix] -``` - -The `spaceship::section:v3` relies on the following arguments order: - -1. `color` _Required_ — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -2. `prefix` _Optional_ — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -3. `content` _Required_ — the content of the section. Can be any valid value or result of command execution. -4. `suffix` _Optional_ — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -Here is a simple example: - -```zsh -# Display prompt section with prefix and suffix -# Backslash is used to escape line ending -spaceship::section \ - "$SPACESHIP_SECTION_COLOR" \ - "$SPACESHIP_SECTION_PREFIX" \ - "$SPACESHIP_SECTION_SYMBOL$section_content" \ - "$SPACESHIP_SECTION_SUFFIX" - -# Display prompt section without prefix and suffix -spaceship::section "$color" "$SPACESHIP_CHAR_SYMBOL" -``` - -## `spaceship::section::render` - -This function renders the section from the data tuple provided by [`spaceship::section`](#spaceshipsection). - -``` title="Signature" -spaceship::render section <data> -``` - -If `SPACESHIP_PROMPT_PREFIXES_SHOW` is `false` or if the section is not the first in the prompt, then prefix will be omitted. - -If `SPACESHIP_PROMPT_SUFFIXES_SHOW` is `false`, then suffix will be omitted. - -The `data` is a result of the `spaceship::section` function. For example: - -```zsh -local color="red" content="value" - -spaceship::section::render "$(spaceship::section --color "$color" "$content")" -#> %{%B%F{red}%}value%{%b%f%} -``` - -!!! tip - You can use for rendering subsections within complex sections. See the sources of [`git`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/git.zsh) or [`docker`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/docker.zsh) sections for an example. diff --git a/.zsh/themes/spaceship-prompt/docs/api/section.zh.md b/.zsh/themes/spaceship-prompt/docs/api/section.zh.md deleted file mode 100644 index 98d5607..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/section.zh.md +++ /dev/null @@ -1,106 +0,0 @@ -# Sections - -Sections are defined using `spaceship::section` function. This section takes the content of the section parameters for displaying, like prefix, suffix, color and symbol for the section. These values will be used for displaying the section. - -The `spaceship::section` is used to pack the section data into a data tuple. This data tuple is stored in the cache. During the rendering process, the data tuple for each section is being rendered into a section via `spaceship::section::render` function. - -## `spaceship::section` - -!!! tip - For creating a custom section, prefer using the [`spaceship::section::v4` function](#spaceshipsectionv4). The versioned function will ensure compatibility with new versions of Spaceship. - -This is the main function for defining a section. This takes section parameters and its content and transforms it into a data tuple. - -``` title="Signature" -spaceship::section [--color color] [--prefix prefix] [--suffix suffix] [--symbol symbol] <content> -``` - -It takes a single argument `content` which is the content of the section. Additionally, the function takes the following optional parameters: - -* `--color` — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -* `--prefix` — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -* `--symbol` — the symbol of the section. Can be any valid value or result of command execution. Will be rendered before the content. -* `--suffix` — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -The order of the parameters is not important. All of them are default to empty strings. - -!!! help - The `content`, `--prefix`, `--suffix` and `--symbol` can contain escapes to set additional foreground color, background color and other visual effects. - - Read more about escapes in [13 Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -## `spaceship::section::v4` - -This is an alias of `spaceship::section` function. It's the versioned function for creating a custom section. - -The signature of this function is the same as for `spaceship::section` function. - -Here is an example usage: - -```zsh -local content="value" - -spaceship::section::v4 \ - --color "$SPACESHIP_SECTION_COLOR" \ - --prefix "$SPACESHIP_SECTION_PREFIX" \ - --suffix "$SPACESHIP_SECTION_SUFFIX" \ - --symbol "$SPACESHIP_SECTION_SYMBOL" \ - "$content" -``` - -## `spaceship::section::v3` - -!!! warning - This function is introduced for compatibility with Spaceship v3 sections. It's recommended to use the [`spaceship::section::v4` function](#spaceshipsectionv4) instead. - -This is a replacement for the `spaceship::section` function used in Spaceship v3. Use it for backward compatibility only. - -``` title="Signature" -spaceship::section <color> [prefix] <content> [suffix] -``` - -The `spaceship::section:v3` relies on the following arguments order: - -1. `color` _Required_ — color for displaying the `content`. Can be any of [basic colors](https://wiki.archlinux.org/index.php/zsh#Colors) or [color codes](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg). -2. `prefix` _Optional_ — prefix before `content`. Usually, it's the value of `SPACESHIP_<SECTION>_PREFIX`. -3. `content` _Required_ — the content of the section. Can be any valid value or result of command execution. -4. `suffix` _Optional_ — suffix after `content`. Usually, it's the value of `SPACESHIP_<SECTION>_SUFFIX`. - -Here is a simple example: - -```zsh -# Display prompt section with prefix and suffix -# Backslash is used to escape line ending -spaceship::section \ - "$SPACESHIP_SECTION_COLOR" \ - "$SPACESHIP_SECTION_PREFIX" \ - "$SPACESHIP_SECTION_SYMBOL$section_content" \ - "$SPACESHIP_SECTION_SUFFIX" - -# Display prompt section without prefix and suffix -spaceship::section "$color" "$SPACESHIP_CHAR_SYMBOL" -``` - -## `spaceship::section::render` - -This function renders the section from the data tuple provided by [`spaceship::section`](#spaceshipsection). - -``` title="Signature" -spaceship::render section <data> -``` - -If `SPACESHIP_PROMPT_PREFIXES_SHOW` is `false` or if the section is not the first in the prompt, then prefix will be omitted. - -If `SPACESHIP_PROMPT_SUFFIXES_SHOW` is `false`, then suffix will be omitted. - -The `data` is a result of the `spaceship::section` function. For example: - -```zsh -local color="red" content="value" - -spaceship::section::render "$(spaceship::section --color "$color" "$content")" -#> %{%B%F{red}%}value%{%b%f%} -``` - -!!! tip - You can use for rendering subsections within complex sections. See the sources of [`git`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/git.zsh) or [`docker`](https://github.com/spaceship-prompt/spaceship-prompt/blob/master/sections/docker.zsh) sections for an example. diff --git a/.zsh/themes/spaceship-prompt/docs/api/testkit.de.md b/.zsh/themes/spaceship-prompt/docs/api/testkit.de.md deleted file mode 100644 index bf8ff33..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/testkit.de.md +++ /dev/null @@ -1,66 +0,0 @@ -# Testing utilities - -This set of utilities are aimed to help you to test your custom sections. They are useful to render prompts as string for checking the rendered output. - -For example, here's an example of a testing with shunit2: - -```zsh -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -# Setup shunit2 hook -oneTimeSetUp() { - export TERM="xterm-256color" - - SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true - SPACESHIP_PROMPT_ADD_NEWLINE=false - SPACESHIP_PROMPT_ORDER=(char) - - source "spaceship.zsh" -} - -# Clean-up shunit2 hook -oneTimeTearDown() { - unset SPACESHIP_PROMPT_FIRST_PREFIX_SHOW - unset SPACESHIP_PROMPT_ADD_NEWLINE - unset SPACESHIP_PROMPT_ORDER -} - -# Test case -test_char() { - SPACESHIP_CHAR_COLOR_SUCCESS=blue - - # Here we render the prompt as a string - local actual="$(spaceship::testkit::render_prompt)" - local expected="%{%B%F{$SPACESHIP_CHAR_COLOR_SUCCESS}%}➜ %{%b%f%}" - - assertEquals "render char" "$expected" "$actual" -} - -source tests/shunit2/shunit2 -``` - -## `spaceship::testkit::render_prompt` - -Renders the value of `PROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_prompt -``` - -## `spaceship::testkit::render_rprompt` - -Renders the value of `RPROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_rprompt -``` - -## `spaceship::testkit::render_ps2` - -Renders the value of `PS2` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_ps2 -``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/testkit.fr.md b/.zsh/themes/spaceship-prompt/docs/api/testkit.fr.md deleted file mode 100644 index bf8ff33..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/testkit.fr.md +++ /dev/null @@ -1,66 +0,0 @@ -# Testing utilities - -This set of utilities are aimed to help you to test your custom sections. They are useful to render prompts as string for checking the rendered output. - -For example, here's an example of a testing with shunit2: - -```zsh -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -# Setup shunit2 hook -oneTimeSetUp() { - export TERM="xterm-256color" - - SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true - SPACESHIP_PROMPT_ADD_NEWLINE=false - SPACESHIP_PROMPT_ORDER=(char) - - source "spaceship.zsh" -} - -# Clean-up shunit2 hook -oneTimeTearDown() { - unset SPACESHIP_PROMPT_FIRST_PREFIX_SHOW - unset SPACESHIP_PROMPT_ADD_NEWLINE - unset SPACESHIP_PROMPT_ORDER -} - -# Test case -test_char() { - SPACESHIP_CHAR_COLOR_SUCCESS=blue - - # Here we render the prompt as a string - local actual="$(spaceship::testkit::render_prompt)" - local expected="%{%B%F{$SPACESHIP_CHAR_COLOR_SUCCESS}%}➜ %{%b%f%}" - - assertEquals "render char" "$expected" "$actual" -} - -source tests/shunit2/shunit2 -``` - -## `spaceship::testkit::render_prompt` - -Renders the value of `PROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_prompt -``` - -## `spaceship::testkit::render_rprompt` - -Renders the value of `RPROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_rprompt -``` - -## `spaceship::testkit::render_ps2` - -Renders the value of `PS2` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_ps2 -``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/testkit.md b/.zsh/themes/spaceship-prompt/docs/api/testkit.md deleted file mode 100644 index bf8ff33..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/testkit.md +++ /dev/null @@ -1,66 +0,0 @@ -# Testing utilities - -This set of utilities are aimed to help you to test your custom sections. They are useful to render prompts as string for checking the rendered output. - -For example, here's an example of a testing with shunit2: - -```zsh -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -# Setup shunit2 hook -oneTimeSetUp() { - export TERM="xterm-256color" - - SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true - SPACESHIP_PROMPT_ADD_NEWLINE=false - SPACESHIP_PROMPT_ORDER=(char) - - source "spaceship.zsh" -} - -# Clean-up shunit2 hook -oneTimeTearDown() { - unset SPACESHIP_PROMPT_FIRST_PREFIX_SHOW - unset SPACESHIP_PROMPT_ADD_NEWLINE - unset SPACESHIP_PROMPT_ORDER -} - -# Test case -test_char() { - SPACESHIP_CHAR_COLOR_SUCCESS=blue - - # Here we render the prompt as a string - local actual="$(spaceship::testkit::render_prompt)" - local expected="%{%B%F{$SPACESHIP_CHAR_COLOR_SUCCESS}%}➜ %{%b%f%}" - - assertEquals "render char" "$expected" "$actual" -} - -source tests/shunit2/shunit2 -``` - -## `spaceship::testkit::render_prompt` - -Renders the value of `PROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_prompt -``` - -## `spaceship::testkit::render_rprompt` - -Renders the value of `RPROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_rprompt -``` - -## `spaceship::testkit::render_ps2` - -Renders the value of `PS2` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_ps2 -``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/testkit.uk.md b/.zsh/themes/spaceship-prompt/docs/api/testkit.uk.md deleted file mode 100644 index bf8ff33..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/testkit.uk.md +++ /dev/null @@ -1,66 +0,0 @@ -# Testing utilities - -This set of utilities are aimed to help you to test your custom sections. They are useful to render prompts as string for checking the rendered output. - -For example, here's an example of a testing with shunit2: - -```zsh -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -# Setup shunit2 hook -oneTimeSetUp() { - export TERM="xterm-256color" - - SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true - SPACESHIP_PROMPT_ADD_NEWLINE=false - SPACESHIP_PROMPT_ORDER=(char) - - source "spaceship.zsh" -} - -# Clean-up shunit2 hook -oneTimeTearDown() { - unset SPACESHIP_PROMPT_FIRST_PREFIX_SHOW - unset SPACESHIP_PROMPT_ADD_NEWLINE - unset SPACESHIP_PROMPT_ORDER -} - -# Test case -test_char() { - SPACESHIP_CHAR_COLOR_SUCCESS=blue - - # Here we render the prompt as a string - local actual="$(spaceship::testkit::render_prompt)" - local expected="%{%B%F{$SPACESHIP_CHAR_COLOR_SUCCESS}%}➜ %{%b%f%}" - - assertEquals "render char" "$expected" "$actual" -} - -source tests/shunit2/shunit2 -``` - -## `spaceship::testkit::render_prompt` - -Renders the value of `PROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_prompt -``` - -## `spaceship::testkit::render_rprompt` - -Renders the value of `RPROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_rprompt -``` - -## `spaceship::testkit::render_ps2` - -Renders the value of `PS2` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_ps2 -``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/testkit.zh.md b/.zsh/themes/spaceship-prompt/docs/api/testkit.zh.md deleted file mode 100644 index bf8ff33..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/testkit.zh.md +++ /dev/null @@ -1,66 +0,0 @@ -# Testing utilities - -This set of utilities are aimed to help you to test your custom sections. They are useful to render prompts as string for checking the rendered output. - -For example, here's an example of a testing with shunit2: - -```zsh -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -# Setup shunit2 hook -oneTimeSetUp() { - export TERM="xterm-256color" - - SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true - SPACESHIP_PROMPT_ADD_NEWLINE=false - SPACESHIP_PROMPT_ORDER=(char) - - source "spaceship.zsh" -} - -# Clean-up shunit2 hook -oneTimeTearDown() { - unset SPACESHIP_PROMPT_FIRST_PREFIX_SHOW - unset SPACESHIP_PROMPT_ADD_NEWLINE - unset SPACESHIP_PROMPT_ORDER -} - -# Test case -test_char() { - SPACESHIP_CHAR_COLOR_SUCCESS=blue - - # Here we render the prompt as a string - local actual="$(spaceship::testkit::render_prompt)" - local expected="%{%B%F{$SPACESHIP_CHAR_COLOR_SUCCESS}%}➜ %{%b%f%}" - - assertEquals "render char" "$expected" "$actual" -} - -source tests/shunit2/shunit2 -``` - -## `spaceship::testkit::render_prompt` - -Renders the value of `PROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_prompt -``` - -## `spaceship::testkit::render_rprompt` - -Renders the value of `RPROMPT` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_rprompt -``` - -## `spaceship::testkit::render_ps2` - -Renders the value of `PS2` variable and prints it as a string. - -``` title="Signature" -spaceship::testkit::render_ps2 -``` diff --git a/.zsh/themes/spaceship-prompt/docs/api/utils.de.md b/.zsh/themes/spaceship-prompt/docs/api/utils.de.md deleted file mode 100644 index dedd10d..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/utils.de.md +++ /dev/null @@ -1,199 +0,0 @@ -# General utilities - -Below you can find a list of general purpose utilities. - -## `spaceship::exists` - -``` title="Signature" -spaceship::exists <command> -``` - -This command validates that given program is available for execution. It checks for PATH binaries, functions, and builtins. It returns zero exit code if a `command` exists and non-zero code otherwise. - -You can use this utility to check if some program is installed and perform actions conditionally. For example, you can either return an error and exit or continue script's execution. For example: - -```zsh -# Check multiple commands for existing -if spaceship::exists nvm; then - # extract nvm version -elif spaceship::exists node; then - # extract node version -else - return -fi - -# Do nothing if docker is not installed -spaceship::exists docker || return -``` - -## `spaceship::defined` - -``` title="Signature" -spaceship::defined <function> -``` - -The same as [`spaceship::exists`](#spaceshipexists), but for functions. It returns zero exit code if a `function` has been defined previously and non-zero if `function` hasn't. - -You can use this utility to check if a user has previously defined a function or not. For example: - -```zsh -# Check if section has been defined -if spaceship::defined spaceship_section; then - spaceship_section -else - # section is not found -fi -``` - -## `spaceship::is_git` - -This utility returns zero exit code if a current working directory is a Git repository and non-zero if it's not. For example: - -```zsh -# Return if current directory is not a git repository -spaceship::is_git || return -``` - -## `spaceship::is_hg` - -The same as [`spaceship::is_git`](#spaceshipisgit), but for Mercurial repositories. This utility returns zero exit code if a current working directory is a Mercurial repository and non-zero if it's not. - -```zsh -# Return if current directory is not a Mercurial repository -spaceship::is_hg || return -``` - -## `spaceship::is_section_async` - -Checks if a section is asynchronous or not by checking `SPACESHIP_<SECTION>_ASYNC` option. This utility returns zero exit code if a section is asynchronous and non-zero if it's not. - -If `SPACESHIP_PROMPT_ASYNC` is set to `false`, then all sections are considered to be synchronous. - -``` title="Signature" -spaceship::is_section_async <section> -``` - -1. `section` _Required_ — a section to be checked. - -Some sections are always synchronous, not matter what, to ensure correct work of the prompt. Those are: `user`, `dir`, `host`, `exec_time`, `async`, `line_sep`, `jobs`, `exit_code` and `char`. - -## `spaceship::is_prompt_async` - -Checks if the prompt works in asynchronous mode or not. This utility returns zero exit code if the prompt works in asynchronous mode and non-zero if it's not. - -Check if `SPACESHIP_PROMPT_ASYNC` is set to `true` and [`zsh-async` is loaded](/api/environment/#asynchronous-runtime). - -## `spaceship::deprecated` - -This utility checks if `option` variable is set and if it is, prints the `message`. The `message` supports escapes to set foreground color, background color and other visual effects. - -``` title="Signature" -spaceship::deprecated <option> [message] -``` - -1. `option` _Required_ — the name of a deprecated variable. If this variable is set (contains any value), then `"%B$deprecated%b is deprecated.` will be printed. `%B` and `%b` is escapes to set the bold style for text. -2. `message` _Optional_ — a string for additional deprecation message. Can contain prompt expansions. - -Read more about escapes in [Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -Here's an example of usage: - -```zsh -# Check if SPACESHIP_BATTERY_ALWAYS_SHOW is set -spaceship::deprecated SPACESHIP_BATTERY_ALWAYS_SHOW "Use %BSPACESHIP_BATTERY_SHOW='always'%b instead." -#> SPACESHIP_BATTERY_ALWAYS_SHOW is deprecated. Use SPACESHIP_BATTERY_SHOW='always' instead. -``` - -## `spaceship::displaytime` - -This utility converts `seconds` into a human-readable format. It splits `seconds` into days (`d`), hours (`h`), minutes (`m`) and seconds (`s`). - -``` title="Signature" -spaceship::displaytime <seconds> [precision] -``` - -1. `seconds` _Required_ — seconds for conversion into the readable format. -1. `precision` _Optional_ — precision of the output. Default value is `1`. - -The usage example looks like this: - -```zsh -spaceship::displaytime 123456 -#> 1d 10h 17m 36.0s - -paceship::displaytime 123.45 2 -#> 2m 3.45s -``` - -## `spaceship::union` - -A utility for performing a union (intersection) of arrays. It lists the contents found in two or more arrays. - -Spaceship uses this utility internally for resolution of sections that need to be sourced. - -``` title="Signature" -spaceship::union <arr1[ arr2[ ...]]> -``` - -1. `arr...` — a list of arrays. - -Here is an example: - -```zsh -arr1=('a' 'b' 'c') -arr2=('b' 'c' 'd') -arr3=('c' 'd' 'e') -spaceship::union $arr1 $arr2 $arr3 -#> a b c d e -``` - -## `spaceship::upsearch` - -Performs an upward search for a specific file or directory. Returns the path of the first found file or directory. Goes upwards up to the repository or system root directory. Useful for understanding the context of a current directory. - -``` title="Signature" -spaceship::upsearch [--silent] <paths...> -``` - -1. `paths...` _Required_ — a list of paths to search. -2. `--silent` or `-s` _Optional_ — if set, then the utility will return zero exit code, if at least one of `paths` is found and non-zero, if not. - -This can be used for detecting project context or finding a specific file upwards. - -```zsh -# Understanding the project context -spaceship::upsearch -s package.json node_modules && echo "Node project detected." - -# Finding a specific file upwards -spaceship::upsearch package.json -#> /path/to/project/package.json -``` - -## `spaceship::datafile` - -This utility queries data files for a specific key. It returns the value of the key. Exits with non-zero code when the file type is unknown, data cannot be read, or the key is not found. - -``` title="Signature" -spaceship::datafile --<type> <file> [key] -``` - -1. `--type` _Required_ — a type of the data file. Can be `json`, `yaml`, `toml` or `xml`. -2. `file` _Required_ — a path to the data file. -3. `key` _Optional_ — a key to query within a data file. - -You can use this utility to query data from a data file: - -```zsh -spaceship::datafile --json package.json "author.name" -#> "John Doe" -``` - -It needs the following tools for reading data files: - -* JSON — [`jq`](https://stedolan.github.io/jq/), [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/), [`node`](https://nodejs.org/) -* YAML — [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/) -* TOML — `tomlq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) -* XML — `xq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) - -!!! tip - The most universal solution for reading data files is to use [`python-yq`](https://kislyuk.github.io/yq/). diff --git a/.zsh/themes/spaceship-prompt/docs/api/utils.fr.md b/.zsh/themes/spaceship-prompt/docs/api/utils.fr.md deleted file mode 100644 index dedd10d..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/utils.fr.md +++ /dev/null @@ -1,199 +0,0 @@ -# General utilities - -Below you can find a list of general purpose utilities. - -## `spaceship::exists` - -``` title="Signature" -spaceship::exists <command> -``` - -This command validates that given program is available for execution. It checks for PATH binaries, functions, and builtins. It returns zero exit code if a `command` exists and non-zero code otherwise. - -You can use this utility to check if some program is installed and perform actions conditionally. For example, you can either return an error and exit or continue script's execution. For example: - -```zsh -# Check multiple commands for existing -if spaceship::exists nvm; then - # extract nvm version -elif spaceship::exists node; then - # extract node version -else - return -fi - -# Do nothing if docker is not installed -spaceship::exists docker || return -``` - -## `spaceship::defined` - -``` title="Signature" -spaceship::defined <function> -``` - -The same as [`spaceship::exists`](#spaceshipexists), but for functions. It returns zero exit code if a `function` has been defined previously and non-zero if `function` hasn't. - -You can use this utility to check if a user has previously defined a function or not. For example: - -```zsh -# Check if section has been defined -if spaceship::defined spaceship_section; then - spaceship_section -else - # section is not found -fi -``` - -## `spaceship::is_git` - -This utility returns zero exit code if a current working directory is a Git repository and non-zero if it's not. For example: - -```zsh -# Return if current directory is not a git repository -spaceship::is_git || return -``` - -## `spaceship::is_hg` - -The same as [`spaceship::is_git`](#spaceshipisgit), but for Mercurial repositories. This utility returns zero exit code if a current working directory is a Mercurial repository and non-zero if it's not. - -```zsh -# Return if current directory is not a Mercurial repository -spaceship::is_hg || return -``` - -## `spaceship::is_section_async` - -Checks if a section is asynchronous or not by checking `SPACESHIP_<SECTION>_ASYNC` option. This utility returns zero exit code if a section is asynchronous and non-zero if it's not. - -If `SPACESHIP_PROMPT_ASYNC` is set to `false`, then all sections are considered to be synchronous. - -``` title="Signature" -spaceship::is_section_async <section> -``` - -1. `section` _Required_ — a section to be checked. - -Some sections are always synchronous, not matter what, to ensure correct work of the prompt. Those are: `user`, `dir`, `host`, `exec_time`, `async`, `line_sep`, `jobs`, `exit_code` and `char`. - -## `spaceship::is_prompt_async` - -Checks if the prompt works in asynchronous mode or not. This utility returns zero exit code if the prompt works in asynchronous mode and non-zero if it's not. - -Check if `SPACESHIP_PROMPT_ASYNC` is set to `true` and [`zsh-async` is loaded](/api/environment/#asynchronous-runtime). - -## `spaceship::deprecated` - -This utility checks if `option` variable is set and if it is, prints the `message`. The `message` supports escapes to set foreground color, background color and other visual effects. - -``` title="Signature" -spaceship::deprecated <option> [message] -``` - -1. `option` _Required_ — the name of a deprecated variable. If this variable is set (contains any value), then `"%B$deprecated%b is deprecated.` will be printed. `%B` and `%b` is escapes to set the bold style for text. -2. `message` _Optional_ — a string for additional deprecation message. Can contain prompt expansions. - -Read more about escapes in [Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -Here's an example of usage: - -```zsh -# Check if SPACESHIP_BATTERY_ALWAYS_SHOW is set -spaceship::deprecated SPACESHIP_BATTERY_ALWAYS_SHOW "Use %BSPACESHIP_BATTERY_SHOW='always'%b instead." -#> SPACESHIP_BATTERY_ALWAYS_SHOW is deprecated. Use SPACESHIP_BATTERY_SHOW='always' instead. -``` - -## `spaceship::displaytime` - -This utility converts `seconds` into a human-readable format. It splits `seconds` into days (`d`), hours (`h`), minutes (`m`) and seconds (`s`). - -``` title="Signature" -spaceship::displaytime <seconds> [precision] -``` - -1. `seconds` _Required_ — seconds for conversion into the readable format. -1. `precision` _Optional_ — precision of the output. Default value is `1`. - -The usage example looks like this: - -```zsh -spaceship::displaytime 123456 -#> 1d 10h 17m 36.0s - -paceship::displaytime 123.45 2 -#> 2m 3.45s -``` - -## `spaceship::union` - -A utility for performing a union (intersection) of arrays. It lists the contents found in two or more arrays. - -Spaceship uses this utility internally for resolution of sections that need to be sourced. - -``` title="Signature" -spaceship::union <arr1[ arr2[ ...]]> -``` - -1. `arr...` — a list of arrays. - -Here is an example: - -```zsh -arr1=('a' 'b' 'c') -arr2=('b' 'c' 'd') -arr3=('c' 'd' 'e') -spaceship::union $arr1 $arr2 $arr3 -#> a b c d e -``` - -## `spaceship::upsearch` - -Performs an upward search for a specific file or directory. Returns the path of the first found file or directory. Goes upwards up to the repository or system root directory. Useful for understanding the context of a current directory. - -``` title="Signature" -spaceship::upsearch [--silent] <paths...> -``` - -1. `paths...` _Required_ — a list of paths to search. -2. `--silent` or `-s` _Optional_ — if set, then the utility will return zero exit code, if at least one of `paths` is found and non-zero, if not. - -This can be used for detecting project context or finding a specific file upwards. - -```zsh -# Understanding the project context -spaceship::upsearch -s package.json node_modules && echo "Node project detected." - -# Finding a specific file upwards -spaceship::upsearch package.json -#> /path/to/project/package.json -``` - -## `spaceship::datafile` - -This utility queries data files for a specific key. It returns the value of the key. Exits with non-zero code when the file type is unknown, data cannot be read, or the key is not found. - -``` title="Signature" -spaceship::datafile --<type> <file> [key] -``` - -1. `--type` _Required_ — a type of the data file. Can be `json`, `yaml`, `toml` or `xml`. -2. `file` _Required_ — a path to the data file. -3. `key` _Optional_ — a key to query within a data file. - -You can use this utility to query data from a data file: - -```zsh -spaceship::datafile --json package.json "author.name" -#> "John Doe" -``` - -It needs the following tools for reading data files: - -* JSON — [`jq`](https://stedolan.github.io/jq/), [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/), [`node`](https://nodejs.org/) -* YAML — [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/) -* TOML — `tomlq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) -* XML — `xq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) - -!!! tip - The most universal solution for reading data files is to use [`python-yq`](https://kislyuk.github.io/yq/). diff --git a/.zsh/themes/spaceship-prompt/docs/api/utils.md b/.zsh/themes/spaceship-prompt/docs/api/utils.md deleted file mode 100644 index dedd10d..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/utils.md +++ /dev/null @@ -1,199 +0,0 @@ -# General utilities - -Below you can find a list of general purpose utilities. - -## `spaceship::exists` - -``` title="Signature" -spaceship::exists <command> -``` - -This command validates that given program is available for execution. It checks for PATH binaries, functions, and builtins. It returns zero exit code if a `command` exists and non-zero code otherwise. - -You can use this utility to check if some program is installed and perform actions conditionally. For example, you can either return an error and exit or continue script's execution. For example: - -```zsh -# Check multiple commands for existing -if spaceship::exists nvm; then - # extract nvm version -elif spaceship::exists node; then - # extract node version -else - return -fi - -# Do nothing if docker is not installed -spaceship::exists docker || return -``` - -## `spaceship::defined` - -``` title="Signature" -spaceship::defined <function> -``` - -The same as [`spaceship::exists`](#spaceshipexists), but for functions. It returns zero exit code if a `function` has been defined previously and non-zero if `function` hasn't. - -You can use this utility to check if a user has previously defined a function or not. For example: - -```zsh -# Check if section has been defined -if spaceship::defined spaceship_section; then - spaceship_section -else - # section is not found -fi -``` - -## `spaceship::is_git` - -This utility returns zero exit code if a current working directory is a Git repository and non-zero if it's not. For example: - -```zsh -# Return if current directory is not a git repository -spaceship::is_git || return -``` - -## `spaceship::is_hg` - -The same as [`spaceship::is_git`](#spaceshipisgit), but for Mercurial repositories. This utility returns zero exit code if a current working directory is a Mercurial repository and non-zero if it's not. - -```zsh -# Return if current directory is not a Mercurial repository -spaceship::is_hg || return -``` - -## `spaceship::is_section_async` - -Checks if a section is asynchronous or not by checking `SPACESHIP_<SECTION>_ASYNC` option. This utility returns zero exit code if a section is asynchronous and non-zero if it's not. - -If `SPACESHIP_PROMPT_ASYNC` is set to `false`, then all sections are considered to be synchronous. - -``` title="Signature" -spaceship::is_section_async <section> -``` - -1. `section` _Required_ — a section to be checked. - -Some sections are always synchronous, not matter what, to ensure correct work of the prompt. Those are: `user`, `dir`, `host`, `exec_time`, `async`, `line_sep`, `jobs`, `exit_code` and `char`. - -## `spaceship::is_prompt_async` - -Checks if the prompt works in asynchronous mode or not. This utility returns zero exit code if the prompt works in asynchronous mode and non-zero if it's not. - -Check if `SPACESHIP_PROMPT_ASYNC` is set to `true` and [`zsh-async` is loaded](/api/environment/#asynchronous-runtime). - -## `spaceship::deprecated` - -This utility checks if `option` variable is set and if it is, prints the `message`. The `message` supports escapes to set foreground color, background color and other visual effects. - -``` title="Signature" -spaceship::deprecated <option> [message] -``` - -1. `option` _Required_ — the name of a deprecated variable. If this variable is set (contains any value), then `"%B$deprecated%b is deprecated.` will be printed. `%B` and `%b` is escapes to set the bold style for text. -2. `message` _Optional_ — a string for additional deprecation message. Can contain prompt expansions. - -Read more about escapes in [Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -Here's an example of usage: - -```zsh -# Check if SPACESHIP_BATTERY_ALWAYS_SHOW is set -spaceship::deprecated SPACESHIP_BATTERY_ALWAYS_SHOW "Use %BSPACESHIP_BATTERY_SHOW='always'%b instead." -#> SPACESHIP_BATTERY_ALWAYS_SHOW is deprecated. Use SPACESHIP_BATTERY_SHOW='always' instead. -``` - -## `spaceship::displaytime` - -This utility converts `seconds` into a human-readable format. It splits `seconds` into days (`d`), hours (`h`), minutes (`m`) and seconds (`s`). - -``` title="Signature" -spaceship::displaytime <seconds> [precision] -``` - -1. `seconds` _Required_ — seconds for conversion into the readable format. -1. `precision` _Optional_ — precision of the output. Default value is `1`. - -The usage example looks like this: - -```zsh -spaceship::displaytime 123456 -#> 1d 10h 17m 36.0s - -paceship::displaytime 123.45 2 -#> 2m 3.45s -``` - -## `spaceship::union` - -A utility for performing a union (intersection) of arrays. It lists the contents found in two or more arrays. - -Spaceship uses this utility internally for resolution of sections that need to be sourced. - -``` title="Signature" -spaceship::union <arr1[ arr2[ ...]]> -``` - -1. `arr...` — a list of arrays. - -Here is an example: - -```zsh -arr1=('a' 'b' 'c') -arr2=('b' 'c' 'd') -arr3=('c' 'd' 'e') -spaceship::union $arr1 $arr2 $arr3 -#> a b c d e -``` - -## `spaceship::upsearch` - -Performs an upward search for a specific file or directory. Returns the path of the first found file or directory. Goes upwards up to the repository or system root directory. Useful for understanding the context of a current directory. - -``` title="Signature" -spaceship::upsearch [--silent] <paths...> -``` - -1. `paths...` _Required_ — a list of paths to search. -2. `--silent` or `-s` _Optional_ — if set, then the utility will return zero exit code, if at least one of `paths` is found and non-zero, if not. - -This can be used for detecting project context or finding a specific file upwards. - -```zsh -# Understanding the project context -spaceship::upsearch -s package.json node_modules && echo "Node project detected." - -# Finding a specific file upwards -spaceship::upsearch package.json -#> /path/to/project/package.json -``` - -## `spaceship::datafile` - -This utility queries data files for a specific key. It returns the value of the key. Exits with non-zero code when the file type is unknown, data cannot be read, or the key is not found. - -``` title="Signature" -spaceship::datafile --<type> <file> [key] -``` - -1. `--type` _Required_ — a type of the data file. Can be `json`, `yaml`, `toml` or `xml`. -2. `file` _Required_ — a path to the data file. -3. `key` _Optional_ — a key to query within a data file. - -You can use this utility to query data from a data file: - -```zsh -spaceship::datafile --json package.json "author.name" -#> "John Doe" -``` - -It needs the following tools for reading data files: - -* JSON — [`jq`](https://stedolan.github.io/jq/), [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/), [`node`](https://nodejs.org/) -* YAML — [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/) -* TOML — `tomlq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) -* XML — `xq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) - -!!! tip - The most universal solution for reading data files is to use [`python-yq`](https://kislyuk.github.io/yq/). diff --git a/.zsh/themes/spaceship-prompt/docs/api/utils.uk.md b/.zsh/themes/spaceship-prompt/docs/api/utils.uk.md deleted file mode 100644 index dedd10d..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/utils.uk.md +++ /dev/null @@ -1,199 +0,0 @@ -# General utilities - -Below you can find a list of general purpose utilities. - -## `spaceship::exists` - -``` title="Signature" -spaceship::exists <command> -``` - -This command validates that given program is available for execution. It checks for PATH binaries, functions, and builtins. It returns zero exit code if a `command` exists and non-zero code otherwise. - -You can use this utility to check if some program is installed and perform actions conditionally. For example, you can either return an error and exit or continue script's execution. For example: - -```zsh -# Check multiple commands for existing -if spaceship::exists nvm; then - # extract nvm version -elif spaceship::exists node; then - # extract node version -else - return -fi - -# Do nothing if docker is not installed -spaceship::exists docker || return -``` - -## `spaceship::defined` - -``` title="Signature" -spaceship::defined <function> -``` - -The same as [`spaceship::exists`](#spaceshipexists), but for functions. It returns zero exit code if a `function` has been defined previously and non-zero if `function` hasn't. - -You can use this utility to check if a user has previously defined a function or not. For example: - -```zsh -# Check if section has been defined -if spaceship::defined spaceship_section; then - spaceship_section -else - # section is not found -fi -``` - -## `spaceship::is_git` - -This utility returns zero exit code if a current working directory is a Git repository and non-zero if it's not. For example: - -```zsh -# Return if current directory is not a git repository -spaceship::is_git || return -``` - -## `spaceship::is_hg` - -The same as [`spaceship::is_git`](#spaceshipisgit), but for Mercurial repositories. This utility returns zero exit code if a current working directory is a Mercurial repository and non-zero if it's not. - -```zsh -# Return if current directory is not a Mercurial repository -spaceship::is_hg || return -``` - -## `spaceship::is_section_async` - -Checks if a section is asynchronous or not by checking `SPACESHIP_<SECTION>_ASYNC` option. This utility returns zero exit code if a section is asynchronous and non-zero if it's not. - -If `SPACESHIP_PROMPT_ASYNC` is set to `false`, then all sections are considered to be synchronous. - -``` title="Signature" -spaceship::is_section_async <section> -``` - -1. `section` _Required_ — a section to be checked. - -Some sections are always synchronous, not matter what, to ensure correct work of the prompt. Those are: `user`, `dir`, `host`, `exec_time`, `async`, `line_sep`, `jobs`, `exit_code` and `char`. - -## `spaceship::is_prompt_async` - -Checks if the prompt works in asynchronous mode or not. This utility returns zero exit code if the prompt works in asynchronous mode and non-zero if it's not. - -Check if `SPACESHIP_PROMPT_ASYNC` is set to `true` and [`zsh-async` is loaded](/api/environment/#asynchronous-runtime). - -## `spaceship::deprecated` - -This utility checks if `option` variable is set and if it is, prints the `message`. The `message` supports escapes to set foreground color, background color and other visual effects. - -``` title="Signature" -spaceship::deprecated <option> [message] -``` - -1. `option` _Required_ — the name of a deprecated variable. If this variable is set (contains any value), then `"%B$deprecated%b is deprecated.` will be printed. `%B` and `%b` is escapes to set the bold style for text. -2. `message` _Optional_ — a string for additional deprecation message. Can contain prompt expansions. - -Read more about escapes in [Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -Here's an example of usage: - -```zsh -# Check if SPACESHIP_BATTERY_ALWAYS_SHOW is set -spaceship::deprecated SPACESHIP_BATTERY_ALWAYS_SHOW "Use %BSPACESHIP_BATTERY_SHOW='always'%b instead." -#> SPACESHIP_BATTERY_ALWAYS_SHOW is deprecated. Use SPACESHIP_BATTERY_SHOW='always' instead. -``` - -## `spaceship::displaytime` - -This utility converts `seconds` into a human-readable format. It splits `seconds` into days (`d`), hours (`h`), minutes (`m`) and seconds (`s`). - -``` title="Signature" -spaceship::displaytime <seconds> [precision] -``` - -1. `seconds` _Required_ — seconds for conversion into the readable format. -1. `precision` _Optional_ — precision of the output. Default value is `1`. - -The usage example looks like this: - -```zsh -spaceship::displaytime 123456 -#> 1d 10h 17m 36.0s - -paceship::displaytime 123.45 2 -#> 2m 3.45s -``` - -## `spaceship::union` - -A utility for performing a union (intersection) of arrays. It lists the contents found in two or more arrays. - -Spaceship uses this utility internally for resolution of sections that need to be sourced. - -``` title="Signature" -spaceship::union <arr1[ arr2[ ...]]> -``` - -1. `arr...` — a list of arrays. - -Here is an example: - -```zsh -arr1=('a' 'b' 'c') -arr2=('b' 'c' 'd') -arr3=('c' 'd' 'e') -spaceship::union $arr1 $arr2 $arr3 -#> a b c d e -``` - -## `spaceship::upsearch` - -Performs an upward search for a specific file or directory. Returns the path of the first found file or directory. Goes upwards up to the repository or system root directory. Useful for understanding the context of a current directory. - -``` title="Signature" -spaceship::upsearch [--silent] <paths...> -``` - -1. `paths...` _Required_ — a list of paths to search. -2. `--silent` or `-s` _Optional_ — if set, then the utility will return zero exit code, if at least one of `paths` is found and non-zero, if not. - -This can be used for detecting project context or finding a specific file upwards. - -```zsh -# Understanding the project context -spaceship::upsearch -s package.json node_modules && echo "Node project detected." - -# Finding a specific file upwards -spaceship::upsearch package.json -#> /path/to/project/package.json -``` - -## `spaceship::datafile` - -This utility queries data files for a specific key. It returns the value of the key. Exits with non-zero code when the file type is unknown, data cannot be read, or the key is not found. - -``` title="Signature" -spaceship::datafile --<type> <file> [key] -``` - -1. `--type` _Required_ — a type of the data file. Can be `json`, `yaml`, `toml` or `xml`. -2. `file` _Required_ — a path to the data file. -3. `key` _Optional_ — a key to query within a data file. - -You can use this utility to query data from a data file: - -```zsh -spaceship::datafile --json package.json "author.name" -#> "John Doe" -``` - -It needs the following tools for reading data files: - -* JSON — [`jq`](https://stedolan.github.io/jq/), [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/), [`node`](https://nodejs.org/) -* YAML — [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/) -* TOML — `tomlq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) -* XML — `xq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) - -!!! tip - The most universal solution for reading data files is to use [`python-yq`](https://kislyuk.github.io/yq/). diff --git a/.zsh/themes/spaceship-prompt/docs/api/utils.zh.md b/.zsh/themes/spaceship-prompt/docs/api/utils.zh.md deleted file mode 100644 index dedd10d..0000000 --- a/.zsh/themes/spaceship-prompt/docs/api/utils.zh.md +++ /dev/null @@ -1,199 +0,0 @@ -# General utilities - -Below you can find a list of general purpose utilities. - -## `spaceship::exists` - -``` title="Signature" -spaceship::exists <command> -``` - -This command validates that given program is available for execution. It checks for PATH binaries, functions, and builtins. It returns zero exit code if a `command` exists and non-zero code otherwise. - -You can use this utility to check if some program is installed and perform actions conditionally. For example, you can either return an error and exit or continue script's execution. For example: - -```zsh -# Check multiple commands for existing -if spaceship::exists nvm; then - # extract nvm version -elif spaceship::exists node; then - # extract node version -else - return -fi - -# Do nothing if docker is not installed -spaceship::exists docker || return -``` - -## `spaceship::defined` - -``` title="Signature" -spaceship::defined <function> -``` - -The same as [`spaceship::exists`](#spaceshipexists), but for functions. It returns zero exit code if a `function` has been defined previously and non-zero if `function` hasn't. - -You can use this utility to check if a user has previously defined a function or not. For example: - -```zsh -# Check if section has been defined -if spaceship::defined spaceship_section; then - spaceship_section -else - # section is not found -fi -``` - -## `spaceship::is_git` - -This utility returns zero exit code if a current working directory is a Git repository and non-zero if it's not. For example: - -```zsh -# Return if current directory is not a git repository -spaceship::is_git || return -``` - -## `spaceship::is_hg` - -The same as [`spaceship::is_git`](#spaceshipisgit), but for Mercurial repositories. This utility returns zero exit code if a current working directory is a Mercurial repository and non-zero if it's not. - -```zsh -# Return if current directory is not a Mercurial repository -spaceship::is_hg || return -``` - -## `spaceship::is_section_async` - -Checks if a section is asynchronous or not by checking `SPACESHIP_<SECTION>_ASYNC` option. This utility returns zero exit code if a section is asynchronous and non-zero if it's not. - -If `SPACESHIP_PROMPT_ASYNC` is set to `false`, then all sections are considered to be synchronous. - -``` title="Signature" -spaceship::is_section_async <section> -``` - -1. `section` _Required_ — a section to be checked. - -Some sections are always synchronous, not matter what, to ensure correct work of the prompt. Those are: `user`, `dir`, `host`, `exec_time`, `async`, `line_sep`, `jobs`, `exit_code` and `char`. - -## `spaceship::is_prompt_async` - -Checks if the prompt works in asynchronous mode or not. This utility returns zero exit code if the prompt works in asynchronous mode and non-zero if it's not. - -Check if `SPACESHIP_PROMPT_ASYNC` is set to `true` and [`zsh-async` is loaded](/api/environment/#asynchronous-runtime). - -## `spaceship::deprecated` - -This utility checks if `option` variable is set and if it is, prints the `message`. The `message` supports escapes to set foreground color, background color and other visual effects. - -``` title="Signature" -spaceship::deprecated <option> [message] -``` - -1. `option` _Required_ — the name of a deprecated variable. If this variable is set (contains any value), then `"%B$deprecated%b is deprecated.` will be printed. `%B` and `%b` is escapes to set the bold style for text. -2. `message` _Optional_ — a string for additional deprecation message. Can contain prompt expansions. - -Read more about escapes in [Prompt Expansion](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) section of Zsh documentation. - -Here's an example of usage: - -```zsh -# Check if SPACESHIP_BATTERY_ALWAYS_SHOW is set -spaceship::deprecated SPACESHIP_BATTERY_ALWAYS_SHOW "Use %BSPACESHIP_BATTERY_SHOW='always'%b instead." -#> SPACESHIP_BATTERY_ALWAYS_SHOW is deprecated. Use SPACESHIP_BATTERY_SHOW='always' instead. -``` - -## `spaceship::displaytime` - -This utility converts `seconds` into a human-readable format. It splits `seconds` into days (`d`), hours (`h`), minutes (`m`) and seconds (`s`). - -``` title="Signature" -spaceship::displaytime <seconds> [precision] -``` - -1. `seconds` _Required_ — seconds for conversion into the readable format. -1. `precision` _Optional_ — precision of the output. Default value is `1`. - -The usage example looks like this: - -```zsh -spaceship::displaytime 123456 -#> 1d 10h 17m 36.0s - -paceship::displaytime 123.45 2 -#> 2m 3.45s -``` - -## `spaceship::union` - -A utility for performing a union (intersection) of arrays. It lists the contents found in two or more arrays. - -Spaceship uses this utility internally for resolution of sections that need to be sourced. - -``` title="Signature" -spaceship::union <arr1[ arr2[ ...]]> -``` - -1. `arr...` — a list of arrays. - -Here is an example: - -```zsh -arr1=('a' 'b' 'c') -arr2=('b' 'c' 'd') -arr3=('c' 'd' 'e') -spaceship::union $arr1 $arr2 $arr3 -#> a b c d e -``` - -## `spaceship::upsearch` - -Performs an upward search for a specific file or directory. Returns the path of the first found file or directory. Goes upwards up to the repository or system root directory. Useful for understanding the context of a current directory. - -``` title="Signature" -spaceship::upsearch [--silent] <paths...> -``` - -1. `paths...` _Required_ — a list of paths to search. -2. `--silent` or `-s` _Optional_ — if set, then the utility will return zero exit code, if at least one of `paths` is found and non-zero, if not. - -This can be used for detecting project context or finding a specific file upwards. - -```zsh -# Understanding the project context -spaceship::upsearch -s package.json node_modules && echo "Node project detected." - -# Finding a specific file upwards -spaceship::upsearch package.json -#> /path/to/project/package.json -``` - -## `spaceship::datafile` - -This utility queries data files for a specific key. It returns the value of the key. Exits with non-zero code when the file type is unknown, data cannot be read, or the key is not found. - -``` title="Signature" -spaceship::datafile --<type> <file> [key] -``` - -1. `--type` _Required_ — a type of the data file. Can be `json`, `yaml`, `toml` or `xml`. -2. `file` _Required_ — a path to the data file. -3. `key` _Optional_ — a key to query within a data file. - -You can use this utility to query data from a data file: - -```zsh -spaceship::datafile --json package.json "author.name" -#> "John Doe" -``` - -It needs the following tools for reading data files: - -* JSON — [`jq`](https://stedolan.github.io/jq/), [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/), [`node`](https://nodejs.org/) -* YAML — [`yq`](https://mikefarah.gitbook.io/yq/) or [`python-yq`](https://kislyuk.github.io/yq/), [`python`](https://www.python.org/) -* TOML — `tomlq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) -* XML — `xq` (comes with [`python-yq`](https://kislyuk.github.io/yq/)) - -!!! tip - The most universal solution for reading data files is to use [`python-yq`](https://kislyuk.github.io/yq/). diff --git a/.zsh/themes/spaceship-prompt/docs/assets/FiraCodeNerd.woff2 b/.zsh/themes/spaceship-prompt/docs/assets/FiraCodeNerd.woff2 deleted file mode 100644 index b1ed1c6..0000000 Binary files a/.zsh/themes/spaceship-prompt/docs/assets/FiraCodeNerd.woff2 and /dev/null differ diff --git a/.zsh/themes/spaceship-prompt/docs/assets/favicon.ico b/.zsh/themes/spaceship-prompt/docs/assets/favicon.ico deleted file mode 100644 index 710a855..0000000 Binary files a/.zsh/themes/spaceship-prompt/docs/assets/favicon.ico and /dev/null differ diff --git a/.zsh/themes/spaceship-prompt/docs/assets/images/configurable.svg b/.zsh/themes/spaceship-prompt/docs/assets/images/configurable.svg deleted file mode 100644 index 3d17497..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/images/configurable.svg +++ /dev/null @@ -1 +0,0 @@ -<svg id="b7e1fa79-b025-4aca-abaf-9f282d3c3989" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="938.94952" height="517.98015" viewBox="0 0 938.94952 517.98015"><rect x="332.85372" y="513.66655" width="606.0958" height="2" fill="#e6e6e6"/><path d="M921.05069,543.28036c13.25,18.73,16.75,125.33,17.53,159.5.01995.77.04,1.5.05,2.19h33.54c.41-.73.79-1.45,1.15-2.19,19.88-39.24,8.85-86.29,8.27-88.67,1.50994,7.48-5.32,29.16-13.04,50.16C963.84073,599.70035,923.57071,546.54037,921.05069,543.28036Z" transform="translate(-130.52524 -191.00993)" fill="#e6e6e6"/><path d="M179.03705,288.03355a48.51181,48.51181,0,0,1,0-97.02362H620.56482a48.51181,48.51181,0,0,1,0,97.02362Z" transform="translate(-130.52524 -191.00993)" fill="#e6e6e6"/><rect x="94.68018" y="6.32763" width="86.36017" height="84.36837" fill="#fff"/><path d="M620.56482,197.33755h-44.645v84.36837h44.645a42.18418,42.18418,0,1,0,0-84.36837Z" transform="translate(-130.52524 -191.00993)" fill="#fff"/><rect x="270.33021" y="6.32763" width="85.77451" height="84.36837" fill="#fff"/><rect x="182.44649" y="6.32763" width="86.47758" height="84.36837" fill="#c34435"/><rect x="357.51085" y="6.32763" width="86.47758" height="84.36837" fill="#e6e6e6"/><path d="M223.79928,197.33755H179.037a42.18418,42.18418,0,1,0,0,84.36837h44.76224Z" transform="translate(-130.52524 -191.00993)" fill="#c34435"/><polygon points="45.408 64.735 33.663 49.636 40.493 44.323 46.053 51.473 64.839 31.644 71.12 37.595 45.408 64.735" fill="#fff"/><polygon points="218.363 64.735 206.618 49.636 213.448 44.323 219.008 51.473 237.794 31.644 244.075 37.595 218.363 64.735" fill="#fff"/><rect x="527.83156" y="221.01568" width="5.5092" height="37.0121" transform="translate(-144.4876 254.32544) rotate(-45)" fill="#fff"/><rect x="513.45755" y="236.76713" width="37.0121" height="5.5092" transform="translate(-144.08415 255.29944) rotate(-45)" fill="#fff"/><path d="M268.21618,264.81564a25.31051,25.31051,0,1,1,25.31051-25.31051A25.33906,25.33906,0,0,1,268.21618,264.81564Zm0-44.99646a19.686,19.686,0,1,0,19.68595,19.686A19.70807,19.70807,0,0,0,268.21618,219.81918Z" transform="translate(-130.52524 -191.00993)" fill="#e6e6e6"/><path d="M443.98361,264.81564a25.31051,25.31051,0,1,1,25.31051-25.31051A25.33906,25.33906,0,0,1,443.98361,264.81564Zm0-44.99646a19.686,19.686,0,1,0,19.68595,19.686A19.70807,19.70807,0,0,0,443.98361,219.81918Z" transform="translate(-130.52524 -191.00993)" fill="#e6e6e6"/><path d="M619.048,264.81564a25.31051,25.31051,0,1,1,25.31051-25.31051A25.33906,25.33906,0,0,1,619.048,264.81564Zm0-44.99646a19.686,19.686,0,1,0,19.686,19.686A19.70807,19.70807,0,0,0,619.048,219.81918Z" transform="translate(-130.52524 -191.00993)" fill="#e6e6e6"/><path d="M851.38353,464.45242l-10.62585,29.64052a10.34739,10.34739,0,0,0,4.37745,12.341l0,0a10.34739,10.34739,0,0,0,15.64572-7.69444l3.37227-30.03053,25.53922-84.42132L867.70025,373.6463Z" transform="translate(-130.52524 -191.00993)" fill="#a0616a"/><polygon points="711.991 497.265 727.598 497.265 727.598 345.449 692.127 344.739 711.991 497.265" fill="#a0616a"/><polygon points="642.467 497.265 658.074 497.265 658.074 345.449 622.603 344.739 642.467 497.265" fill="#a0616a"/><path d="M860.606,552.42086l-40.43711-4.25654-8.51307-44.69364-15.60731,45.40306-48.24075-4.966L767.67163,468.709c36.30995-24.67316,70.79615-24.13361,103.57574,0Z" transform="translate(-130.52524 -191.00993)" fill="#2f2e41"/><path d="M792.04624,694.741a12.67411,12.67411,0,0,1-14.27955,14.13116l-28.75209-3.89946a9.82627,9.82627,0,0,1-8.19677-11.2029v0a9.82627,9.82627,0,0,1,9.712-8.33211h4.74057l15.5969-14.21051c.15379,9.67931,7.2821,7.52995,19.06287,6.58536Z" transform="translate(-130.52524 -191.00993)" fill="#2f2e41"/><path d="M861.56968,694.741a12.67411,12.67411,0,0,1-14.27955,14.13116L818.538,704.97268a9.82627,9.82627,0,0,1-8.19677-11.2029v0a9.82627,9.82627,0,0,1,9.712-8.33211h4.74057l15.5969-14.21051c.15379,9.67931,7.2821,7.52995,19.06287,6.58536Z" transform="translate(-130.52524 -191.00993)" fill="#2f2e41"/><circle cx="675.63258" cy="78.17385" r="25.00716" fill="#a0616a"/><polygon points="707.379 120.207 676.165 123.045 676.165 95.377 692.481 85.445 707.379 120.207" fill="#a0616a"/><path d="M874.79448,479.3503c-31.40278-22.99491-69.10967-20.65841-110.67-2.83769,18.82984-53.30557,26.85059-102.985,12.06018-145.01157a33.436,33.436,0,0,1,25.14947-32.39292l5.35572-1.37007,26.24864,1.41884,24.64823,14.449A33.555,33.555,0,0,1,874.172,342.40115Z" transform="translate(-130.52524 -191.00993)" fill="#c34435"/><path d="M753.48317,458.777l-10.62584,29.64052a10.34738,10.34738,0,0,0,4.37744,12.341h0a10.34738,10.34738,0,0,0,15.64571-7.69443l3.37227-30.03053L791.792,378.61226,769.7999,367.97091Z" transform="translate(-130.52524 -191.00993)" fill="#a0616a"/><path d="M895.36775,400.60436H860.606V315.47362h0a47.95711,47.95711,0,0,1,23.64788,32.08749Z" transform="translate(-130.52524 -191.00993)" fill="#c34435"/><path d="M787.09191,255.64389a10.18217,10.18217,0,0,1-9.66538-.523,7.705,7.705,0,0,1-3.07332-8.83245c1.0544-2.71107,3.72255-4.40874,6.31141-5.73513a63.70442,63.70442,0,0,1,18.15276-6.06395c3.014-.52152,6.20577-.8082,9.0545.30589,1.40954.55125,2.67346,1.42439,4.07257,2.00156,2.57261,1.06127,5.44252,1.06591,8.16522,1.64159A19.92323,19.92323,0,0,1,833.345,248.3547a24.00724,24.00724,0,0,1,2.04864,5.3776,30.94533,30.94533,0,0,1-.04985,15.57471c-2.14128,8.08308-7.59126,15.50989-7.10076,23.85741-4.02949-2.34645-5.917-7.1238-9.2818-10.352a15.2743,15.2743,0,0,0-9.18029-4.158,4.85548,4.85548,0,0,1-2.68043-.68249,4.18309,4.18309,0,0,1-1.166-2.10784l-3.79068-11.87319c-.77146-2.41636-1.70321-5.0417-3.8836-6.33781a9.77178,9.77178,0,0,0-4.33638-1.05378,66.02557,66.02557,0,0,0-10.82686.10171" transform="translate(-130.52524 -191.00993)" fill="#2f2e41"/><path d="M795.33912,384.99706l-40.4371-15.6073,18.36389-49.48047a31.94213,31.94213,0,0,1,27.74857-20.75239h0Z" transform="translate(-130.52524 -191.00993)" fill="#c34435"/></svg> \ No newline at end of file diff --git a/.zsh/themes/spaceship-prompt/docs/assets/images/out-of-the-box.svg b/.zsh/themes/spaceship-prompt/docs/assets/images/out-of-the-box.svg deleted file mode 100644 index 300acfa..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/images/out-of-the-box.svg +++ /dev/null @@ -1 +0,0 @@ -<svg id="a5860ba0-ef67-4914-ac96-07e2ebcccb4f" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="1095.74023" height="664.03433" viewBox="0 0 1095.74023 664.03433"><title>abstract \ No newline at end of file diff --git a/.zsh/themes/spaceship-prompt/docs/assets/images/spaceship-demo.gif b/.zsh/themes/spaceship-prompt/docs/assets/images/spaceship-demo.gif deleted file mode 100644 index 2382f6f..0000000 Binary files a/.zsh/themes/spaceship-prompt/docs/assets/images/spaceship-demo.gif and /dev/null differ diff --git a/.zsh/themes/spaceship-prompt/docs/assets/images/spaceship-demo.svg b/.zsh/themes/spaceship-prompt/docs/assets/images/spaceship-demo.svg deleted file mode 100644 index 48cb6fd..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/images/spaceship-demo.svg +++ /dev/null @@ -1 +0,0 @@ -~~falsetrueccdcdProjects/spaceship/cdProjects/spaceship/spaceshipspaceshiponmainnnpminit-ynpminit-yAliastip:npmI-yWroteto/Users/denysd/Projects/spaceship/package.json:{"name":"spaceship","version":"1.0.0","description":"","main":"index.js","scripts":{"test":"echo\"Error:notestspecified\"&&exit1"},"keywords":[],"author":"","license":"ISC"}spaceshipis📦1.0.0spaceshiponmain[?]is📦1.0.0nvmuse18nvmuse18nvmuse18Nowusingnodev18.7.0(npmv8.15.0)spaceshipis📦1.0.0viav18.7.0spaceshipis📦1.0.0viav18.7.0spaceshiponmain[?]is📦1.0.0viav18.7.0ggitinitgitgitaddpackage.jsonspaceshiponmain[+]is📦1.0.0viav18.7.0gitaddpackage.jsongitcommit-m"Initialcommit"gitcommit-m"Initialcommit"gitcommit-m"Initialcommit"Aliastip:ggitcm"Initialcommit"[main(root-commit)58d0091]Initialcommit1filechanged,12insertions(+)createmode100644package.jsonspaceshiponmainis📦1.0.0viav18.7.0clearAliastip:clrspaceshipeditspaceshipedit"~/.spaceshiprc.zsh"4L,98B1#Replacesymbolsforpackages23#SPACESHIP_CHAR_SYMBOL="ᐅ"4#SPACESHIP_PACKAGE_SYMBOL="🗳"~<.zsh[+] CWD: /Users/denysd/Projects/spaceship Line: 3 Column: 13SPACESHIP_CHAR_SYMBOL="ᐅ"<.zsh[+] CWD: /Users/denysd/Projects/spaceship Line: 4 Column: 14SPACESHIP_PACKAGE_SYMBOL="🗳":wqspaceshiptook4.1sspaceshiponmainis🗳1.0.0viav18.7.0took4.1ssudo-ssudo-sAliastip:_-sPassword:RevertingtonvmdefaultversionNowusingsystemversionofnode:v18.6.0(npmv8.15.0)rootinspaceshiprootinspaceshipis🗳1.0.0rootinspaceshiponmainis🗳1.0.0exitspaceshiptook12.0sspaceshiponmainis🗳1.0.0viav18.7.0took12.0sccdclearffalsefalsefalsefalsettruetruetrueclearspaceshipnvmuse18npnpminit-ynpmspaceshipis📦1.0.0npminit-ynvnvmuse18nvmnvmuse18nvmuse18nvmusenvmuse18gitinitgitinitgitagitaddpackage.jsongitaddpackage.jsongitaddpackage.jsongitaddpackage.jsongitaddpackage.jsongitcgitcommit-m"Initialcommit"gitcommit-m"Initialcommit"gitcommit-m"Initialcommit"gitcommit-m"Initialcommit"gitcommit-m"Initialcommit"gitcommitgitcommit-m"Initialcommit"gitcommit-mcdProjects/spaceship/clclearclearclearsspaceshipeditspaceshipeditspaceshipeditspaceshipeditspaceshipeditspaceshipeditspaceshipeditspaceshipeditspaceshipspaceshipeditspaceshipeditspaceshipedit"~/.spaceshiprc.zsh"<prc.zsh CWD: /Users/denysd/Projects/spaceship Line: 1 Column: 1<prc.zsh CWD: /Users/denysd/Projects/spaceship Line: 2 Column: 0<prc.zsh CWD: /Users/denysd/Projects/spaceship Line: 3 Column: 13SPACESHIP_CHAR_SYMBOL="ᐅ"4SPACESHIP_PACKAGE_SYMBOL="🗳"::w"~/.spaceshiprc.zsh""~/.spaceshiprc.zsh"4L,94Bwrittenspaceshipis🗳1.0.0took4.1sspaceshipis🗳1.0.0viav18.7.0took4.1sspaceshipis🗳1.0.0viav18.7.0took4.1ssspaceshipeditsusudo-ssudo-ssudosudo-srootinspaceshipis🗳1.0.0eexitexitexitspaceshipis🗳1.0.0took12.0sspaceshipis🗳1.0.0viav18.7.0took12.0sspaceshipis🗳1.0.0viav18.7.0took12.0sclearcdProjects/spaceship/cdclclearclearclear diff --git a/.zsh/themes/spaceship-prompt/docs/assets/images/what-is-needed.svg b/.zsh/themes/spaceship-prompt/docs/assets/images/what-is-needed.svg deleted file mode 100644 index 663d531..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/images/what-is-needed.svg +++ /dev/null @@ -1 +0,0 @@ -3333 \ No newline at end of file diff --git a/.zsh/themes/spaceship-prompt/docs/assets/scripts/registry.js b/.zsh/themes/spaceship-prompt/docs/assets/scripts/registry.js deleted file mode 100644 index b758c3f..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/scripts/registry.js +++ /dev/null @@ -1,57 +0,0 @@ -function initRegistry(list, input) { - const registryType = input ? input.getAttribute('data-registry') : null; - - const registry = registryType - ? fetch(`/registry/${registryType}.json`) - .then(res => res.json()) - .then(registry => registry.sections) - : Promise.all([ - fetch('/registry/internal.json').then(res => res.json()), - fetch('/registry/external.json').then(res => res.json()), - ]) - .then(([internal, external]) => ([ - ...internal.sections, - ...external.sections - ])); - - registry.then(sections => { - list.innerHTML = sections - .sort((a, b) => a.name.localeCompare(b.name)) - .map(item => ` - -
  • - - ${item.name} - ${item.internal ? 'internal' : ''} - - ${item.description} -
  • -
    - `) - .join(''); - }); - - input.addEventListener('keyup', _.debounce(e => { - console.log(e.target.value); - const query = e.target.value.toLowerCase().trim(); - - Array.from(list.children).forEach(item => { - if (item.innerText.toLowerCase().includes(query)) { - item.style.display = ''; - } else { - item.style.display = 'none'; - } - }) - }, 300)); -} - -const observer = new MutationObserver(mutations => { - const list = document.querySelector('#sections-list'); - const input = document.querySelector('#sections-search'); - - if (list && input) { - initRegistry(list, input); - } -}); - -observer.observe(document.body, {childList: true}); diff --git a/.zsh/themes/spaceship-prompt/docs/assets/styles/announce.css b/.zsh/themes/spaceship-prompt/docs/assets/styles/announce.css deleted file mode 100644 index f19f9d8..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/styles/announce.css +++ /dev/null @@ -1,24 +0,0 @@ -.announce { - color: #FFD200 !important; -} -.hashtag { - color: #035DB8 !important; -} -.mdx-author { - display: flex; - font-size: 0.68rem; -} -.mdx-author img { - height: 2.5rem; - border-radius: 100%; -} -.mdx-author p { - margin: 0; -} -.mdx-author p:first-child { - flex-shrink: 0; - margin-right: 0.8rem; -} -.mdx-author p > span { - display: block; -} diff --git a/.zsh/themes/spaceship-prompt/docs/assets/styles/companies.css b/.zsh/themes/spaceship-prompt/docs/assets/styles/companies.css deleted file mode 100644 index 3bf5bda..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/styles/companies.css +++ /dev/null @@ -1,48 +0,0 @@ -@keyframes slider { - 0% { - transform: translateX(calc(100% - 100vw)); - } - 50% { - transform: translateX(0); - } - 100% { - transform: translateX(calc(100% - 100vw)); - } -} - -.companies { - display: flex; - flex-direction: row-reverse; - white-space: nowrap; - overflow: hidden; - margin: 2rem auto; -} - -.companies-title { - text-transform: uppercase; -} - -.companies-slider { - white-space: nowrap; - animation: 150s linear infinite slider; -} - -.companies .company { - height: 3rem; - opacity: 0.6; - margin: 0 1rem; - filter: grayscale() brightness(25%) invert(0); -} - -.companies .company:hover { - opacity: 1; -} - -[data-md-color-scheme="slate"] .companies .company { - filter: grayscale() brightness(25%) invert(1); -} - -.companies .company img { - height: 100%; - max-height: 2.5em; -} diff --git a/.zsh/themes/spaceship-prompt/docs/assets/styles/embed.css b/.zsh/themes/spaceship-prompt/docs/assets/styles/embed.css deleted file mode 100644 index 9f20564..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/styles/embed.css +++ /dev/null @@ -1,24 +0,0 @@ -@font-face { - font-family: 'FiraCode Nerd Font'; - src: url("/assets/FiraCodeNerd.woff2") format("woff2"); - font-weight: 400; - font-style: normal; -} - -code { - font-family: 'FiraCode Nerd Font', source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; - overflow-wrap: break-word; -} - -.terminal-demo { - display: flex; - justify-content: center; -} - -.terminal-demo .asciicast { - width: 80%; -} - -.twitter-tweet { - margin: 0 auto; -} diff --git a/.zsh/themes/spaceship-prompt/docs/assets/styles/hero.css b/.zsh/themes/spaceship-prompt/docs/assets/styles/hero.css deleted file mode 100644 index 5129c3a..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/styles/hero.css +++ /dev/null @@ -1,95 +0,0 @@ -.hero-container { - padding: 2rem 0; - background: rgb(34, 28, 62); - background: url('data:image/svg+xml;utf8,'), - linear-gradient( - 180deg, - var(--md-primary-fg-color), - var(--md-accent-fg-color) 99%, - var(--md-default-bg-color) 0 - ); - background-repeat: no-repeat; - background-position: bottom; - background-size: contain; -} - -[data-md-color-scheme="slate"] .hero-container { - background: url('data:image/svg+xml;utf8,'), - linear-gradient( - 180deg, - var(--md-primary-fg-color), - var(--md-accent-fg-color) 99%, - var(--md-default-bg-color) 0 - ); - background-repeat: no-repeat; - background-position: bottom; - background-size: contain; -} - -.mdx-hero { - color: var(--md-primary-bg-color); - margin-bottom: 4rem; -} - -.mdx-hero .md-button { - margin-top: 0.5rem; - margin-right: 0.5rem; - color: var(--md-primary-bg-color); -} - -.mdx-hero .md-button--primary { - color: rgba(195, 68, 53, 1); - background-color: var(--md-primary-bg-color); - border-color: var(--md-primary-bg-color); -} - -.mdx-hero__image { - display: flex; - justify-content: center; - align-items: flex-start; -} - -.mdx-hero__content { - text-align: center; -} - -.mdx-hero__content h1 { - margin-bottom: 1rem; - font-weight: 700; - color: currentColor; -} - -.mdx-features { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); - grid-gap: 3rem; - margin-bottom: 3rem; -} - -.mdx-features img { - height: 160px; - object-fit: fixed; -} - -@media screen and (min-width: 960px) { - .md-sidebar--secondary { - display: none; - } - - .mdx-hero { - display: flex; - align-items: stretch; - } - - .mdx-hero__image { - order: 1; - width: 50%; - } - - .mdx-hero__content { - width: 50%; - margin-top: 5rem; - padding-bottom: 20vh; - text-align: left; - } -} diff --git a/.zsh/themes/spaceship-prompt/docs/assets/styles/registry.css b/.zsh/themes/spaceship-prompt/docs/assets/styles/registry.css deleted file mode 100644 index 00feda0..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/styles/registry.css +++ /dev/null @@ -1,33 +0,0 @@ -#sections-list { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); - grid-auto-rows: minmax(max-content, 1fr); - gap: 1rem; - list-style: none; - margin: 1rem 0; -} - -#sections-list li { - display: flex; - flex-direction: column; - height: 100%; - margin: 0; - padding: 0.5rem; - border-bottom: 1px solid var(--md-default-fg-color--lightest); - border-radius: 0.1rem; - cursor: pointer; - color: var(--md-default-fg-color--light); - transition: all 0.2s ease-in-out; -} - -#sections-list li:hover, -#sections-list li:focus { - background-color: var(--md-default-fg-color--lightest); - color: var(--md-typeset-a-color); -} - -#sections-list li em { - font-weight: lighter; - font-size: smaller; - color: var(--md-typeset-a-color); -} diff --git a/.zsh/themes/spaceship-prompt/docs/assets/styles/themes.css b/.zsh/themes/spaceship-prompt/docs/assets/styles/themes.css deleted file mode 100644 index 73ff02c..0000000 --- a/.zsh/themes/spaceship-prompt/docs/assets/styles/themes.css +++ /dev/null @@ -1,29 +0,0 @@ -[data-md-color-scheme="default"] { - --md-primary-fg-color: #221c3e; - --md-primary-fg-color--light: #a7a4b2; - --md-primary-fg-color--dark: #1b1632; - - --md-accent-fg-color: #c34435; - --md-accent-fg-color--light: #db8f86; - --md-accent-fg-color--dark: #752920; - - --md-typeset-a-color: var(--md-accent-fg-color); -} - -[data-md-color-scheme="slate"] { - --md-hue: 260; - - --md-primary-fg-color: #221c3e; - --md-primary-fg-color--light: #a7a4b2; - --md-primary-fg-color--dark: #1b1632; - - --md-accent-fg-color: #c34435; - --md-accent-fg-color--light: #db8f86; - --md-accent-fg-color--dark: #752920; - - --md-typeset-a-color: var(--md-accent-fg-color); -} - -[data-md-color-scheme="slate"] .md-button { - color: var(--md-accent-fg-color); -} diff --git a/.zsh/themes/spaceship-prompt/docs/blog/2017-spaceship-v2.md b/.zsh/themes/spaceship-prompt/docs/blog/2017-spaceship-v2.md deleted file mode 100644 index 0e11cb7..0000000 --- a/.zsh/themes/spaceship-prompt/docs/blog/2017-spaceship-v2.md +++ /dev/null @@ -1,172 +0,0 @@ -# A big update of spaceship-zsh-theme - - - ---- - -

    - ![Awesome Spaceship’s logo](https://cdn-images-1.medium.com/max/2050/1*inODQBDdKkPWKree_HSyWA.png){ width=33.3% } -

    - -I’ve been working on big PR for spaceship-zsh-theme last few weeks. This is the biggest update of Spaceship ever, there are a lot of changes (breaking changes too), prompt is almost completely rewritten, so I decided to write a note which should be a summary of my efforts. - -## Why? - -Before I dive into describing of new features I’d like to talk about causes of full-rewritting. The main reason is that Spaceship has a lot of boilerplate copy-pasted code, like this: - -```zsh -echo -n "%{$fg_bold[green]%}" -echo -n "${SPACESHIP_NVM_SYMBOL} ${nvm_status}" -echo -n "%{$reset_color%}" -``` - -And this snippet was a part of any section causing many related problems. - -Order of section and their colors in prompt was hardly defined in Spaceship’s source code and that was the second important problem. Users could override prefixes for sections, but couldn’t do the same for suffixes, colors or order of sections. Options were grouped by the name (like GIT, XCODE, etc), except PREFIX-options which were grouped by themselves. That was made API inconsistence. - -Another yet problem was hidden in the hostname section. Internally, this section used username section and directory prefix. It’s just historical issue related to the specificity of implementation. Anyway, this caused non-obvious binding between parts of prompt and that was the big problem for future features. - -Besides this, there was few smaller, but nevertheless annoying issues around Spaceship’s internals which have to be fixed. - -## What’s new? - -**spaceship-zsh-theme** is now v2.0.0. A [pull-request #78](https://github.com/denysdovhan/spaceship-zsh-theme/pull/78) for this version contains 66 commits (1095 additions and 523 deletions), 48 new options (98 total, 26 was deprecated). - -![preview of Spaceship](https://cdn-images-1.medium.com/max/2400/1*Vtc9ZCR2p7a_9-6MuFB-hw.gif) - -Let’s take a look what’s coming on with new major update precisely. Here is a list of important changes: - -### Custom prompt ordering - -I’ve started refactoring from implementing of new feature: *custom prompt ordering*. - -Previously, users have no ability to change order of Spaceship’s sections. Moreover, there wasn’t such thing like *section* in Spaceship. Therefore, giving users ability to define order of prompt was the key feature of this major update. - -Now you can use `$SPACESHIP_PROMPT_ORDER` options to define desirable order, like this (default order below): - -```zsh -SPACESHIP_PROMPT_ORDER=( - time # Time stampts section - user # Username section - host # Hostname section - dir # Current directory section - git # Git section (git_branch + git_status) - node # Node.js section - ruby # Ruby section - xcode # Xcode section - swift # Swift section - golang # Go section - docker # Docker section - venv # virtualenv section - pyenv # Pyenv section - line_sep # Line break - vi_mode # Vi-mode indicator - char # Prompt character -) -``` - -### Prefixes are part of sections - -Previously, I’ve mentioned problems with naming of prefix options. In new version prefixes are moved to the corresponding sections: -`$SPACESHIP_PREFIX_* →$SPACESHIP_*_PREFIX` - -`$SPACESHIP_PREFIX_SHOW` options was renamed to `$SPACESHIP_PROMPT_PREFIXES_SHOW` and moved under prompt section. - -Don’t worry if you use old options right now, you will get a deprecation warning with suggestion of option that should be used instead: - -![An example of deprecation warnings](https://cdn-images-1.medium.com/max/3332/1*HsAPhD7LM1ViUosVQMjpLQ.png) - -Warnings for deprecated options won’t be removed until next major release. - -### Suffix options - -Since introducing prefixes, it was expected that suffixes should be added too. Now each section has corresponding `$SPACESHIP_*_SUFFIX` option for section’s suffix. As default it falls to the value of `$SPACESHIP_PROMPT_DEFAULT_SUFFIX` which is space. However, feel free to define you own suffix for any section (find more examples in [Presets](https://github.com/denysdovhan/spaceship-zsh-theme/wiki/Presets) wiki-page). - -### Custom colors - -Previously, there was no way to change section colors. New major release brings this feature to the users. If you need to change a section color, just assign color name to the corresponding `$SPACESHIP_*_COLOR` variable. Here is an example: - -![An example of using **SPACESHIP_*_COLOR** options](https://cdn-images-1.medium.com/max/3332/1*pYv-hix4QKUCPCMCW2A4Ug.png) - -### Git is more specific - -Now Git support is much more better. Firstly, git section was split up into two subsections:git_branch + git_status. As you may noticed, the first one shows current Git branch and the second one shows Git status. - -In addition to good old indicators, here are new ones that were added to Git status subsection: - -* » — renamed files; -* ✘ — deleted files; -* = — unmerged changes; -* ⇕ — diverged changes. - -### Fixed Node.js support - -There is no nvm section and related options anymore. Instead of this, node is used. We had [plenty of issues](https://github.com/denysdovhan/spaceship-zsh-theme/issues/33) from people, who prefer to use n instead of nvm. New version comes with `$SPACESHIP_NODE_DEFAULT_VERSION` option. If you use n, assign you default system Node.js version to this variable and node section will be hidden. - -### NPM package - -Spaceship now spread as NPM-package. That means you can install it with single command: - -```zsh -npm install -g spaceship-zsh-theme -``` - -This command will automatically download, link and source Spaceship. `$ZSH_THEME` will be set to "spaceship". Just reload your terminal. - -Also, you can uninstall Spaceship with npm uninstall command and update with npm update. - -Along with this, you can install Spaceship as usual, using shell plugin manager or with single command: - -```zsh -curl -o - https://raw.githubusercontent.com/denysdovhan/spaceship-zsh-theme/master/install.zsh | zsh -``` - -By the way, it would be great if we add ability to install Spaceship using Homebrew. If you can help, please, drop a message in related issue — [Install via Homebrew](https://github.com/denysdovhan/spaceship-zsh-theme/issues/90). - -### Smaller changes - -With bigger changes there were also smaller ones. Spaceship has got more internal improvements, specifically: - -* **New prompt character.** Now it’s `➜` instead of `➔`. The change is not quite obvious, but new character has rounded corners, which is more appropriate for eyes. -* **Low internal coupling.** User and dir sections are independent from host section. -* **Extended API.** Now time and user has their own prefixes and other options, which were missed. -* **Better installer/uninstaller.** `install.sh` was replaced by `install.zsh` and `uninstall.zsh` for installing and uninstalling respectively. Both are triggered by NPM postscripts or with curl and wget. -* **Added `.editorconfig`.** I have no idea why I’ve missed adding it before. Definitely, this file should be in any open source project. -* **Added wiki pages.** Docs were particularly move to the GitHub wiki pages. Specifically, [Screenshots](https://github.com/denysdovhan/spaceship-zsh-theme/wiki/Screenshots) page now contains more screenshots of Spaceship with other color schemes (including light ones). - -## Presets - -At this moment, Spaceship has 98 options. You can change almost anything you want: order, colors, prefixes, suffixes, symbols, etc. This makes Spaceship even more customizable than it was before. - -Playing with options, I found out that I make Spaceship to look like other themes. For instance, here is a demo how Spaceship may look like **robbyrussell** prompt (default Oh-My-Zsh prompt): - -![A [**robbyrussell **preset](https://github.com/denysdovhan/spaceship-zsh-theme/wiki/Presets#robbyrussell) for Spaceship](https://cdn-images-1.medium.com/max/2000/1*2nj-JjXMsxJ2lxEH8JAO8A.gif) - -That’s why I decided to create a [Presets](https://github.com/denysdovhan/spaceship-zsh-theme/wiki/Presets) wiki page where users can share their configuration with others. - -## Plans for future - -Surely, this release is not the end. There are plenty feature requests and working pull requests with draft implementation of these features, specifically: - -* [☿ Mercurial support](https://github.com/denysdovhan/spaceship-zsh-theme/issues/54) -* [⚙ Background jobs](https://github.com/denysdovhan/spaceship-zsh-theme/issues/66) -* [🐘 PHP support](https://github.com/denysdovhan/spaceship-zsh-theme/issues/74) -* [☁️ Amazon Web Services support](https://github.com/denysdovhan/spaceship-zsh-theme/issues/86) - -Wanna help? Check out [help wanted label](https://github.com/denysdovhan/spaceship-zsh-theme/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp-wanted) in Issue. If you need a feature or have any question, don’t be hesitate to [open an issue](https://github.com/denysdovhan/spaceship-zsh-theme/issues/new). - -## Donation - -I work on this project in my spare time, beside my primary job. I hope enjoy using Spaceship, and if you do, please, [buy me a cup of chamomile tea ☕️ or cheese cake 🍰](https://www.buymeacoffee.com/denysdovhan) - -I would appreciate your support! *Thank you!* - -> Thank you for reading! Follow me on [Twitter](https://twitter.com/denysdovhan) and [Facebook](https://www.facebook.com/denysdovhan), if you want to get updates. diff --git a/.zsh/themes/spaceship-prompt/docs/blog/2018-spaceship-v3.md b/.zsh/themes/spaceship-prompt/docs/blog/2018-spaceship-v3.md deleted file mode 100644 index 5acf883..0000000 --- a/.zsh/themes/spaceship-prompt/docs/blog/2018-spaceship-v3.md +++ /dev/null @@ -1,144 +0,0 @@ -# Meet Spaceship ZSH v3.0! - - - ---- - -![Photo by [Tim Mossholder](https://unsplash.com/photos/qjgdslbEn-I?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/search/photos/rocket?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)](https://cdn-images-1.medium.com/max/14400/1*J5P7vSWaFGRiO6wxyU5z8w.jpeg) - -[Spaceship](https://github.com/denysdovhan/spaceship-prompt) is a minimalistic, powerful and extremely customizable [Zsh](http://zsh.org/) prompt. Today we’re announcing the third major release of Spaceship prompt — one of the most powerful zsh prompts ever. - -Almost a year has passed since [A big update of spaceship-zsh-theme](https://medium.com/@denysdovhan/a-big-update-of-spaceship-zsh-theme-a705776ac6b5) and release of v2.0, but now we have even more exciting changes and announcements. So here we go! - -[:material-github: Source on GitHub](https://github.com/spaceship-prompt/spaceship-prompt/tree/v3.0.0){ .md-button} - -## What’s new? - -The initial purpose of this release was refactoring of how Spaceship works with sections. By the way, there were a few pull-requests with breaking, but important changes. This release brings better API, new options, few performance improvements and more. - -### Drop Oh-My-Zsh dependency - -We’ve run into [troubles](https://github.com/denysdovhan/spaceship-prompt/issues/101) using built-in functions from Oh-My-Zsh (OMZ). Besides this, a lot of users would like to use Spaceship without OMZ, with their custom setup or with frameworks like [prezto](https://github.com/sorin-ionescu/prezto). That was the main reason why we decided to remove using OMZ in Spaceship code. - -You don’t have to use `ZSH_THEME` or `ZSH_CUSTOM` folder anymore to install Spaceship. Since v3.0 we use a native prompt system that comes zsh: - -```zsh -# .zshrc -autoload -U promptinit; promptinit -prompt spaceship -``` - -### Brand-new name - -Dropping OMZ means that Spaceship isn’t a *theme *anymore, it’s a *prompt*. We’ve renamed our packages and GitHub repository - -**spaceship-zsh-theme → spaceship-prompt** - -Old `spaceship-zsh-theme` npm-package has been deprecated with recommendation to install spaceship-prompt instead. - -### Better project structure - -First, project structure has been totally reorganized. Previously, Spaceship was just a huge single source file and any change causes constant jumping between different parts of a single file. - -Now Spaceship is split up into smaller modules (sections, utils, etc) and they are loading when it’s required. That also means, if you’re struggling with performance, you can just avoid loading the sections that you don’t use. Read more at **“Why is my prompt slow?”** section of documentation: - -[Troubleshooting](https://github.com/spaceship-prompt/spaceship-prompt/blob/v3.0.0/docs/Troubleshooting.md){ .md-button } - -### Custom sections and Spaceship API - -Brice Dutheil sent us a pull-request with [Allow invoking custom functions](https://github.com/denysdovhan/spaceship-prompt/pull/262). This feature opens an ability to define custom sections with any functionality and, therefore, to extend functionality as much as you need. - -Moreover, v3.0 comes with better API for creating sections. To avoid conflicts, Spaceship uses SPACESHIP_ prefix for variables and spaceship:: prefix for a function. All section, including custom ones, are being required to use spaceship_prefix before their name to load correctly. - -Check out Spaceship’s API here: - -[API Documentation](https://github.com/spaceship-prompt/spaceship-prompt/blob/v3.0.0/docs/API.md){ .md-button } - -We encourage you to create your section, as many as you want and share them with others on our [External sections](https://github.com/denysdovhan/spaceship-prompt/wiki/External-sections) wiki-page! - -### Contributing guidelines - -Ability to extend and share sections requires new contributing guidelines, so we’ve finally added a CONTRIBUGING.md file to our repository. - -Three simple rules define our development path: - -* **Show only what’s needed.** The prompt should not be overloaded, it shows only what user needs at the moment (current directory, git branch, etc). -* **Work out of the box.** The prompt should work right after installation without any additional configuration. Install it and use it. -* **Be configurable.** It works without configuration, but if a configuration is needed, it provides an easy-to-use interface for customization. - -Please, keep this simple rules in mind while you’re contributing to Spaceship. - -[Contributing Guide](https://github.com/spaceship-prompt/spaceship-prompt/blob/v3.0.0/CONTRIBUTING.md){ .md-button } - -### Right prompt support - -The new release brings the support of right prompt (`RPROMPT`). By default, right prompt is empty, but you can add some sections the same way you do with a primary prompt. - -![**Spaceship** with **time** section in right prompt*](https://cdn-images-1.medium.com/max/3268/1*ebF5F3FSxkFGYir2i3aP0A.png) - -Read the documentation about prompt ordering to learn more: - -[Options](https://github.com/spaceship-prompt/spaceship-prompt/blob/v3.0.0/docs/Options.md){ .md-button } - -### Website and documentation - -We are glad to announce that now Spaceship has a documentation website. We use [GitBook](https://gitbook.com) for generating this website from our `./docs` folder. - -Here’s how it looks like: - -![Website Preview](https://cdn-images-1.medium.com/max/6208/1*sBoAIMIJgp9zZFavFDxTng.png) - -Check out our website at: - -[Website](https://spaceship-prompt.sh){ .md-button } - -### Smaller changes - -There was also a lot of petite, but still important changes: - -* Thanks to [Rolf Koenders](undefined) Spaceship now [truncates directory name in repositories](https://github.com/denysdovhan/spaceship-prompt/pull/169). -* Now Spaceship has more options for displaying sections: always, needed and charged (for battery section). -* We [removed LS_COLORS](https://github.com/denysdovhan/spaceship-prompt/pull/273) configuration from Spaceship since it doesn’t seem to be a part of prompt. -* [char is now a separate section](https://github.com/denysdovhan/spaceship-prompt/pull/115) that can be configurable as any other. -* Some long-standing bugs have been fixed and resolved. - -You can check out Spaceship 3.0 Roadmap for further information: - -[:material-github: 3.0: Roadmap · Issue #200](https://github.com/denysdovhan/spaceship-prompt/issues/200){ .md-button} - -## Some statistics - -It’s always interesting to see more statistic, so totally a [pull-request #148](https://github.com/denysdovhan/spaceship-prompt/pull/148) contains: - -* ⏺ 178 commits -* ➕ 3,220 additions -* ➖ 2,250 deletions -* ✅ 34 closed issues in milestone -* 👨‍💻 +1 team member (welcome [Maxim Baz](undefined) 👋🏻) - -## Plans for future - -As always, the project doesn’t stop to evolve. We have plenty of issue, pull-requests, and plans for future development. - -* **Top priority:** [Async rendering to speed-up prompt.](https://github.com/denysdovhan/spaceship-prompt/issues/307) -* [☕ Java support](https://github.com/denysdovhan/spaceship-prompt/pull/265) -* [🌳 Elm support](https://github.com/denysdovhan/spaceship-prompt/pull/253) -* and [others](https://github.com/denysdovhan/spaceship-prompt/pulls) - -Want to help? Check out [help wanted label](https://github.com/denysdovhan/spaceship-prompt/labels/help-wanted) in Issue. If you need a feature or have any question, don’t be hesitated to [open an issue](https://github.com/denysdovhan/spaceship-zsh-theme/issues/new). - -## Donation - -Hi! I work on this project in my spare time, beside my primary job. I hope enjoy using Spaceship, and if you do, please, [buy me a cup of tea ☕️](https://www.buymeacoffee.com/denysdovha). - -I would appreciate your support! *Thank you!* - -> Thankyou for reading! If you like this article, please, press 👏. Follow me on [Twitter](https://twitter.com/denysdovhan) and [GitHub](https://github.com/denysdovhan), if you want to get updates.* diff --git a/.zsh/themes/spaceship-prompt/docs/blog/2022-spaceship-v4.md b/.zsh/themes/spaceship-prompt/docs/blog/2022-spaceship-v4.md deleted file mode 100644 index aa46dd8..0000000 --- a/.zsh/themes/spaceship-prompt/docs/blog/2022-spaceship-v4.md +++ /dev/null @@ -1,229 +0,0 @@ -# Announcing Spaceship v4 — the faster, the better - - - ---- - -_The wait is over._ We're finally ready to launch the new version of Spaceship. - -This is a major release, bringing many new features and smaller improvements. We've dramatically improved performance, improved API, made configuration easier and refactored dozens of parts of the codebase. - -Let's see what's new in **Spaceship v4**. - -
    - ![spacex-tKs_2sBoqAg-unsplash](https://user-images.githubusercontent.com/3459374/183982070-512f298c-5ff6-4b1c-b0b7-23d0551d09aa.jpeg) -
    A picture of Falcon Heavy by SpaceX
    -
    - -## A few words from maintainer - -Hey, I'm Denys 👋 - -I'm original creator and maintainer of Spaceship project. Before we begin, I'd like to say a few words about my journey to this release. - -It's been a while since the last release of Spaceship. A lot has happened. I've burned out from doing open-source for free, moved to another city, started lots of different projects, and _full scale invasion of my country began_. - -I live in Kyiv, Ukraine. Russia invaded my country, kills my countrymen daily, endangers my live forcing me to flee the city I live in. I was working on this release mostly to get my mind off the reality. This release is partly made when I was sitting in a shelter, hiding from rocket strikes. This is the reality of Russian cruelty and aggression. - -Ukrainian Open Source community teamed up and created a website where you can read more about the situation and donate to help people in need. Please, consider donating to help us survive and win this war. - -[:flag_ua: StandWithUkraine](https://stand-with-ukraine.pp.ua){ .md-button } -[War in Ukraine](https://war.ukraine.ua){ .md-button } - -Please, **spread the word and help us, help me**. Thank you. Let's get back to the release. - -## What's new in v4? - -This release comes with tons of bigger and smaller improvements. Let's take a closer look at features that are new in v4. - -[v4.0.0 Release Notes](https://github.com/spaceship-prompt/spaceship-prompt/releases/tag/v4.0.0){ .md-button } - -### Asynchronous rendering - -The biggest feature of this release is [**asynchronous rendering**](/config/prompt/). We know you've been waiting for this for long. - -Spaceship has a lot of sections and even [more have been contributed](https://github.com/spaceship-prompt/spaceship-prompt/pulls?q=is%3Apr+is%3Aopen+label%3Anew-feature). The more section is added, the more computation is needed to render the prompt. For a user it means you have to wait longer to be able to type the next command. Not anymore. - -Now Spaceship performs heavy computation in a separate thread and renders the prompt asynchronously. Spaceship will display the prompt **immediately, without blocking the input**. You can start typing the following command right away. Additional information will be added to the prompt as soon as the computation is finished. - -Here's how it works: - -
    - -
    - -As you see above, only the directory and prompt character are displayed immediately. The rest of the prompt (`git` and `package` sections) are rendered asynchronously and thus added later. A [`…` placeholder](/sections/async) for upcoming information is displayed while the computation is in progress. - -If you're fast enough you can even type the following command, before the prompt is fully rendered. - -The asynchronous rendering is enabled by default. You can disable it by setting `SPACESHIP_PROMPT_ASYNC` to `false` in your configuration. - -```zsh title=".spaceshiprc.zsh" -SPACESHIP_PROMPT_ASYNC=false -``` - -Kudos to [@laggardkernel](https://github.com/laggardkernel) who laid the groundwork for asynchronous rendering. - -### Registry for sections - -This release also introduces [the Spaceship Registry](/registry). It's a registry of all sections that are available for Spaceship. - -![Spaceship Registry](https://user-images.githubusercontent.com/3459374/187728583-0a7b3fdb-2a6d-41bb-ae1d-378b8e4db660.png) - -It will dramatically simplify exploring new sections. Now you can browse all the sections, including the additional sections developed and maintained by other users. - -Additionally, if you are developing a custom section for Spaceship you might want to check out our section development guide and a template repository: - -[Create a custom section](/advanced/creating-section){ .md-button} -[:fontawesome-brands-github: Use a section template](https://github.com/spaceship-prompt/spaceship-section){ .md-button } - -### Easier configuration - -Previously, users had problems with understanding where to put Spaceship's configuration in their dotfiles. This release introduces Spaceship configuration files. Now you can put your configuration in `~/.spaceshiprc.zsh` or `~/.config/spaceship.zsh` files and it will be loaded automatically in a proper place. - -These files will sourced as a simple Zsh file, so you can write imperative configuration within them. You can also use [Spaceship CLI](#command-line-interface) within the configuration file. - -To get started with configuration file, create one: - -```zsh title="Terminal" -touch ~/.spaceshiprc.zsh -``` - -You can also quickly open you configuration file with `spaceship edit` command. Here's an example: - -
    - -
    - -### Command line interface - -You might have noticed Spaceship now comes with a handy `spaceship` CLI. The goal is to simplify common task you do with Spaceship, like editing configuration, adding and removing sections, etc. - -You can also dynamically add and remove sections to/from the prompt with `spaceship add` and `spaceship remove` commands. - -
    - -
    - -Both `spaceship add` and `spaceship remove` apply changes only to the current session, so if you want to make them permanent, add those commands to your `.spaceshiprc.zsh`: - -```zsh title=".spaceshiprc.zsh" -# Removes git out of the prompt -spaceship remove git dir - -# Adds git back to the prompt, before the prompt character -spaceship add git --before char - -# Add directory to the right prompt -spaceship add dir --order rprompt -``` - -What else can you do with `spaceship` CLI? - -* `spaceship print` — prints the current prompt value in a raw format. -* `spaceship edit` — quickly opens your [Spaceship configuration](#easier-configuration) in your `$EDITOR`. -* `spaceship bug-report` — generates a bug report for you with pre-filled information about your environment. Use it any time you want to report a bug. - -### Other improvements - -* **Source files of the Spaceship are now getting automatically compiled to ZWC with [`zcompile`](https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html#index-_002e).** ZWC or Zsh Word Code is a special format of compiled Zsh scripts. It helps Zsh skip the reading and parsing of the script and get straight to executing. This results in a significant performance boost. -* **Improved `package` section.** Now it supports `composer` and `julia`. Package version resolution got smarter and faster thanks to the new `spaceship::datafile` utility. -* **`git` and `hg` orders are now configurable.** You can use `spaceship add --order git` to change the order of `git` section or add custom subsection to it. -* **Upsearching files.** Now when Spaceship looks for a file, it will search for it in the current directory and all parent directories up to the repository root. This will help maintaining the context of you current environment. -* **Added checks for minimal zsh version.** Now, if you are running an outdated version of Zsh, you will get a message. -* **Spaceship Docker image.** You can now use [Spaceship Docker image](https://github.com/spaceship-prompt/spaceship-prompt/pkgs/container/spaceship-prompt) to test Spaceship in a clean environment. It's also used to run tests in CI. -* **Spaceship Testkit.** If you are developing a custom section you can now use [Spaceship Testkit](/api/testkit/) for performing common testing tasks. -* [**And many more!**](TODO: link to changelog) - -### Breaking Changes - -Of course, every major release comes with breaking changes. Here's what you need to know: - -#### A new API for `spaceship::section`, not relying on arguments order - -Not you can pass information about the section via flags. In custom sections it's recommended to use `spaceship::section::v4` function to ensure smooth migration to the newer version in the future. Previous one can be used via `::v3` suffix. - -#### `pyenv` section is renamed to `python` - -This is done to unify naming of the sections. If you are using `PYENV_` options, you need to rename it to `PYTHON_` in your configuration. You'll get a corresponding warning if you are using the old options. - -#### `ember` section is removed from core - -It's now [an external section `spaceship-ember`](https://github.com/spaceship-prompt/spaceship-ember). It's still available in the registry, so you can install it back to your prompt if you need it. - -#### `java` section was refactored - -[Maven (`spaceship-maven`)](https://github.com/spaceship-prompt/spaceship-maven) and [Gradle (`spaceship-gradle`)](https://github.com/spaceship-prompt/spaceship-gradle) are not included by default, but still can be installed as external sections. - -#### `vi_mode` section is also removed from core - -It used to cause too many problems for users who are not using Vi-mode. You can still install as [`spaceship-vi-mode` section](https://github.com/spaceship-prompt/spaceship-vi-mode). - -#### Kubecontext section now has consisted naming. - -Options are renamed to `KUBECTL_` instead of `KUBECONTEXT_`. You'll get a corresponding warning if you are using the old options. - -## What's next? - -### Smaller and shorter releases - -Preparing such releases like this one is a bit of a challenge. There are too many things to check and rework. - -From now on, we'll try to release more often, but with smaller and shorter changelogs. This will help us to keep the quality of the releases high and make it easier for you to keep up with the changes. - -### More sections - -More new sections are coming. Asynchronous rendering unblocks new sections that were frozen due to performance issues. In upcoming day and weeks we will gradually unfreeze, update and merge PRs with new sections. - -You should expect these sections to be released in the next few weeks: [Flutter](https://github.com/spaceship-prompt/spaceship-prompt/pull/942), [V Lang](https://github.com/spaceship-prompt/spaceship-prompt/pull/877), [Pulumni](https://github.com/spaceship-prompt/spaceship-prompt/pull/834), [Ocaml](https://github.com/spaceship-prompt/spaceship-prompt/pull/810), [Deno](https://github.com/spaceship-prompt/spaceship-prompt/pull/809) and others. - -## How to help? - -The development of such release takes time and effort. We gladly accept any help. Here are some ways you can help: - -### Contribute to the project - -You can contribute to the project by taking simple tasks marked by **good first issue** label, helping to translate the documentation or by helping people who are having issues with Spaceship. - -[:material-open-source-initiative: How to Contribute](/contribute){ .md-button } -[:material-translate: Help Translating](https://translate.spaceship-prompt.sh/){ .md-button } - -### Financial support - -If you really enjoy this project, you can contribute financially. Any contribution is highly appreciated, even the smallest one. There are several ways to donate: - -**Recurring donations:** - -[:fontawesome-brands-github: Sponsors](https://github.com/sponsors/denysdovhan?frequency=recurring){ .md-button } -[:material-open-source-initiative: Open Collective](https://opencollective.com/spaceship-prompt){ .md-button } -[:fontawesome-brands-patreon: Patreon](https://patreon.com/denysdovhan){ .md-button } - -**One-time donations:** - -[:fontawesome-brands-github: Sponsors](https://github.com/sponsors/denysdovhan?frequency=one-time){ .md-button } -[:material-coffee: Buy Me a Coffee](https://buymeacoffee.com/denysdovhan){ .md-button } -[:fontawesome-solid-paw: Monobank Jar](https://send.monobank.ua/jar/2N46sWTaZZ){ .md-button } - -**Crypto donations:** - -* **:fontawesome-brands-ethereum: Ethereum**: `0x5C9496De5E51D48daf28354DC04d8f9D33955559` -* **:fontawesome-brands-bitcoin: Bitcoin**: `bc1q5ezjvpgftmx42f9qgdf5lscjz43uh4jf02uvje` - -## Thanks everyone! - -Thanks for reading! Thank you for using Spaceship! Hope you'll enjoy using this new version of Spaceship! - -See you in our [Discord server](https://discord.gg/NTQWz8Dyt9)! Don't forget to like and retweet our announcement tweet! - - - diff --git a/.zsh/themes/spaceship-prompt/docs/blog/index.md b/.zsh/themes/spaceship-prompt/docs/blog/index.md deleted file mode 100644 index 8736bec..0000000 --- a/.zsh/themes/spaceship-prompt/docs/blog/index.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -search: - exclude: true ---- - -# Blog - -## [Announcing Spaceship v4 — the faster, the better][spaceship-v4] - -**_The wait is over._ We're finally ready to launch the new version of Spaceship.** - - - - ---- - -This is a major release, bringing many new features and smaller improvements. We've dramatically improved performance, improved API, made configuration easier and refactored dozens of parts of the codebase. Let's see what's new in Spaceship v4. - -[:octicons-arrow-right-24: Continue reading][spaceship-v4] -[spaceship-v4]: /blog/2022-spaceship-v4 - -## [Meet Spaceship ZSH v3.0!][spaceship-v3] - -**Three… Two… One… Liftoff!** - - - ---- - -Spaceship is a minimalistic, powerful and extremely customizable Zsh. Today we’re announcing the third major release of Spaceship prompt — one of the most powerful Zsh prompts ever. - -[:octicons-arrow-right-24: Continue reading][spaceship-v3] -[spaceship-v3]: /blog/2018-spaceship-v3 - -## [A big update of spaceship-zsh-theme][spaceship-v2] - -**What’s new, what was deprecated and what the plan for future** - - - ---- - -I’ve been working on big PR for spaceship-zsh-theme last few weeks. This is the biggest update of Spaceship ever, there are a lot of changes (breaking changes too), prompt is almost completely rewritten, so I decided to write a note which should be a summary of my efforts. - -[:octicons-arrow-right-24: Continue reading][spaceship-v2] -[spaceship-v2]: /blog/2017-spaceship-v2 - - - -[denysdovhan]: https://unavatar.io/denysdovhan diff --git a/.zsh/themes/spaceship-prompt/docs/config/intro.de.md b/.zsh/themes/spaceship-prompt/docs/config/intro.de.md deleted file mode 100644 index 49980eb..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/intro.de.md +++ /dev/null @@ -1,56 +0,0 @@ -# Introduction - -Welcome to Spaceship configuration! Here is a quick guide of how to adjust Spaceship to your personal workflows. - -## Create a config file - -To get started with customization, create a configuration file: - -```zsh -touch ~/.spaceshiprc.zsh -``` - -… or, if you prefer to keep your configuration within a `~/.config` or `~/.config/spaceship` folders, you can do so, as well: - -```zsh -mkdir -p ~/.config/spaceship.zsh -``` - -This file will be automatically sourced by Spaceship when it starts up. - -## Configure your prompt - -The configuration file is a `.zsh` file, so you can use `zsh` syntax to customize Spaceship. You can use loops, conditions, custom functions or even source additional `zsh` files. It's up to you. - -Here's an example of a configuration file: - -```zsh -# Display time -SPACESHIP_TIME_SHOW=true - -# Display username always -SPACESHIP_USER_SHOW=always - -# Do not truncate path in repos -SPACESHIP_DIR_TRUNC_REPO=false - -# Add custom Ember section -# See: https://github.com/spaceship-prompt/spaceship-ember -spaceship add ember - -# Add a custom vi-mode section to the prompt -# See: https://github.com/spaceship-prompt/spaceship-vi-mode -spaceship add --before char vi_mode -``` - -You can learn more about available options by reading further documentation. - -[See available options](/config/prompt ""){.md-button} - -## Changing the config location - -Optionally, you can change the location of the configuration file by setting the `SPACESHIP_CONFIG_FILE` environment variable. - -```zsh -export SPACESHIP_CONFIG_FILE="$HOME/.dotfiles/path/to/spaceship.zsh" -``` diff --git a/.zsh/themes/spaceship-prompt/docs/config/intro.fr.md b/.zsh/themes/spaceship-prompt/docs/config/intro.fr.md deleted file mode 100644 index b6ccc3f..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/intro.fr.md +++ /dev/null @@ -1,56 +0,0 @@ -# Introduction - -Bienvenue dans la configuration de Spaceship ! Here is a quick guide of how to adjust Spaceship to your personal workflows. - -## Créer un fichier de configuration - -Pour commencer avec la personnalisation, créez un fichier de configuration : - -```zsh -touch ~/.spaceshiprc.zsh -``` - -… ou, si vous préférez conserver votre configuration dans les dossiers `~/.config` ou `~/.config/spaceship`, vous pouvez également : - -```zsh -mkdir -p ~/.config/spaceship.zsh -``` - -Le fichier va être sourcé automatiquement par Spaceship quand il démarrera. - -## Configure your prompt - -The configuration file is a `.zsh` file, so you can use `zsh` syntax to customize Spaceship. You can use loops, conditions, custom functions or even source additional `zsh` files. It's up to you. - -Here's an example of a configuration file: - -```zsh -# Display time -SPACESHIP_TIME_SHOW=true - -# Display username always -SPACESHIP_USER_SHOW=always - -# Do not truncate path in repos -SPACESHIP_DIR_TRUNC_REPO=false - -# Add custom Ember section -# See: https://github.com/spaceship-prompt/spaceship-ember -spaceship add ember - -# Add a custom vi-mode section to the prompt -# See: https://github.com/spaceship-prompt/spaceship-vi-mode -spaceship add --before char vi_mode -``` - -You can learn more about available options by reading further documentation. - -[See available options](/config/prompt ""){.md-button} - -## Changing the config location - -Optionally, you can change the location of the configuration file by setting the `SPACESHIP_CONFIG_FILE` environment variable. - -```zsh -export SPACESHIP_CONFIG_FILE="$HOME/.dotfiles/path/to/spaceship.zsh" -``` diff --git a/.zsh/themes/spaceship-prompt/docs/config/intro.md b/.zsh/themes/spaceship-prompt/docs/config/intro.md deleted file mode 100644 index ef16626..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/intro.md +++ /dev/null @@ -1,56 +0,0 @@ -# Introduction - -Welcome to Spaceship configuration! Here is a quick guide of how to adjust Spaceship to your personal workflows. - -## Create a config file - -To get started with customization, create a configuration file: - -```zsh -touch ~/.spaceshiprc.zsh -``` - -… or, if you prefer to keep your configuration within a `~/.config` or `~/.config/spaceship` folders, you can do so, as well: - -```zsh -mkdir -p ~/.config/spaceship.zsh -``` - -This file will be automatically sourced by Spaceship when it starts up. - -## Configure your prompt - -The configuration file is a `.zsh` file, so you can use `zsh` syntax to customize Spaceship. You can use loops, conditions, custom functions or even source additional `zsh` files. It's up to you. - -Here's an example of a configuration file: - -```zsh -# Display time -SPACESHIP_TIME_SHOW=true - -# Display username always -SPACESHIP_USER_SHOW=always - -# Do not truncate path in repos -SPACESHIP_DIR_TRUNC_REPO=false - -# Add custom Ember section -# See: https://github.com/spaceship-prompt/spaceship-ember -spaceship add ember - -# Add a custom vi-mode section to the prompt -# See: https://github.com/spaceship-prompt/spaceship-vi-mode -spaceship add --before char vi_mode -``` - -You can learn more about available options by reading further documentation. - -[See available options](/config/prompt){ .md-button } - -## Changing the config location - -Optionally, you can change the location of the configuration file by setting the `SPACESHIP_CONFIG` environment variable. - -```zsh -export SPACESHIP_CONFIG="$HOME/.dotfiles/path/to/spaceship.zsh" -``` diff --git a/.zsh/themes/spaceship-prompt/docs/config/intro.uk.md b/.zsh/themes/spaceship-prompt/docs/config/intro.uk.md deleted file mode 100644 index 1054ee3..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/intro.uk.md +++ /dev/null @@ -1,56 +0,0 @@ -# Вступ - -Ласкаво просимо до конфігурації Spaceship! Ось швидкий посібник по налаштуванню Spaceship для ваших особистих робочих процесів. - -## Створення файлу конфігурації - -Щоб почати з налаштування, створіть файл конфігурації: - -```zsh -touch ~/.spaceshiprc.zsh -``` - -… або, якщо ви бажаєте зберегти свою конфігурацію в папках `~/.config` або `~/.config/spaceship`, зробіть ось це: - -```zsh -mkdir -p ~/.config/spaceship.zsh -``` - -Spaceship автоматично завантажить цей файл при запуску. - -## Налаштуйте ваш командний рядок - -Файл конфігурації є файлом `.zsh`, тому ви можете використовувати `zsh`-синтаксис для налаштування Spaceship. Можна використовувати цикли, умови, користувацькі функції або навіть завантажувати додаткові `zsh` файли. Вирішувати вам. - -Ось приклад файлу конфігурації: - -```zsh -# Показувати час -SPACESHIP_TIME_SHOW=true - -# Завжди показувати ім'я користувача -SPACESHIP_USER_SHOW=always - -# Не скорочувати шлях в репозиторіях -SPACESHIP_DIR_TRUNC_REPO=false - -# Додати зовнішню секцію Ember -# See: https://github.com/spaceship-prompt/spaceship-ember -spaceship add ember - -# Додати зовнішню секцію vi-mode -# See: https://github.com/spaceship-prompt/spaceship-vi-mode -spaceship add --before char vi_mode -``` - -Ви можете дізнатися більше про доступні опції, читаючи документацію далі. - -[Переглянути доступні опції](/config/prompt ""){.md-button} - -## Зміна розташування файлу конфігурації - -Додатково, ви можете змінити розташування файлу конфігурації, встановивши змінну середовища `SPACESHIP_CONFIG_FILE`. - -```zsh -export SPACESHIP_CONFIG_FILE="$HOME/.dotfiles/path/to/spaceship.zsh" -``` diff --git a/.zsh/themes/spaceship-prompt/docs/config/intro.zh.md b/.zsh/themes/spaceship-prompt/docs/config/intro.zh.md deleted file mode 100644 index 49980eb..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/intro.zh.md +++ /dev/null @@ -1,56 +0,0 @@ -# Introduction - -Welcome to Spaceship configuration! Here is a quick guide of how to adjust Spaceship to your personal workflows. - -## Create a config file - -To get started with customization, create a configuration file: - -```zsh -touch ~/.spaceshiprc.zsh -``` - -… or, if you prefer to keep your configuration within a `~/.config` or `~/.config/spaceship` folders, you can do so, as well: - -```zsh -mkdir -p ~/.config/spaceship.zsh -``` - -This file will be automatically sourced by Spaceship when it starts up. - -## Configure your prompt - -The configuration file is a `.zsh` file, so you can use `zsh` syntax to customize Spaceship. You can use loops, conditions, custom functions or even source additional `zsh` files. It's up to you. - -Here's an example of a configuration file: - -```zsh -# Display time -SPACESHIP_TIME_SHOW=true - -# Display username always -SPACESHIP_USER_SHOW=always - -# Do not truncate path in repos -SPACESHIP_DIR_TRUNC_REPO=false - -# Add custom Ember section -# See: https://github.com/spaceship-prompt/spaceship-ember -spaceship add ember - -# Add a custom vi-mode section to the prompt -# See: https://github.com/spaceship-prompt/spaceship-vi-mode -spaceship add --before char vi_mode -``` - -You can learn more about available options by reading further documentation. - -[See available options](/config/prompt ""){.md-button} - -## Changing the config location - -Optionally, you can change the location of the configuration file by setting the `SPACESHIP_CONFIG_FILE` environment variable. - -```zsh -export SPACESHIP_CONFIG_FILE="$HOME/.dotfiles/path/to/spaceship.zsh" -``` diff --git a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.de.md b/.zsh/themes/spaceship-prompt/docs/config/loading-sections.de.md deleted file mode 100644 index 66aa613..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.de.md +++ /dev/null @@ -1,29 +0,0 @@ -# Loading custom sections - -Though Spaceship has multiple sections for various use-cases, sometimes you may need to install a custom one: for a specific tool or something that you use personally. - -You can create your own section using [sections API](/api/section) or use existing one from [the Registry](/registry): - -[Browse Registry](/registry ""){.md-button} [Create a custom section](/advanced/creating-section ""){.md-button} - -## How to install a section - -It better to follow the installation instructions provided by the section author. - -Most of the time, it's enough to just clone the repository locally (for example to `~/.config/spaceship`) and source the section somewhere in [Spaceship config](/config/intro/#create-a-config-file) or directly in `~/.zshrc`. - -## How to add a section to the prompt - -Spaceship CLI provides a command to add a section to the prompt: - -```zsh -spaceship add
    -``` - -For example, for `ember` section you can use: - -```zsh -spaceship add ember -``` - -You need to add this line somewhere in `~/.zshrc`. diff --git a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.fr.md b/.zsh/themes/spaceship-prompt/docs/config/loading-sections.fr.md deleted file mode 100644 index 66aa613..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.fr.md +++ /dev/null @@ -1,29 +0,0 @@ -# Loading custom sections - -Though Spaceship has multiple sections for various use-cases, sometimes you may need to install a custom one: for a specific tool or something that you use personally. - -You can create your own section using [sections API](/api/section) or use existing one from [the Registry](/registry): - -[Browse Registry](/registry ""){.md-button} [Create a custom section](/advanced/creating-section ""){.md-button} - -## How to install a section - -It better to follow the installation instructions provided by the section author. - -Most of the time, it's enough to just clone the repository locally (for example to `~/.config/spaceship`) and source the section somewhere in [Spaceship config](/config/intro/#create-a-config-file) or directly in `~/.zshrc`. - -## How to add a section to the prompt - -Spaceship CLI provides a command to add a section to the prompt: - -```zsh -spaceship add
    -``` - -For example, for `ember` section you can use: - -```zsh -spaceship add ember -``` - -You need to add this line somewhere in `~/.zshrc`. diff --git a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.md b/.zsh/themes/spaceship-prompt/docs/config/loading-sections.md deleted file mode 100644 index 3b9a10e..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.md +++ /dev/null @@ -1,30 +0,0 @@ -# Loading custom sections - -Though Spaceship has multiple sections for various use-cases, sometimes you may need to install a custom one: for a specific tool or something that you use personally. - -You can create your own section using [sections API](/api/section) or use existing one from [the Registry](/registry): - -[Browse Registry](/registry){ .md-button } -[Create a custom section](/advanced/creating-section){ .md-button } - -## How to install a section - -It better to follow the installation instructions provided by the section author. - -Most of the time, it's enough to just clone the repository locally (for example to `~/.config/spaceship`) and source the section somewhere in [Spaceship config](/config/intro/#create-a-config-file) or directly in `~/.zshrc`. - -## How to add a section to the prompt - -Spaceship CLI provides a command to add a section to the prompt: - -```zsh -spaceship add
    -``` - -For example, for `ember` section you can use: - -```zsh -spaceship add ember -``` - -You need to add this line somewhere in `~/.zshrc`. diff --git a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.uk.md b/.zsh/themes/spaceship-prompt/docs/config/loading-sections.uk.md deleted file mode 100644 index c57a758..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.uk.md +++ /dev/null @@ -1,29 +0,0 @@ -# Завантаження власних секцій - -Хоча Spaceship пропонує чисельні вбудовані секції для різноманітних випадків, іноді вам може бути потрібно встановити щось інше: для специфічного інструменту або чогось персонального. - -Ви можете створити власні секції за допомогою [API секцій](/api/section), або використати існуючу з [Реєстру](/registry): - -[Подивитись Реєстр](/registry ""){.md-button} [Створити власну секцію](/advanced/creating-section ""){.md-button} - -## Як встановити секцію - -Найкращій спосіб – слідувати інструкціям, наданим автором секції. - -В більшості випадків буде достатньо клонувати репозиторій локально (наприклад у `~/.config/spaceship`) та завантажити секцію десь у [конфігурації Spaceship](/config/intro/#create-a-config-file) або напряму в `~/.zshrc`. - -## Як додати секцію в командний рядок - -Spaceship CLI має команду для додавання секції в командний рядок: - -```zsh -spaceship add
    -``` - -Наприклад, для секції `ember` треба використати: - -```zsh -spaceship add ember -``` - -Вам потрібно додати цей рядок в `~/.zshrc`. diff --git a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.zh.md b/.zsh/themes/spaceship-prompt/docs/config/loading-sections.zh.md deleted file mode 100644 index 66aa613..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/loading-sections.zh.md +++ /dev/null @@ -1,29 +0,0 @@ -# Loading custom sections - -Though Spaceship has multiple sections for various use-cases, sometimes you may need to install a custom one: for a specific tool or something that you use personally. - -You can create your own section using [sections API](/api/section) or use existing one from [the Registry](/registry): - -[Browse Registry](/registry ""){.md-button} [Create a custom section](/advanced/creating-section ""){.md-button} - -## How to install a section - -It better to follow the installation instructions provided by the section author. - -Most of the time, it's enough to just clone the repository locally (for example to `~/.config/spaceship`) and source the section somewhere in [Spaceship config](/config/intro/#create-a-config-file) or directly in `~/.zshrc`. - -## How to add a section to the prompt - -Spaceship CLI provides a command to add a section to the prompt: - -```zsh -spaceship add
    -``` - -For example, for `ember` section you can use: - -```zsh -spaceship add ember -``` - -You need to add this line somewhere in `~/.zshrc`. diff --git a/.zsh/themes/spaceship-prompt/docs/config/prompt.de.md b/.zsh/themes/spaceship-prompt/docs/config/prompt.de.md deleted file mode 100644 index e3dcfb5..0000000 --- a/.zsh/themes/spaceship-prompt/docs/config/prompt.de.md +++ /dev/null @@ -1,146 +0,0 @@ -# Prompt configuration - -This page describes prompt-level options for Spaceship. - -## Terminology - -The prompt consists of **sections**. All sections are combined into a [**prompt order**](#prompt-order). - -When the prompt is being rendered, just goes over the prompt order and executes each section. If you want to add a custom section, add it to the order. You can add or remove sections from the prompt order at any time. - -Typically, a section consist of a **prefix**, **symbol**, **content** and **suffix**. The symbol and the content are painted in **color**. Here's an example with a `package` section: - -``` -is 📦 3.16.5 -``` - -Above, `is` is a prefix, `📦` is a symbol, `3.16.5` is the content and `` (a space) is the suffix. - -Each part can be configured via corresponding **options**. Options are just environment variables and have this signature `SPACESHIP_
    _