From afa3ed3a0a81b3449c6f05f7fceb7261906e8ba0 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Tue, 30 Aug 2022 01:45:16 +0000 Subject: [PATCH] Update dotfiles/.config/bashtop/bashtop.cfg, dotfiles/.config/inkscape/palettes/flat-remix-palette.gpl, dotfiles/.config/qt5ct/qt5ct.conf, dotfiles/.config/tilix/schemes/Flat-Remix.json, dotfiles/.local/share/qt5ct/colors/flat-remix-dark.conf, dotfiles/.local/share/qt5ct/colors/flat-remix-light.conf, dotfiles/.local/share/qt5ct/qss/fusion-simple-scrollbar.qss, dotfiles/.bashrc, .gitattributes, dotfiles/.gitconfig, dotfiles/.zshrc, dotfiles/.local/p10k.zsh, dotfiles/.local/antigen.zsh, dotfiles/.local/fzf.zsh, dotfiles/.profile --- .gitattributes | 4 + dotfiles/.bashrc | 186 ++ dotfiles/.config/bashtop/bashtop.cfg | 1 + .../inkscape/palettes/flat-remix-palette.gpl | 143 ++ dotfiles/.config/qt5ct/qt5ct.conf | 13 + .../.config/tilix/schemes/Flat-Remix.json | 35 + dotfiles/.gitconfig | 19 + dotfiles/.local/antigen.zsh | 2057 +++++++++++++++++ dotfiles/.local/fzf.zsh | 13 + dotfiles/.local/p10k.zsh | 1645 +++++++++++++ .../share/qt5ct/colors/flat-remix-dark.conf | 4 + .../share/qt5ct/colors/flat-remix-light.conf | 4 + .../qt5ct/qss/fusion-simple-scrollbar.qss | 29 + dotfiles/.profile | 304 ++- dotfiles/.zshrc | 381 +++ 15 files changed, 4837 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 dotfiles/.config/bashtop/bashtop.cfg create mode 100644 dotfiles/.config/inkscape/palettes/flat-remix-palette.gpl create mode 100644 dotfiles/.config/qt5ct/qt5ct.conf create mode 100644 dotfiles/.config/tilix/schemes/Flat-Remix.json create mode 100644 dotfiles/.local/antigen.zsh create mode 100644 dotfiles/.local/fzf.zsh create mode 100644 dotfiles/.local/p10k.zsh create mode 100644 dotfiles/.local/share/qt5ct/colors/flat-remix-dark.conf create mode 100644 dotfiles/.local/share/qt5ct/colors/flat-remix-light.conf create mode 100644 dotfiles/.local/share/qt5ct/qss/fusion-simple-scrollbar.qss diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..21ad9e7e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +*.gif diff=image +*.jpg diff=image +*.png diff=image +*.svg diff=image \ No newline at end of file diff --git a/dotfiles/.bashrc b/dotfiles/.bashrc index e69de29b..79574437 100644 --- a/dotfiles/.bashrc +++ b/dotfiles/.bashrc @@ -0,0 +1,186 @@ +### Fig +[[ -f "$HOME/.fig/shell/bashrc.pre.bash" ]] && . "$HOME/.fig/shell/bashrc.pre.bash" + +### ~/.profile +[[ -f "$HOME/.profile" ]] && . "$HOME/.profile" + +COLOR_SCHEME=dark # dark/light + +alias ..='cd ..' +alias cp='cp -v' +alias rm='rm -I' +alias mv='mv -iv' +alias ln='ln -sriv' +alias xclip='xclip -selection c' +command -v vim > /dev/null && alias vi='vim' + +### Colorize commands +alias ls='ls --color=auto' +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' +alias diff='diff --color=auto' +alias ip='ip --color=auto' +alias pacman='pacman --color=auto' + +### LS & TREE +alias ll='ls -la' +alias la='ls -A' +alias l='ls -F' +command -v lsd > /dev/null && alias ls='lsd --group-dirs first' && \ + alias tree='lsd --tree' +command -v colorls > /dev/null && alias ls='colorls --sd --gs' && \ + alias tree='colorls --tree' + +### CAT & LESS +command -v bat > /dev/null && \ + alias bat='bat --theme=ansi' && \ + alias cat='bat --pager=never' && \ + alias less='bat' +# in debian the command is batcat +command -v batcat > /dev/null && \ + alias batcat='batcat --theme=ansi' && \ + alias cat='batcat --pager=never' && \ + alias less='batcat' + +### TOP +command -v htop > /dev/null && alias top='htop' +command -v gotop > /dev/null && alias top='gotop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' +command -v ytop > /dev/null && alias top='ytop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' +command -v btm > /dev/null && alias top='btm $([ "$COLOR_SCHEME" = "light" ] && echo "--color default-light")' +# themes for light/dark color-schemes inside ~/.config/bashtop; Press ESC to open the menu and change the theme +command -v bashtop > /dev/null && alias top='bashtop' +command -v bpytop > /dev/null && alias top='bpytop' + +### Settings +shopt -s globstar +shopt -s histappend +shopt -s checkwinsize + +HISTCONTROL=ignoreboth +HISTSIZE=5000 +HISTFILESIZE=5000 +HISTFILE=~/.bash_history + +# Bash Completion +if [ -f /usr/share/bash-completion/bash_completion ] +then + source /usr/share/bash-completion/bash_completion +elif [ -f /etc/bash_completion ] +then + source /etc/bash_completion +fi + +# Add new line before prompt +PROMPT_COMMAND="PROMPT_COMMAND=echo" + +# Prompt +PS1='\[\033[;32m\]┌──(\[\033[1;34m\]\u@\h\[\033[;32m\])-[\[\033[0;1m\]\w\[\033[;32m\]]\n\[\033[;32m\]└─\[\033[1;34m\]\$\[\033[0m\] ' + +### Miscellaneous +export VISUAL=vim +export EDITOR=$VISUAL + +# enable terminal linewrap +setterm -linewrap on 2> /dev/null + +# colorize man pages +export LESS_TERMCAP_mb=$'\e[1;32m' +export LESS_TERMCAP_md=$'\e[1;32m' +export LESS_TERMCAP_me=$'\e[0m' +export LESS_TERMCAP_se=$'\e[0m' +export LESS_TERMCAP_so=$'\e[01;33m' +export LESS_TERMCAP_ue=$'\e[0m' +export LESS_TERMCAP_us=$'\e[1;4;31m' +export LESSHISTFILE=- + +# colorize ls +[ -x /usr/bin/dircolors ] && eval "$(dircolors -b)" + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty) + PS1="\[\e]0;\u@\h: \w\a\]$PS1" + ;; +esac + +### Functions +glog() { + setterm -linewrap off 2> /dev/null + + git --no-pager log --all --color=always --graph --abbrev-commit --decorate --date-order \ + --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' "$@" \ + | sed -E \ + -e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+ /├\1─╮\2/' \ + -e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m /\1├─╯\x1b\[m/' \ + -e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+/├\1╮\2/' \ + -e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m/\1├╯\x1b\[m/' \ + -e 's/╮(\x1b\[[0-9;]*m)+\\/╮\1╰╮/' \ + -e 's/╯(\x1b\[[0-9;]*m)+\//╯\1╭╯/' \ + -e 's/(\||\\)\x1b\[m (\x1b\[[0-9;]*m)/╰╮\2/' \ + -e 's/(\x1b\[[0-9;]*m)\\/\1╮/g' \ + -e 's/(\x1b\[[0-9;]*m)\//\1╯/g' \ + -e 's/^\*|(\x1b\[m )\*/\1⎬/g' \ + -e 's/(\x1b\[[0-9;]*m)\|/\1│/g' \ + | command less -r $([ $# -eq 0 ] && echo "+/[^/]HEAD") + + setterm -linewrap on 2> /dev/null +} + +find() { + if [ $# = 1 ] + then + command find . -iname "*$@*" + else + command find "$@" + fi +} + +rga-fzf() { + RG_PREFIX="rga --files-with-matches" + local file + file="$( + FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \ + fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \ + --phony -q "$1" \ + --bind "change:reload:$RG_PREFIX {q}" \ + --preview-window="70%:wrap" + )" && + echo "opening $file" && + xdg-open "$file" +} + +### fd +[ -e /usr/local/src/fd/fd ] && source /usr/local/src/fd/autocomplete/fd.bash-completion + +### Hyperfine +[ -e /usr/local/src/hyperfine/hyperfine ] && source /usr/local/src/hyperfine/autocomplete/hyperfine.bash-completion + +### mcfly +export MCFLY_KEY_SCHEME=vim +[ -e /usr/local/src/mcfly/mcfly ] && eval "$(mcfly init bash)" + +### wp-cli +[ -e /usr/local/bin/wp ] && source /usr/local/src/wp-cli/wp-completion.bash + +### direnv +[ -e /usr/local/bin/direnv ] && eval "$(direnv hook bash)" + +### Googler +[ -e /usr/local/bin/googler ] && source /usr/local/src/googler/googler-completion.bash +[ -e /usr/local/bin/googler ] && source /usr/local/src/googler/googler_at + +### FZF +[ -f ~/.local/fzf.bash ] && source ~/.local/fzf.bash + +### Google Cloud SDK +if type brew &> /dev/null; then + [[ ! -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc" ]] || source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc" + [[ ! -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" ]] || source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" +fi + +### zoxide +type zoxide &> /dev/null && eval "$(zoxide init bash)" + +### Fig +[[ -f "$HOME/.fig/shell/bashrc.post.bash" ]] && . "$HOME/.fig/shell/bashrc.post.bash" diff --git a/dotfiles/.config/bashtop/bashtop.cfg b/dotfiles/.config/bashtop/bashtop.cfg new file mode 100644 index 00000000..97f927de --- /dev/null +++ b/dotfiles/.config/bashtop/bashtop.cfg @@ -0,0 +1 @@ +color_theme="flat-remix" diff --git a/dotfiles/.config/inkscape/palettes/flat-remix-palette.gpl b/dotfiles/.config/inkscape/palettes/flat-remix-palette.gpl new file mode 100644 index 00000000..4a6eab69 --- /dev/null +++ b/dotfiles/.config/inkscape/palettes/flat-remix-palette.gpl @@ -0,0 +1,143 @@ +GIMP Palette +Name: flat-remix-palette +# +255 255 255 #FFFFFF +230 230 230 #E6E6E6 +204 204 204 #CCCCCC +179 179 179 #B3B3B3 +153 153 153 #999999 +128 128 128 #808080 +102 102 102 #666666 + 76 76 76 #4C4C4C + 51 51 51 #333333 + 25 25 25 #191919 + 0 0 0 #000000 + +115 118 128 #737680 + 96 99 110 #60636E + 76 79 92 #4C4F5C + 56 60 74 #383C4A + 51 54 67 #333643 + 45 48 59 #2D303B + 39 42 52 #272A34 + +189 151 119 #BD9777 +180 137 100 #B48964 +170 122 80 #AA7A50 +161 107 61 #A16B3D +145 97 55 #916137 +129 86 49 #815631 +113 75 43 #714B2B + +149 129 113 #958171 +134 112 93 #86705D +119 94 73 #775E49 +104 76 53 #684C35 + 94 69 48 #5E4530 + 83 61 42 #533D2A + 73 53 37 #493525 + +174 122 196 #AE7AC4 +163 104 188 #A368BC +151 85 179 #9755B3 +140 66 171 #8C42AB +126 60 154 #7E3C9A +112 53 137 #703589 + 98 46 120 #622E78 + +205 92 129 #CD5C81 +198 69 112 #C64570 +191 46 94 #BF2E5E +184 23 76 #B8174C +166 21 69 #A61545 +147 18 61 #93123D +129 16 53 #811035 + +225 94 94 #E15E5E +221 71 71 #DD4747 +216 48 48 #D83030 +212 25 25 #D41919 +191 23 23 #BF1717 +170 20 20 #AA1414 +149 18 18 #951212 + +254 113 113 #FE7171 +253 93 93 #FD5D5D +253 73 73 #FD4949 +253 53 53 #FD3535 +228 48 48 #E43030 +202 42 42 #CA2A2A +178 37 37 #B22525 + +254 164 76 #FEA44C +253 151 51 #FD9733 +253 138 25 #FD8A19 +253 125 0 #FD7D00 + +255 216 110 #FFD86E +255 210 89 #FFD259 +255 204 68 #FFCC44 +255 199 48 #FFC730 + +250 232 149 #FAE895 +249 229 134 #F9E586 +249 225 119 #F9E177 +248 222 104 #F8DE68 + + 84 189 142 #54BD8E + 61 180 126 #3DB47E + 36 170 110 #24AA6E + 12 161 94 #0CA15E + 11 145 85 #0B9155 + 10 129 75 #0A814B + 8 113 66 #087142 + + 94 189 171 #5EBDAB + 71 180 159 #47B49F + 48 170 147 #30AA93 + 25 161 135 #19A187 + 23 145 122 #17917A + 20 129 108 #14816C + 18 113 95 #12715F + +101 207 212 #65CFD4 + 79 200 206 #4FC8CE + 57 193 200 #39C1C8 + 35 186 194 #23BAC2 + 32 168 175 #20A8AF + 28 149 155 #1C959B + 25 131 136 #198388 + +128 198 237 #80C6ED +110 190 235 #6EBEEB + 92 182 232 #5CB6E8 + 74 174 230 #4AAEE6 + 67 157 207 #439DCF + 59 139 184 #3B8BB8 + 52 122 161 #347AA1 + +114 162 244 #72A2F4 + 94 149 243 #5E95F3 + 74 136 241 #4A88F1 + 54 123 240 #367BF0 + 49 111 216 #316FD8 + 43 98 192 #2B62C0 + 38 86 168 #2656A8 + +103 139 200 #678BC8 + 81 123 193 #517BC1 + 59 106 185 #3B6AB9 + 38 90 177 #265AB1 + 34 81 160 #2251A0 + 30 72 142 #1E488E + 27 63 124 #1B3F7C + + 91 115 157 #5B739D + 68 96 143 #44608F + 44 76 129 #2C4C81 + 21 56 115 #153873 + 19 51 104 #133368 + 17 45 92 #112D5C + 15 39 81 #0F2751 + + diff --git a/dotfiles/.config/qt5ct/qt5ct.conf b/dotfiles/.config/qt5ct/qt5ct.conf new file mode 100644 index 00000000..1189d1f0 --- /dev/null +++ b/dotfiles/.config/qt5ct/qt5ct.conf @@ -0,0 +1,13 @@ +[Appearance] +custom_palette=true +icon_theme=Flat-Remix-Blue-Dark +color_scheme_path=/usr/share/qt5ct/colors/flat-remix-light.conf +standard_dialogs=default +style=Fusion + +[Interface] +stylesheets=/usr/share/qt5ct/qss/fusion-simple-scrollbar.qss + +[Fonts] +fixed=@Variant(\0\0\0@\0\0\0\x12\0\x46\0i\0r\0\x61\0 \0\x43\0o\0\x64\0\x65@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x39\x10) +general=@Variant(\0\0\0@\0\0\0\x12\0\x43\0\x61\0n\0t\0\x61\0r\0\x65\0l\0l@&\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10) diff --git a/dotfiles/.config/tilix/schemes/Flat-Remix.json b/dotfiles/.config/tilix/schemes/Flat-Remix.json new file mode 100644 index 00000000..dc52f55a --- /dev/null +++ b/dotfiles/.config/tilix/schemes/Flat-Remix.json @@ -0,0 +1,35 @@ +{ + "background-color": "#272A34", + "badge-color": "#AC7EA8", + "bold-color": "#FFFFFF", + "comment": "", + "cursor-background-color": "#000000", + "cursor-foreground-color": "#FFFFFF", + "foreground-color": "#FFFFFF", + "highlight-background-color": "#000000", + "highlight-foreground-color": "#FFFFFF", + "name": "Flat-Remix", + "palette": [ + "#1F2229", + "#D41919", + "#5EBDAB", + "#FEA44C", + "#367bf0", + "#9755b3", + "#49AEE6", + "#E6E6E6", + "#198388", + "#EC0101", + "#47D4B9", + "#FF8A18", + "#277FFF", + "#962ac3", + "#05A1F7", + "#FFFFFF" + ], + "use-badge-color": false, + "use-bold-color": false, + "use-cursor-color": false, + "use-highlight-color": false, + "use-theme-colors": true +} \ No newline at end of file diff --git a/dotfiles/.gitconfig b/dotfiles/.gitconfig index e69de29b..f87daba3 100644 --- a/dotfiles/.gitconfig +++ b/dotfiles/.gitconfig @@ -0,0 +1,19 @@ +[user] + email = + name = + +[color] + diff = auto + status = auto + branch = auto + interactive = auto + ui = true + pager = true +[credential] + helper = cache --timeout=3600 +[pull] + rebase = true +[core] + attributesfile = ~/.gitattributes +[diff "image"] + command = compare $2 $1 png:- | montage -geometry +4+4 $2 - $1 png:- | display -title \"$1\" - diff --git a/dotfiles/.local/antigen.zsh b/dotfiles/.local/antigen.zsh new file mode 100644 index 00000000..e8132076 --- /dev/null +++ b/dotfiles/.local/antigen.zsh @@ -0,0 +1,2057 @@ +###################################################################### +# This file was autogenerated by `make`. Do not edit it directly! +###################################################################### +# Antigen: A simple plugin manager for zsh + # Authors: Shrikant Sharat Kandula + # and Contributors + # Homepage: http://antigen.sharats.me + # License: MIT License +zmodload zsh/parameter +autoload -U is-at-least + +# While boot.zsh is part of the ext/cache functionallity it may be disabled +# with ANTIGEN_CACHE flag, and it's always compiled with antigen.zsh +if [[ $ANTIGEN_CACHE != false ]]; then + ANTIGEN_CACHE="${ANTIGEN_CACHE:-${ADOTDIR:-$HOME/.antigen}/init.zsh}" + ANTIGEN_RSRC="${ANTIGEN_RSRC:-${ADOTDIR:-$HOME/.antigen}/.resources}" + + # It may not be necessary to check ANTIGEN_AUTO_CONFIG. + if [[ $ANTIGEN_AUTO_CONFIG != false && -f $ANTIGEN_RSRC ]]; then + # Check the list of files for configuration changes (uses -nt comp) + ANTIGEN_CHECK_FILES=$(cat $ANTIGEN_RSRC 2> /dev/null) + ANTIGEN_CHECK_FILES=(${(@f)ANTIGEN_CHECK_FILES}) + + for config in $ANTIGEN_CHECK_FILES; do + if [[ "$config" -nt "$config.zwc" ]]; then + # Flag configuration file as newer + { zcompile "$config" } &! + # Kill cache file in order to force full loading (see a few lines below) + [[ -f "$ANTIGEN_CACHE" ]] && rm -f "$ANTIGEN_CACHE" + fi + done + fi + + # If there is a cache file do load from it + if [[ -f $ANTIGEN_CACHE && ! $_ANTIGEN_CACHE_LOADED == true ]]; then + # Wrap antigen in order to defer cache source until `antigen-apply` + antigen() { + if [[ $1 == "apply" ]]; then + source "$ANTIGEN_CACHE" + # Handle `antigen-init` command properly + elif [[ $1 == "init" ]]; then + source "$2" + fi + } + # Do not continue loading antigen as cache bundle takes care of it. + return 0 + fi +fi +[[ -z "$_ANTIGEN_INSTALL_DIR" ]] && _ANTIGEN_INSTALL_DIR=${0:A:h} + +# Each line in this string has the following entries separated by a space +# character. +# , , , +[[ $_ANTIGEN_CACHE_LOADED != true ]] && typeset -aU _ANTIGEN_BUNDLE_RECORD + +# Do not load anything if git is not available. +if (( ! $+commands[git] )); then + echo 'Antigen: Please install git to use Antigen.' >&2 + return 1 +fi + +# Used to defer compinit/compdef +typeset -a __deferred_compdefs +compdef () { __deferred_compdefs=($__deferred_compdefs "$*") } + +# A syntax sugar to avoid the `-` when calling antigen commands. With this +# function, you can write `antigen-bundle` as `antigen bundle` and so on. +antigen () { + local cmd="$1" + if [[ -z "$cmd" ]]; then + echo 'Antigen: Please give a command to run.' >&2 + return 1 + fi + shift + + if (( $+functions[antigen-$cmd] )); then + "antigen-$cmd" "$@" + return $? + else + echo "Antigen: Unknown command: $cmd" >&2 + return 1 + fi +} +# Returns the bundle's git revision +# +# Usage +# -antigen-bundle-rev bundle-name [is_local_clone] +# +# Returns +# Bundle rev-parse output (branch name or short ref name) +-antigen-bundle-rev () { + local bundle=$1 + local is_local_clone=$2 + + local bundle_path=$bundle + # Get bunde path inside $ADOTDIR if bundle was effectively cloned + if [[ "$is_local_clone" == "true" ]]; then + bundle_path=$(-antigen-get-clone-dir $bundle) + fi + + local ref + ref=$(git --git-dir="$bundle_path/.git" rev-parse --abbrev-ref '@' 2>/dev/null) + + # Avoid 'HEAD' when in detached mode + if [[ $ref == "HEAD" ]]; then + ref=$(git --git-dir="$bundle_path/.git" describe --tags --exact-match 2>/dev/null \ + || git --git-dir="$bundle_path/.git" rev-parse --short '@' 2>/dev/null || "-") + fi + echo $ref +} +# Usage: +# -antigen-bundle-short-name "https://github.com/user/repo.git[|*]" "[branch/name]" +# Returns: +# user/repo@branch/name +-antigen-bundle-short-name () { + local bundle_name="${1%|*}" + local bundle_branch="$2" + local match mbegin mend MATCH MBEGIN MEND + + [[ "$bundle_name" =~ '.*/(.*/.*).*$' ]] && bundle_name=$match[1] + bundle_name="${bundle_name%.git*}" + + if [[ -n $bundle_branch ]]; then + bundle_name="$bundle_name@$bundle_branch" + fi + + echo $bundle_name +} +# Echo the bundle specs as in the record. The first line is not echoed since it +# is a blank line. +-antigen-echo-record () { + echo ${(j:\n:)_ANTIGEN_BUNDLE_RECORD} +} +# Filters _ANTIGEN_BUNDLE_RECORD for $1 +# +# Usage +# -antigen-find-bundle example/bundle +# +# Returns +# String if bundle is found +-antigen-find-bundle () { + echo $(-antigen-find-record $1 | cut -d' ' -f1) +} + +# Filters _ANTIGEN_BUNDLE_RECORD for $1 +# +# Usage +# -antigen-find-record example/bundle +# +# Returns +# String if record is found +-antigen-find-record () { + local bundle=$1 + + if [[ $# -eq 0 ]]; then + return 1 + fi + + local record=${bundle/\|/\\\|} + echo "${_ANTIGEN_BUNDLE_RECORD[(r)*$record*]}" +} +# Returns bundle names from _ANTIGEN_BUNDLE_RECORD +# +# Usage +# -antigen-get-bundles [--short|--simple|--long] +# +# Returns +# List of bundles installed +-antigen-get-bundles () { + local mode revision url bundle_name bundle_entry loc no_local_clone + local record bundle make_local_clone + mode=${1:-"--short"} + + for record in $_ANTIGEN_BUNDLE_RECORD; do + bundle=(${(@s/ /)record}) + url=$bundle[1] + loc=$bundle[2] + make_local_clone=$bundle[4] + + bundle_name=$(-antigen-bundle-short-name $url) + + case "$mode" in + --short) + # Only check revision for bundle with a requested branch + if [[ $url == *\|* ]]; then + revision=$(-antigen-bundle-rev $url $make_local_clone) + else + revision="master" + fi + + if [[ $loc != '/' ]]; then + bundle_name="$bundle_name ~ $loc" + fi + echo "$bundle_name @ $revision" + ;; + --simple) + echo "$bundle_name" + ;; + --long) + echo "$record" + ;; + esac + done +} +# Usage: +# -antigen-get-clone-dir "https://github.com/zsh-users/zsh-syntax-highlighting.git[|feature/branch]" +# Returns: +# $ANTIGEN_BUNDLES/zsh-users/zsh-syntax-highlighting[-feature-branch] +-antigen-get-clone-dir () { + local bundle="$1" + local url="${bundle%|*}" + local branch match mbegin mend MATCH MBEGIN MEND + [[ "$bundle" =~ "\|" ]] && branch="${bundle#*|}" + + # Takes a repo url and mangles it, giving the path that this url will be + # cloned to. Doesn't actually clone anything. + local clone_dir="$ANTIGEN_BUNDLES" + + url=$(-antigen-bundle-short-name $url) + + # Suffix with branch/tag name + [[ -n "$branch" ]] && url="$url-${branch//\//-}" + url=${url//\*/x} + + echo "$clone_dir/$url" +} +# Returns bundles flagged as make_local_clone +# +# Usage +# -antigen-cloned-bundles +# +# Returns +# Bundle metadata +-antigen-get-cloned-bundles() { + -antigen-echo-record | + awk '$4 == "true" {print $1}' | + sort -u +} +# Returns a list of themes from a default library (omz) +# +# Usage +# -antigen-get-themes +# +# Returns +# List of themes by name +-antigen-get-themes () { + local library='robbyrussell/oh-my-zsh' + local bundle=$(-antigen-find-bundle $library) + + if [[ -n "$bundle" ]]; then + local dir=$(-antigen-get-clone-dir $ANTIGEN_DEFAULT_REPO_URL) + echo $(ls $dir/themes/ | grep '.zsh-theme$' | sed 's/.zsh-theme//') + fi + + return 0 +} + +# This function check ZSH_EVAL_CONTEXT to determine if running in interactive shell. +# +# Usage +# -antigen-interactive-mode +# +# Returns +# Either true or false depending if we are running in interactive mode +-antigen-interactive-mode () { + WARN "-antigen-interactive-mode: $ZSH_EVAL_CONTEXT \$_ANTIGEN_INTERACTIVE = $_ANTIGEN_INTERACTIVE" + if [[ $_ANTIGEN_INTERACTIVE != "" ]]; then + [[ $_ANTIGEN_INTERACTIVE == true ]]; + return + fi + + [[ "$ZSH_EVAL_CONTEXT" == toplevel* || "$ZSH_EVAL_CONTEXT" == cmdarg* ]]; +} +# Parses and retrieves a remote branch given a branch name. +# +# If the branch name contains '*' it will retrieve remote branches +# and try to match against tags and heads, returning the latest matching. +# +# Usage +# -antigen-parse-branch https://github.com/user/repo.git x.y.z +# +# Returns +# Branch name +-antigen-parse-branch () { + local url="$1" branch="$2" branches + + local match mbegin mend MATCH MBEGIN MEND + + if [[ "$branch" =~ '\*' ]]; then + branches=$(git ls-remote --tags -q "$url" "$branch"|cut -d'/' -f3|sort -n|tail -1) + # There is no --refs flag in git 1.8 and below, this way we + # emulate this flag -- also git 1.8 ref order is undefined. + branch=${${branches#*/*/}%^*} # Why you are like this? + fi + + echo $branch +} +-antigen-update-repos () { + local repo bundle url target + local log=/tmp/antigen-v2-migrate.log + + echo "It seems you have bundles cloned with Antigen v1.x." + echo "We'll try to convert directory structure to v2." + echo + + echo -n "Moving bundles to '\$ADOTDIR/bundles'... " + + # Migrate old repos -> bundles + local errors=0 + for repo in $ADOTDIR/repos/*; do + bundle=${repo/$ADOTDIR\/repos\//} + bundle=${bundle//-SLASH-/\/} + bundle=${bundle//-COLON-/\:} + bundle=${bundle//-STAR-/\*} + url=${bundle//-PIPE-/\|} + target=$(-antigen-get-clone-dir $url) + mkdir -p "${target:A:h}" + echo " ---> ${repo/$ADOTDIR\/} -> ${target/$ADOTDIR\/}" | tee > $log + mv "$repo" "$target" &> $log + if [[ $? != 0 ]]; then + echo "Failed to migrate '$repo'!." + errors+=1 + fi + done + + if [[ $errors == 0 ]]; then + echo "Done." + else + echo "An error ocurred!" + fi + echo + + if [[ "$(ls -A $ADOTDIR/repos | wc -l | xargs)" == 0 ]]; then + echo "You can safely remove \$ADOTDIR/repos." + else + echo "Some bundles couldn't be migrated. See \$ADOTDIR/repos." + fi + + echo + if [[ $errors == 0 ]]; then + echo "Bundles migrated successfuly." + rm $log + else + echo "Some errors occured. Review migration log in '$log'." + fi + antigen-reset +} +# Ensure that a clone exists for the given repo url and branch. If the first +# argument is `update` and if a clone already exists for the given repo +# and branch, it is pull-ed, i.e., updated. +# +# This function expects three arguments in order: +# - 'url=' +# - 'update=true|false' +# - 'verbose=true|false' +# +# Returns true|false Whether cloning/pulling was succesful +-antigen-ensure-repo () { + # Argument defaults. Previously using ${1:?"missing url argument"} format + # but it seems to mess up with cram + if (( $# < 1 )); then + echo "Antigen: Missing url argument." + return 1 + fi + + # The url. No sane default for this, so just empty. + local url=$1 + # Check if we have to update. + local update=${2:-false} + # Verbose output. + local verbose=${3:-false} + + shift $# + + # Get the clone's directory as per the given repo url and branch. + local clone_dir=$(-antigen-get-clone-dir $url) + if [[ -d "$clone_dir" && $update == false ]]; then + return true + fi + + # A temporary function wrapping the `git` command with repeated arguments. + --plugin-git () { + (\cd -q "$clone_dir" && eval ${ANTIGEN_CLONE_ENV} git --git-dir="$clone_dir/.git" --no-pager "$@" &>>! $ANTIGEN_LOG) + } + + local success=false + + # If its a specific branch that we want, checkout that branch. + local branch="master" # TODO FIX THIS + if [[ $url == *\|* ]]; then + branch="$(-antigen-parse-branch ${url%|*} ${url#*|})" + fi + + if [[ ! -d $clone_dir ]]; then + eval ${ANTIGEN_CLONE_ENV} git clone ${=ANTIGEN_CLONE_OPTS} --branch "$branch" -- "${url%|*}" "$clone_dir" &>> $ANTIGEN_LOG + success=$? + elif $update; then + # Save current revision. + local old_rev="$(--plugin-git rev-parse HEAD)" + # Pull changes if update requested. + --plugin-git checkout "$branch" + --plugin-git pull origin "$branch" + success=$? + + # Update submodules. + --plugin-git submodule update ${=ANTIGEN_SUBMODULE_OPTS} + # Get the new revision. + local new_rev="$(--plugin-git rev-parse HEAD)" + fi + + if [[ -n $old_rev && $old_rev != $new_rev ]]; then + echo Updated from $old_rev[0,7] to $new_rev[0,7]. + if $verbose; then + --plugin-git log --oneline --reverse --no-merges --stat '@{1}..' + fi + fi + + # Remove the temporary git wrapper function. + unfunction -- --plugin-git + + return $success +} +# Helper function: Same as `$1=$2`, but will only happen if the name +# specified by `$1` is not already set. +-antigen-set-default () { + local arg_name="$1" + local arg_value="$2" + eval "test -z \"\$$arg_name\" && typeset -g $arg_name='$arg_value'" +} + +-antigen-env-setup () { + typeset -gU fpath path + + # Pre-startup initializations. + -antigen-set-default ANTIGEN_OMZ_REPO_URL \ + https://github.com/robbyrussell/oh-my-zsh.git + -antigen-set-default ANTIGEN_PREZTO_REPO_URL \ + https://github.com/sorin-ionescu/prezto.git + -antigen-set-default ANTIGEN_DEFAULT_REPO_URL $ANTIGEN_OMZ_REPO_URL + + # Default Antigen directory. + -antigen-set-default ADOTDIR $HOME/.antigen + [[ ! -d $ADOTDIR ]] && mkdir -p $ADOTDIR + + # Defaults bundles directory. + -antigen-set-default ANTIGEN_BUNDLES $ADOTDIR/bundles + + # If there is no bundles directory, create it. + if [[ ! -d $ANTIGEN_BUNDLES ]]; then + mkdir -p $ANTIGEN_BUNDLES + # Check for v1 repos directory, transform it to v2 format. + [[ -d $ADOTDIR/repos ]] && -antigen-update-repos + fi + + -antigen-set-default ANTIGEN_COMPDUMP "${ADOTDIR:-$HOME}/.zcompdump" + -antigen-set-default ANTIGEN_LOG /dev/null + + # CLONE_OPTS uses ${=CLONE_OPTS} expansion so don't use spaces + # for arguments that can be passed as `--key=value`. + -antigen-set-default ANTIGEN_CLONE_ENV "GIT_TERMINAL_PROMPT=0" + -antigen-set-default ANTIGEN_CLONE_OPTS "--single-branch --recursive --depth=1" + -antigen-set-default ANTIGEN_SUBMODULE_OPTS "--recursive --depth=1" + + # Complain when a bundle is already installed. + -antigen-set-default _ANTIGEN_WARN_DUPLICATES true + + # Compatibility with oh-my-zsh themes. + -antigen-set-default _ANTIGEN_THEME_COMPAT true + + # Add default built-in extensions to load at start up + -antigen-set-default _ANTIGEN_BUILTIN_EXTENSIONS 'lock parallel defer cache' + + # Setup antigen's own completion. + if -antigen-interactive-mode; then + TRACE "Gonna create compdump file @ env-setup" COMPDUMP + autoload -Uz compinit + compinit -d "$ANTIGEN_COMPDUMP" + compdef _antigen antigen + else + (( $+functions[antigen-ext-init] )) && antigen-ext-init + fi +} +# Load a given bundle by sourcing it. +# +# The function also modifies fpath to add the bundle path. +# +# Usage +# -antigen-load "bundle-url" ["location"] ["make_local_clone"] ["btype"] +# +# Returns +# Integer. 0 if success 1 if an error ocurred. +-antigen-load () { + local bundle list + typeset -A bundle; bundle=($@) + + typeset -Ua list; list=() + local location="${bundle[dir]}/${bundle[loc]}" + + # Prioritize location when given. + if [[ -f "${location}" ]]; then + list=(${location}) + else + # Directory locations must be suffixed with slash + location="$location/" + + # Prioritize theme with antigen-theme + if [[ ${bundle[btype]} == "theme" ]]; then + list=(${location}*.zsh-theme(N[1])) + fi + + # Common frameworks + if [[ $#list == 0 ]]; then + # dot-plugin, init and functions support (omz, prezto) + # Support prezto function loading. See https://github.com/zsh-users/antigen/pull/428 + list=(${location}*.plugin.zsh(N[1]) ${location}init.zsh(N[1]) ${location}/functions(N[1])) + fi + + # Default to zsh and sh + if [[ $#list == 0 ]]; then + list=(${location}*.zsh(N) ${location}*.sh(N)) + fi + fi + + -antigen-load-env ${(kv)bundle} + + # If there is any sourceable try to load it + if ! -antigen-load-source "${list[@]}" && [[ ! -d ${location} ]]; then + return 1 + fi + + return 0 +} + +-antigen-load-env () { + typeset -A bundle; bundle=($@) + local location=${bundle[dir]}/${bundle[loc]} + + # Load to path if there is no sourceable + if [[ -d ${location} ]]; then + PATH="$PATH:${location:A}" + fpath+=("${location:A}") + return + fi + + PATH="$PATH:${location:A:h}" + fpath+=("${location:A:h}") +} + +-antigen-load-source () { + typeset -a list + list=($@) + local src match mbegin mend MATCH MBEGIN MEND + + # Return error when we're given an empty list + if [[ $#list == 0 ]]; then + return 1 + fi + + # Using a for rather than `source $list` as we need to check for zsh-themes + # In order to create antigen-compat file. This is only needed for interactive-mode + # theme switching, for static loading (cache) there is no need. + for src in $list; do + if [[ $_ANTIGEN_THEME_COMPAT == true && -f "$src" && "$src" == *.zsh-theme* ]]; then + local compat="${src:A}.antigen-compat" + echo "# Generated by Antigen. Do not edit!" >! "$compat" + cat $src | sed -Ee '/\{$/,/^\}/!{ + s/^local // + }' >>! "$compat" + src="$compat" + fi + + if ! source "$src" 2>/dev/null; then + return 1 + fi + done +} +# Usage: +# -antigen-parse-args output_assoc_arr +-antigen-parse-args () { + local argkey key value index=0 args + local match mbegin mend MATCH MBEGIN MEND + + local var=$1 + shift + + # Bundle spec arguments' default values. + #setopt XTRACE VERBOSE + builtin typeset -A args + args[url]="$ANTIGEN_DEFAULT_REPO_URL" + #unsetopt XTRACE VERBOSE + args[loc]=/ + args[make_local_clone]=true + args[btype]=plugin + #args[branch]= # commented out as it may cause assoc array kv mismatch + + while [[ $# -gt 0 ]]; do + argkey="${1%\=*}" + key="${argkey//--/}" + value="${1#*=}" + + case "$argkey" in + --url|--loc|--branch|--btype) + if [[ "$value" == "$argkey" ]]; then + printf "Required argument for '%s' not provided.\n" $key >&2 + else + args[$key]="$value" + fi + ;; + --no-local-clone) + args[make_local_clone]=false + ;; + --*) + printf "Unknown argument '%s'.\n" $key >&2 + ;; + *) + value=$key + case $index in + 0) + key=url + local domain="" + local url_path=$value + # Full url with protocol or ssh github url (github.com:org/repo) + if [[ "$value" =~ "://" || "$value" =~ ":" ]]; then + if [[ "$value" =~ [@.][^/:]+[:]?[0-9]*[:/]?(.*)@?$ ]]; then + url_path=$match[1] + domain=${value/$url_path/} + fi + fi + + if [[ "$url_path" =~ '@' ]]; then + args[branch]="${url_path#*@}" + value="$domain${url_path%@*}" + else + value="$domain$url_path" + fi + ;; + 1) key=loc ;; + esac + let index+=1 + args[$key]="$value" + ;; + esac + + shift + done + + # Check if url is just the plugin name. Super short syntax. + if [[ "${args[url]}" != */* ]]; then + case "$ANTIGEN_DEFAULT_REPO_URL" in + "$ANTIGEN_OMZ_REPO_URL") + args[loc]="plugins/${args[url]}" + ;; + "$ANTIGEN_PREZTO_REPO_URL") + args[loc]="modules/${args[url]}" + ;; + *) + args[loc]="${args[url]}" + ;; + esac + args[url]="$ANTIGEN_DEFAULT_REPO_URL" + fi + + # Resolve the url. + # Expand short github url syntax: `username/reponame`. + local url="${args[url]}" + if [[ $url != git://* && + $url != https://* && + $url != http://* && + $url != ssh://* && + $url != /* && + $url != *github.com:*/* + ]]; then + url="https://github.com/${url%.git}.git" + fi + args[url]="$url" + + # Ignore local clone if url given is not a git directory + if [[ ${args[url]} == /* && ! -d ${args[url]}/.git ]]; then + args[make_local_clone]=false + fi + + # Add the branch information to the url if we need to create a local clone. + # Format url in bundle-metadata format: url[|branch] + if [[ ! -z "${args[branch]}" && ${args[make_local_clone]} == true ]]; then + args[url]="${args[url]}|${args[branch]}" + fi + + # Add the theme extension to `loc`, if this is a theme, but only + # if it's especified, ie, --loc=theme-name, in case when it's not + # specified antige-load-list will look for *.zsh-theme files + if [[ ${args[btype]} == "theme" && + ${args[loc]} != "/" && ${args[loc]} != *.zsh-theme ]]; then + args[loc]="${args[loc]}.zsh-theme" + fi + + local name="${args[url]%|*}" + local branch="${args[branch]}" + + # Extract bundle name. + if [[ "$name" =~ '.*/(.*/.*).*$' ]]; then + name="${match[1]}" + fi + name="${name%.git*}" + + # Format bundle name with optional branch. + if [[ -n "${branch}" ]]; then + args[name]="${name}@${branch}" + else + args[name]="${name}" + fi + + # Format bundle path. + if [[ ${args[make_local_clone]} == true ]]; then + local bpath="$name" + # Suffix with branch/tag name + if [[ -n "$branch" ]]; then + # bpath is in the form of repo/name@version => repo/name-version + # Replace / with - in bundle branch. + local bbranch=${branch//\//-} + # If branch/tag is semver-like do replace * by x. + bbranch=${bbranch//\*/x} + bpath="${name}-${bbranch}" + fi + + bpath="$ANTIGEN_BUNDLES/$bpath" + args[dir]="${(qq)bpath}" + else + # if it's local then path is just the "url" argument, loc remains the same + args[dir]=${args[url]} + fi + + # Escape url and branch (may contain semver-like and pipe characters) + args[url]="${(qq)args[url]}" + if [[ -n "${args[branch]}" ]]; then + args[branch]="${(qq)args[branch]}" + fi + + # Escape bundle name (may contain semver-like characters) + args[name]="${(qq)args[name]}" + + eval "${var}=(${(kv)args})" + + return 0 +} +# Updates revert-info data with git hash. +# +# This does process only cloned bundles. +# +# Usage +# -antigen-revert-info +# +# Returns +# Nothing. Generates/updates $ADOTDIR/revert-info. +-antigen-revert-info() { + local url + # Update your bundles, i.e., `git pull` in all the plugin repos. + date >! $ADOTDIR/revert-info + + -antigen-get-cloned-bundles | while read url; do + local clone_dir="$(-antigen-get-clone-dir "$url")" + if [[ -d "$clone_dir" ]]; then + (echo -n "$clone_dir:" + \cd -q "$clone_dir" + git rev-parse HEAD) >> $ADOTDIR/revert-info + fi + done +} +-antigen-use-oh-my-zsh () { + typeset -g ZSH ZSH_CACHE_DIR + ANTIGEN_DEFAULT_REPO_URL=$ANTIGEN_OMZ_REPO_URL + if [[ -z "$ZSH" ]]; then + ZSH="$(-antigen-get-clone-dir "$ANTIGEN_DEFAULT_REPO_URL")" + fi + if [[ -z "$ZSH_CACHE_DIR" ]]; then + ZSH_CACHE_DIR="$ZSH/cache/" + fi + antigen-bundle --loc=lib +} +-antigen-use-prezto () { + ANTIGEN_DEFAULT_REPO_URL=$ANTIGEN_PREZTO_REPO_URL + antigen-bundle "$ANTIGEN_PREZTO_REPO_URL" +} +# Initialize completion +antigen-apply () { + LOG "Called antigen-apply" + + # Load the compinit module. This will readefine the `compdef` function to + # the one that actually initializes completions. + TRACE "Gonna create compdump file @ apply" COMPDUMP + autoload -Uz compinit + compinit -d "$ANTIGEN_COMPDUMP" + + # Apply all `compinit`s that have been deferred. + local cdef + for cdef in "${__deferred_compdefs[@]}"; do + compdef "$cdef" + done + + { zcompile "$ANTIGEN_COMPDUMP" } &! + + unset __deferred_compdefs +} +# Syntaxes +# antigen-bundle [=/] +# Keyword only arguments: +# branch - The branch of the repo to use for this bundle. +antigen-bundle () { + TRACE "Called antigen-bundle with $@" BUNDLE + if [[ -z "$1" ]]; then + printf "Antigen: Must provide a bundle url or name.\n" >&2 + return 1 + fi + + builtin typeset -A bundle; -antigen-parse-args 'bundle' ${=@} + if [[ -z ${bundle[btype]} ]]; then + bundle[btype]=bundle + fi + + local record="${bundle[url]} ${bundle[loc]} ${bundle[btype]} ${bundle[make_local_clone]}" + if [[ $_ANTIGEN_WARN_DUPLICATES == true && ! ${_ANTIGEN_BUNDLE_RECORD[(I)$record]} == 0 ]]; then + printf "Seems %s is already installed!\n" ${bundle[name]} + return 1 + fi + + # Clone bundle if we haven't done do already. + if [[ ! -d "${bundle[dir]}" ]]; then + if ! -antigen-bundle-install ${(kv)bundle}; then + return 1 + fi + fi + + # Load the plugin. + if ! -antigen-load ${(kv)bundle}; then + TRACE "-antigen-load failed to load ${bundle[name]}" BUNDLE + printf "Antigen: Failed to load %s.\n" ${bundle[btype]} >&2 + return 1 + fi + + # Only add it to the record if it could be installed and loaded. + _ANTIGEN_BUNDLE_RECORD+=("$record") +} + +# +# Usage: +# -antigen-bundle-install +# Returns: +# 1 if it fails to install bundle +-antigen-bundle-install () { + typeset -A bundle; bundle=($@) + + # Ensure a clone exists for this repo, if needed. + # Get the clone's directory as per the given repo url and branch. + local bpath="${bundle[dir]}" + # Clone if it doesn't already exist. + local start=$(date +'%s') + + printf "Installing %s... " "${bundle[name]}" + + if ! -antigen-ensure-repo "${bundle[url]}"; then + # Return immediately if there is an error cloning + TRACE "-antigen-bundle-instal failed to clone ${bundle[url]}" BUNDLE + printf "Error! Activate logging and try again.\n" >&2 + return 1 + fi + + local took=$(( $(date +'%s') - $start )) + printf "Done. Took %ds.\n" $took +} +antigen-bundles () { + # Bulk add many bundles at one go. Empty lines and lines starting with a `#` + # are ignored. Everything else is given to `antigen-bundle` as is, no + # quoting rules applied. + local line + setopt localoptions no_extended_glob # See https://github.com/zsh-users/antigen/issues/456 + grep '^[[:space:]]*[^[:space:]#]' | while read line; do + antigen-bundle ${=line%#*} + done +} +# Cleanup unused repositories. +antigen-cleanup () { + local force=false + if [[ $1 == --force ]]; then + force=true + fi + + if [[ ! -d "$ANTIGEN_BUNDLES" || -z "$(\ls -A "$ANTIGEN_BUNDLES")" ]]; then + echo "You don't have any bundles." + return 0 + fi + + # Find directores in ANTIGEN_BUNDLES, that are not in the bundles record. + typeset -a unused_clones clones + + local url record clone + for record in $(-antigen-get-cloned-bundles); do + url=${record% /*} + clones+=("$(-antigen-get-clone-dir $url)") + done + + for clone in $ANTIGEN_BUNDLES/*/*(/); do + if [[ $clones[(I)$clone] == 0 ]]; then + unused_clones+=($clone) + fi + done + + if [[ -z $unused_clones ]]; then + echo "You don't have any unidentified bundles." + return 0 + fi + + echo 'You have clones for the following repos, but are not used.' + echo "\n${(j:\n:)unused_clones}" + + if $force || (echo -n '\nDelete them all? [y/N] '; read -q); then + echo + echo + for clone in $unused_clones; do + echo -n "Deleting clone \"$clone\"..." + \rm -rf "$clone" + + echo ' done.' + done + else + echo + echo "Nothing deleted." + fi +} +antigen-help () { + antigen-version + + cat < [args] + +Commands: + apply Must be called in the zshrc after all calls to 'antigen bundle'. + bundle Install and load a plugin. + cache-gen Generate Antigen's cache with currently loaded bundles. + cleanup Remove clones of repos not used by any loaded plugins. + init Use caching to quickly load bundles. + list List currently loaded plugins. + purge Remove a bundle from the filesystem. + reset Clean the generated cache. + restore Restore plugin state from a snapshot file. + revert Revert plugins to their state prior to the last time 'antigen + update' was run. + selfupdate Update antigen. + snapshot Create a snapshot of all active plugin repos and save it to a + snapshot file. + update Update plugins. + use Load a supported zsh pre-packaged framework. + +For further details and complete documentation, visit the project's page at +'http://antigen.sharats.me'. +EOF +} +# Antigen command to load antigen configuration +# +# This method is slighlty more performing than using various antigen-* methods. +# +# Usage +# Referencing an antigen configuration file: +# +# antigen-init "/path/to/antigenrc" +# +# or using HEREDOCS: +# +# antigen-init <&2 + return 1 + fi + fi + + # Otherwise we expect it to be a heredoc + grep '^[[:space:]]*[^[:space:]#]' | while read -r line; do + eval $line + done +} +# List instaled bundles either in long (record), short or simple format. +# +# Usage +# antigen-list [--short|--long|--simple] +# +# Returns +# List of bundles +antigen-list () { + local format=$1 + + # List all currently installed bundles. + if [[ -z $_ANTIGEN_BUNDLE_RECORD ]]; then + echo "You don't have any bundles." >&2 + return 1 + fi + + -antigen-get-bundles $format +} +# Remove a bundle from filesystem +# +# Usage +# antigen-purge example/bundle [--force] +# +# Returns +# Nothing. Removes bundle from filesystem. +antigen-purge () { + local bundle=$1 + local force=$2 + + if [[ $# -eq 0 ]]; then + echo "Antigen: Missing argument." >&2 + return 1 + fi + + if -antigen-purge-bundle $bundle $force; then + antigen-reset + else + return $? + fi + + return 0 +} + +# Remove a bundle from filesystem +# +# Usage +# antigen-purge example/bundle [--force] +# +# Returns +# Nothing. Removes bundle from filesystem. +-antigen-purge-bundle () { + local bundle=$1 + local force=$2 + local clone_dir="" + + local record="" + local url="" + local make_local_clone="" + + if [[ $# -eq 0 ]]; then + echo "Antigen: Missing argument." >&2 + return 1 + fi + + # local keyword doesn't work on zsh <= 5.0.0 + record=$(-antigen-find-record $bundle) + + if [[ ! -n "$record" ]]; then + echo "Bundle not found in record. Try 'antigen bundle $bundle' first." >&2 + return 1 + fi + + url="$(echo "$record" | cut -d' ' -f1)" + make_local_clone=$(echo "$record" | cut -d' ' -f4) + + if [[ $make_local_clone == "false" ]]; then + echo "Bundle has no local clone. Will not be removed." >&2 + return 1 + fi + + clone_dir=$(-antigen-get-clone-dir "$url") + if [[ $force == "--force" ]] || read -q "?Remove '$clone_dir'? (y/n) "; then + # Need empty line after read -q + [[ ! -n $force ]] && echo "" || echo "Removing '$clone_dir'."; + rm -rf "$clone_dir" + return $? + fi + + return 1 +} +# Removes cache payload and metadata if available +# +# Usage +# antigen-reset +# +# Returns +# Nothing +antigen-reset () { + [[ -f "$ANTIGEN_CACHE" ]] && rm -f "$ANTIGEN_CACHE" "$ANTIGEN_CACHE.zwc" 1> /dev/null + [[ -f "$ANTIGEN_RSRC" ]] && rm -f "$ANTIGEN_RSRC" 1> /dev/null + [[ -f "$ANTIGEN_COMPDUMP" ]] && rm -f "$ANTIGEN_COMPDUMP" "$ANTIGEN_COMPDUMP.zwc" 1> /dev/null + [[ -f "$ANTIGEN_LOCK" ]] && rm -f "$ANTIGEN_LOCK" 1> /dev/null + echo 'Done. Please open a new shell to see the changes.' +} +antigen-restore () { + local line + if [[ $# == 0 ]]; then + echo 'Please provide a snapshot file to restore from.' >&2 + return 1 + fi + + local snapshot_file="$1" + + # TODO: Before doing anything with the snapshot file, verify its checksum. + # If it fails, notify this to the user and confirm if restore should + # proceed. + + echo -n "Restoring from $snapshot_file..." + + sed -n '1!p' "$snapshot_file" | + while read line; do + local version_hash="${line%% *}" + local url="${line##* }" + local clone_dir="$(-antigen-get-clone-dir "$url")" + + if [[ ! -d $clone_dir ]]; then + git clone "$url" "$clone_dir" &> /dev/null + fi + + (\cd -q "$clone_dir" && git checkout $version_hash) &> /dev/null + done + + echo ' done.' + echo 'Please open a new shell to get the restored changes.' +} +# Reads $ADORDIR/revert-info and restores bundles' revision +antigen-revert () { + local line + if [[ -f $ADOTDIR/revert-info ]]; then + cat $ADOTDIR/revert-info | sed -n '1!p' | while read line; do + local dir="$(echo "$line" | cut -d: -f1)" + git --git-dir="$dir/.git" --work-tree="$dir" \ + checkout "$(echo "$line" | cut -d: -f2)" 2> /dev/null + done + + echo "Reverted to state before running -update on $( + cat $ADOTDIR/revert-info | sed -n '1p')." + + else + echo 'No revert information available. Cannot revert.' >&2 + return 1 + fi +} +# Update (with `git pull`) antigen itself. +# TODO: Once update is finished, show a summary of the new commits, as a kind of +# "what's new" message. +antigen-selfupdate () { + (\cd -q $_ANTIGEN_INSTALL_DIR + if [[ ! ( -d .git || -f .git ) ]]; then + echo "Your copy of antigen doesn't appear to be a git clone. " \ + "The 'selfupdate' command cannot work in this case." + return 1 + fi + local head="$(git rev-parse --abbrev-ref HEAD)" + if [[ $head == "HEAD" ]]; then + # If current head is detached HEAD, checkout to master branch. + git checkout master + fi + git pull + + # TODO Should be transparently hooked by zcache + antigen-reset &>> /dev/null + ) +} +antigen-snapshot () { + local snapshot_file="${1:-antigen-shapshot}" + local urls url dir version_hash snapshot_content + local -a bundles + + # The snapshot content lines are pairs of repo-url and git version hash, in + # the form: + # + urls=$(-antigen-echo-record | awk '$4 == "true" {print $1}' | sort -u) + for url in ${(f)urls}; do + dir="$(-antigen-get-clone-dir "$url")" + version_hash="$(\cd -q "$dir" && git rev-parse HEAD)" + bundles+=("$version_hash $url"); + done + snapshot_content=${(j:\n:)bundles} + + { + # The first line in the snapshot file is for metadata, in the form: + # key='value'; key='value'; key='value'; + # Where `key`s are valid shell variable names. + + # Snapshot version. Has no relation to antigen version. If the snapshot + # file format changes, this number can be incremented. + echo -n "version='1';" + + # Snapshot creation date+time. + echo -n " created_on='$(date)';" + + # Add a checksum with the md5 checksum of all the snapshot lines. + chksum() { (md5sum; test $? = 127 && md5) 2>/dev/null | cut -d' ' -f1 } + local checksum="$(echo "$snapshot_content" | chksum)" + unset -f chksum; + echo -n " checksum='${checksum%% *}';" + + # A newline after the metadata and then the snapshot lines. + echo "\n$snapshot_content" + + } > "$snapshot_file" +} +# Loads a given theme. +# +# Shares the same syntax as antigen-bundle command. +# +# Usage +# antigen-theme zsh/theme[.zsh-theme] +# +# Returns +# 0 if everything was succesfully +antigen-theme () { + local name=$1 result=0 record + local match mbegin mend MATCH MBEGIN MEND + + if [[ -z "$1" ]]; then + printf "Antigen: Must provide a theme url or name.\n" >&2 + return 1 + fi + + -antigen-theme-reset-hooks + + record=$(-antigen-find-record "theme") + if [[ "$1" != */* && "$1" != --* ]]; then + # The first argument is just a name of the plugin, to be picked up from + # the default repo. + antigen-bundle --loc=themes/$name --btype=theme + + else + antigen-bundle "$@" --btype=theme + + fi + result=$? + + # Remove a theme from the record if the following conditions apply: + # - there was no error in bundling the given theme + # - there is a theme registered + # - registered theme is not the same as the current one + if [[ $result == 0 && -n $record ]]; then + # http://zsh-workers.zsh.narkive.com/QwfCWpW8/what-s-wrong-with-this-expression + if [[ "$record" =~ "$@" ]]; then + return $result + else + _ANTIGEN_BUNDLE_RECORD[$_ANTIGEN_BUNDLE_RECORD[(I)$record]]=() + fi + fi + + return $result +} + +-antigen-theme-reset-hooks () { + # This is only needed on interactive mode + autoload -U add-zsh-hook is-at-least + local hook + + # Clear out prompts + PROMPT="" + if [[ -n $RPROMPT ]]; then + RPROMPT="" + fi + + for hook in chpwd precmd preexec periodic; do + add-zsh-hook -D "${hook}" "prompt_*" + # common in omz themes + add-zsh-hook -D "${hook}" "*_${hook}" + add-zsh-hook -d "${hook}" "vcs_info" + done +} +# Updates the bundles or a single bundle. +# +# Usage +# antigen-update [example/bundle] +# +# Returns +# Nothing. Performs a `git pull`. +antigen-update () { + local bundle=$1 url + + # Clear log + :> $ANTIGEN_LOG + + # Update revert-info data + -antigen-revert-info + + # If no argument is given we update all bundles + if [[ $# -eq 0 ]]; then + # Here we're ignoring all non cloned bundles (ie, --no-local-clone) + -antigen-get-cloned-bundles | while read url; do + -antigen-update-bundle $url + done + # TODO next minor version + # antigen-reset + else + if -antigen-update-bundle $bundle; then + # TODO next minor version + # antigen-reset + else + return $? + fi + fi +} + +# Updates a bundle performing a `git pull`. +# +# Usage +# -antigen-update-bundle example/bundle +# +# Returns +# Nothing. Performs a `git pull`. +-antigen-update-bundle () { + local bundle="$1" + local record="" + local url="" + local make_local_clone="" + local start=$(date +'%s') + + if [[ $# -eq 0 ]]; then + printf "Antigen: Missing argument.\n" >&2 + return 1 + fi + + record=$(-antigen-find-record $bundle) + if [[ ! -n "$record" ]]; then + printf "Bundle not found in record. Try 'antigen bundle %s' first.\n" $bundle >&2 + return 1 + fi + + url="$(echo "$record" | cut -d' ' -f1)" + make_local_clone=$(echo "$record" | cut -d' ' -f4) + + local branch="master" + if [[ $url == *\|* ]]; then + branch="$(-antigen-parse-branch ${url%|*} ${url#*|})" + fi + + printf "Updating %s... " $(-antigen-bundle-short-name "$url" "$branch") + + if [[ $make_local_clone == "false" ]]; then + printf "Bundle has no local clone. Will not be updated.\n" >&2 + return 1 + fi + + # update=true verbose=false + if ! -antigen-ensure-repo "$url" true false; then + printf "Error! Activate logging and try again.\n" >&2 + return 1 + fi + + local took=$(( $(date +'%s') - $start )) + printf "Done. Took %ds.\n" $took +} +antigen-use () { + if [[ $1 == oh-my-zsh ]]; then + -antigen-use-oh-my-zsh + elif [[ $1 == prezto ]]; then + -antigen-use-prezto + elif [[ $1 != "" ]]; then + ANTIGEN_DEFAULT_REPO_URL=$1 + antigen-bundle $@ + else + echo 'Usage: antigen-use ' >&2 + echo 'Where is any one of the following:' >&2 + echo ' * oh-my-zsh' >&2 + echo ' * prezto' >&2 + echo ' is the full url.' >&2 + return 1 + fi +} +antigen-version () { + local version="v2.2.2" + local extensions revision="" + if [[ -d $_ANTIGEN_INSTALL_DIR/.git ]]; then + revision=" ($(git --git-dir=$_ANTIGEN_INSTALL_DIR/.git rev-parse --short '@'))" + fi + + printf "Antigen %s%s\n" $version $revision + if (( $+functions[antigen-ext] )); then + typeset -a extensions; extensions=($(antigen-ext-list)) + if [[ $#extensions -gt 0 ]]; then + printf "Extensions loaded: %s\n" ${(j:, :)extensions} + fi + fi +} +typeset -Ag _ANTIGEN_HOOKS; _ANTIGEN_HOOKS=() +typeset -Ag _ANTIGEN_HOOKS_META; _ANTIGEN_HOOKS_META=() +typeset -g _ANTIGEN_HOOK_PREFIX="-antigen-hook-" +typeset -g _ANTIGEN_EXTENSIONS; _ANTIGEN_EXTENSIONS=() + +# -antigen-add-hook antigen-apply antigen-apply-hook replace +# - Replaces hooked function with hook, do not call hooked function +# - Return -1 to stop calling further hooks +# -antigen-add-hook antigen-apply antigen-apply-hook pre (pre-call) +# - By default it will call hooked function +# -antigen-add-hook antigen-pply antigen-apply-hook post (post-call) +# - Calls antigen-apply and then calls hook function +# Usage: +# -antigen-add-hook antigen-apply antigen-apply-hook ["replace"|"pre"|"post"] ["once"|"repeat"] +antigen-add-hook () { + local target="$1" hook="$2" type="$3" mode="${4:-repeat}" + + if (( ! $+functions[$target] )); then + printf "Antigen: Function %s doesn't exist.\n" $target + return 1 + fi + + if (( ! $+functions[$hook] )); then + printf "Antigen: Function %s doesn't exist.\n" $hook + return 1 + fi + + if [[ "${_ANTIGEN_HOOKS[$target]}" == "" ]]; then + _ANTIGEN_HOOKS[$target]="${hook}" + else + _ANTIGEN_HOOKS[$target]="${_ANTIGEN_HOOKS[$target]}:${hook}" + fi + + _ANTIGEN_HOOKS_META[$hook]="target $target type $type mode $mode called 0" + + # Do shadow for this function if there is none already + local hook_function="${_ANTIGEN_HOOK_PREFIX}$target" + if (( ! $+functions[$hook_function] )); then + # Preserve hooked function + eval "function ${_ANTIGEN_HOOK_PREFIX}$(functions -- $target)" + + # Create hook, call hook-handler to further process hook functions + eval "function $target () { + noglob -antigen-hook-handler $target \$@ + return \$? + }" + fi + + return 0 +} + +# Private function to handle multiple hooks in a central point. +-antigen-hook-handler () { + local target="$1" args hook called + local hooks meta + shift + typeset -a args; args=(${@}) + + typeset -a pre_hooks replace_hooks post_hooks; + typeset -a hooks; hooks=(${(s|:|)_ANTIGEN_HOOKS[$target]}) + + typeset -A meta; + for hook in $hooks; do + meta=(${(s: :)_ANTIGEN_HOOKS_META[$hook]}) + if [[ ${meta[mode]} == "once" && ${meta[called]} == 1 ]]; then + WARN "Ignoring hook due to mode ${meta[mode]}: $hook" + continue + fi + + let called=${meta[called]}+1 + meta[called]=$called + _ANTIGEN_HOOKS_META[$hook]="${(kv)meta}" + WARN "Updated meta: "${(kv)meta} + + case "${meta[type]}" in + "pre") + pre_hooks+=($hook) + ;; + "replace") + replace_hooks+=($hook) + ;; + "post") + post_hooks+=($hook) + ;; + esac + done + + WARN "Processing hooks: ${hooks}" + + for hook in $pre_hooks; do + WARN "Pre hook:" $hook $args + noglob $hook $args + [[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret + done + + # A replace hook will return inmediately + local replace_hook=0 ret=0 + for hook in $replace_hooks; do + replace_hook=1 + # Should not be needed if `antigen-remove-hook` removed unneeded hooks. + if (( $+functions[$hook] )); then + WARN "Replace hook:" $hook $args + noglob $hook $args + [[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret + fi + done + + if [[ $replace_hook == 0 ]]; then + WARN "${_ANTIGEN_HOOK_PREFIX}$target $args" + noglob ${_ANTIGEN_HOOK_PREFIX}$target $args + ret=$? + else + WARN "Replaced hooked function." + fi + + for hook in $post_hooks; do + WARN "Post hook:" $hook $args + noglob $hook $args + [[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret + done + + LOG "Return from hook ${target} with ${ret}" + + return $ret +} + +# Usage: +# -antigen-remove-hook antigen-apply-hook +antigen-remove-hook () { + local hook="$1" + typeset -A meta; meta=(${(s: :)_ANTIGEN_HOOKS_META[$hook]}) + local target="${meta[target]}" + local -a hooks; hooks=(${(s|:|)_ANTIGEN_HOOKS[$target]}) + + # Remove registered hook + if [[ $#hooks > 0 ]]; then + hooks[$hooks[(I)$hook]]=() + fi + _ANTIGEN_HOOKS[${target}]="${(j|:|)hooks}" + + if [[ $#hooks == 0 ]]; then + # Destroy base hook + eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)" + if (( $+functions[${_ANTIGEN_HOOK_PREFIX}$target] )); then + unfunction -- "${_ANTIGEN_HOOK_PREFIX}$target" + fi + fi + + unfunction -- $hook 2> /dev/null +} + +# Remove all defined hooks. +-antigen-reset-hooks () { + local target + + for target in ${(k)_ANTIGEN_HOOKS}; do + # Release all hooked functions + eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)" + unfunction -- "${_ANTIGEN_HOOK_PREFIX}$target" 2> /dev/null + done + + _ANTIGEN_HOOKS=() + _ANTIGEN_HOOKS_META=() + _ANTIGEN_EXTENSIONS=() +} + +# Initializes an extension +# Usage: +# antigen-ext ext-name +antigen-ext () { + local ext=$1 + local func="-antigen-$ext-init" + if (( $+functions[$func] && $_ANTIGEN_EXTENSIONS[(I)$ext] == 0 )); then + eval $func + local ret=$? + WARN "$func return code was $ret" + if (( $ret == 0 )); then + LOG "LOADED EXTENSION $ext" EXT + -antigen-$ext-execute && _ANTIGEN_EXTENSIONS+=($ext) + else + WARN "IGNORING EXTENSION $func" EXT + return 1 + fi + + else + printf "Antigen: No extension defined or already loaded: %s\n" $func >&2 + return 1 + fi +} + +# List installed extensions +# Usage: +# antigen ext-list +antigen-ext-list () { + echo $_ANTIGEN_EXTENSIONS +} + +# Initializes built-in extensions +# Usage: +# antigen-ext-init +antigen-ext-init () { + # Initialize extensions. unless in interactive mode. + local ext + for ext in ${(s/ /)_ANTIGEN_BUILTIN_EXTENSIONS}; do + # Check if extension is loaded before intializing it + (( $+functions[-antigen-$ext-init] )) && antigen-ext $ext + done +} +# Initialize defer lib +-antigen-defer-init () { + typeset -ga _DEFERRED_BUNDLE; _DEFERRED_BUNDLE=() + if -antigen-interactive-mode; then + return 1 + fi +} + +-antigen-defer-execute () { + # Hooks antigen-bundle in order to defer its execution. + antigen-bundle-defer () { + _DEFERRED_BUNDLE+=("${(j: :)${@}}") + return -1 # Stop right there + } + antigen-add-hook antigen-bundle antigen-bundle-defer replace + + # Hooks antigen-apply in order to release hooked functions + antigen-apply-defer () { + WARN "Defer pre-apply" DEFER PRE-APPLY + antigen-remove-hook antigen-bundle-defer + + # Process all deferred bundles. + local bundle + for bundle in ${_DEFERRED_BUNDLE[@]}; do + LOG "Processing deferred bundle: ${bundle}" DEFER + antigen-bundle $bundle + done + + unset _DEFERRED_BUNDLE + } + antigen-add-hook antigen-apply antigen-apply-defer pre once +} +# Initialize lock lib +-antigen-lock-init () { + # Default lock path. + -antigen-set-default ANTIGEN_LOCK $ADOTDIR/.lock + typeset -g _ANTIGEN_LOCK_PROCESS=false + + # Use env variable to determine if we should load this extension + -antigen-set-default ANTIGEN_MUTEX true + # Set ANTIGEN_MUTEX to false to avoid loading this extension + if [[ $ANTIGEN_MUTEX == true ]]; then + return 0; + fi + + # Do not use mutex + return 1; +} + +-antigen-lock-execute () { + # Hook antigen command in order to check/create a lock file. + # This hook is only run once then releases itself. + antigen-lock () { + LOG "antigen-lock called" + # If there is a lock set up then we won't process anything. + if [[ -f $ANTIGEN_LOCK ]]; then + # Set up flag do the message is not repeated for each antigen-* command + [[ $_ANTIGEN_LOCK_PROCESS == false ]] && printf "Antigen: Another process in running.\n" + _ANTIGEN_LOCK_PROCESS=true + # Do not further process hooks. For this hook to properly work it + # should be registered first. + return -1 + fi + + WARN "Creating antigen-lock file at $ANTIGEN_LOCK" + touch $ANTIGEN_LOCK + } + antigen-add-hook antigen antigen-lock pre once + + # Hook antigen-apply in order to release .lock file. + antigen-apply-lock () { + WARN "Freeing antigen-lock file at $ANTIGEN_LOCK" + unset _ANTIGEN_LOCK_PROCESS + rm -f $ANTIGEN_LOCK &> /dev/null + } + antigen-add-hook antigen-apply antigen-apply-lock post once +} +# Initialize parallel lib +-antigen-parallel-init () { + WARN "Init parallel extension" PARALLEL + typeset -ga _PARALLEL_BUNDLE; _PARALLEL_BUNDLE=() + if -antigen-interactive-mode; then + return 1 + fi +} + +-antigen-parallel-execute() { + WARN "Exec parallel extension" PARALLEL + # Install bundles in parallel + antigen-bundle-parallel-execute () { + WARN "Parallel antigen-bundle-parallel-execute" PARALLEL + typeset -a pids; pids=() + local args pid + + WARN "Gonna install in parallel ${#_PARALLEL_BUNDLE} bundles." PARALLEL + # Do ensure-repo in parallel + WARN "${_PARALLEL_BUNDLE}" PARALLEL + typeset -Ua repositories # Used to keep track of cloned repositories to avoid + # trying to clone it multiple times. + for args in ${_PARALLEL_BUNDLE}; do + typeset -A bundle; -antigen-parse-args 'bundle' ${=args} + + if [[ ! -d ${bundle[dir]} && $repositories[(I)${bundle[url]}] == 0 ]]; then + WARN "Install in parallel ${bundle[name]}." PARALLEL + echo "Installing ${bundle[name]}!..." + # $bundle[url]'s format is "url|branch" as to create "$ANTIGEN_BUNDLES/bundle/name-branch", + # this way you may require multiple branches from the same repository. + -antigen-ensure-repo "${bundle[url]}" > /dev/null &! + pids+=($!) + else + WARN "Bundle ${bundle[name]} already cloned locally." PARALLEL + fi + + repositories+=(${bundle[url]}) + done + + # Wait for all background processes to end + while [[ $#pids > 0 ]]; do + for pid in $pids; do + # `ps` may diplay an error message such "Signal 18 (CONT) caught by ps + # (procps-ng version 3.3.9).", see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732410 + if [[ $(ps -o pid= -p $pid 2>/dev/null) == "" ]]; then + pids[$pids[(I)$pid]]=() + fi + done + sleep .5 + done + + builtin local bundle &> /dev/null + for bundle in ${_PARALLEL_BUNDLE[@]}; do + antigen-bundle $bundle + done + + + WARN "Parallel install done" PARALLEL + } + + # Hooks antigen-apply in order to release hooked functions + antigen-apply-parallel () { + WARN "Parallel pre-apply" PARALLEL PRE-APPLY + #antigen-remove-hook antigen-pre-apply-parallel + # Hooks antigen-bundle in order to parallel its execution. + antigen-bundle-parallel () { + TRACE "antigen-bundle-parallel: $@" PARALLEL + _PARALLEL_BUNDLE+=("${(j: :)${@}}") + } + antigen-add-hook antigen-bundle antigen-bundle-parallel replace + } + antigen-add-hook antigen-apply antigen-apply-parallel pre once + + antigen-apply-parallel-execute () { + WARN "Parallel replace-apply" PARALLEL REPLACE-APPLY + antigen-remove-hook antigen-bundle-parallel + # Process all parallel bundles. + antigen-bundle-parallel-execute + + unset _PARALLEL_BUNDLE + antigen-remove-hook antigen-apply-parallel-execute + antigen-apply + } + antigen-add-hook antigen-apply antigen-apply-parallel-execute replace once +} +typeset -ga _ZCACHE_BUNDLE_SOURCE _ZCACHE_CAPTURE_BUNDLE +typeset -g _ZCACHE_CAPTURE_PREFIX + +# Generates cache from listed bundles. +# +# Iterates over _ANTIGEN_BUNDLE_RECORD and join all needed sources into one, +# if this is done through -antigen-load-list. +# Result is stored in ANTIGEN_CACHE. +# +# _ANTIGEN_BUNDLE_RECORD and fpath is stored in cache. +# +# Usage +# -zcache-generate-cache +# +# Returns +# Nothing. Generates ANTIGEN_CACHE +-antigen-cache-generate () { + local -aU _fpath _PATH _sources + local record + + LOG "Gonna generate cache for $_ZCACHE_BUNDLE_SOURCE" + for record in $_ZCACHE_BUNDLE_SOURCE; do + record=${record:A} + # LOG "Caching $record" + if [[ -f $record ]]; then + # Adding $'\n' as a suffix as j:\n: doesn't work inside a heredoc. + if [[ $_ANTIGEN_THEME_COMPAT == true && "$record" == *.zsh-theme* ]]; then + local compat="${record:A}.antigen-compat" + echo "# Generated by Antigen. Do not edit!" >! "$compat" + cat $record | sed -Ee '/\{$/,/^\}/!{ + s/^local // + }' >>! "$compat" + record="$compat" + fi + _sources+=("source '${record}';"$'\n') + elif [[ -d $record ]]; then + _PATH+=("${record}") + _fpath+=("${record}") + fi + done + +cat > $ANTIGEN_CACHE <! "$ANTIGEN_RSRC" + for rsrc in $ANTIGEN_CHECK_FILES; do + zcompile $rsrc + done + } &! + + return true +} + +# Initializes caching mechanism. +# +# Hooks `antigen-bundle` and `antigen-apply` in order to defer bundle install +# and load. All bundles are loaded from generated cache rather than dynamically +# as these are bundled. +# +# Usage +# -antigen-cache-init +# Returns +# Nothing +-antigen-cache-init () { + if -antigen-interactive-mode; then + return 1 + fi + + _ZCACHE_CAPTURE_PREFIX=${_ZCACHE_CAPTURE_PREFIX:-"--zcache-"} + _ZCACHE_BUNDLE_SOURCE=(); _ZCACHE_CAPTURE_BUNDLE=() + + # Cache auto config files to check for changes (.zshrc, .antigenrc etc) + -antigen-set-default ANTIGEN_AUTO_CONFIG true + + # Default cache path. + -antigen-set-default ANTIGEN_CACHE $ADOTDIR/init.zsh + -antigen-set-default ANTIGEN_RSRC $ADOTDIR/.resources + if [[ $ANTIGEN_CACHE == false ]]; then + return 1 + fi + + return 0 +} + +-antigen-cache-execute () { + # Main function. Deferred antigen-apply. + antigen-apply-cached () { + # TRACE "APPLYING CACHE" EXT + # Auto determine check_files + # There always should be 5 steps from original source as the correct way is to use + # `antigen` wrapper not `antigen-apply` directly and it's called by an extension. + LOG "TRACE: ${funcfiletrace}" + if [[ $ANTIGEN_AUTO_CONFIG == true && $#ANTIGEN_CHECK_FILES -eq 0 ]]; then + ANTIGEN_CHECK_FILES+=(~/.zshrc) + if [[ $#funcfiletrace -ge 6 ]]; then + ANTIGEN_CHECK_FILES+=("${${funcfiletrace[6]%:*}##* }") + fi + fi + + # Generate and compile cache + -antigen-cache-generate + [[ -f "$ANTIGEN_CACHE" ]] && source "$ANTIGEN_CACHE"; + + # Commented out in order to have a working `cache-gen` command + #unset _ZCACHE_BUNDLE_SOURCE + unset _ZCACHE_CAPTURE_BUNDLE _ZCACHE_CAPTURE_FUNCTIONS + + # Release all hooked functions + antigen-remove-hook -antigen-load-env-cached + antigen-remove-hook -antigen-load-source-cached + antigen-remove-hook antigen-bundle-cached + } + + antigen-add-hook antigen-apply antigen-apply-cached post once + + # Defer antigen-bundle. + antigen-bundle-cached () { + _ZCACHE_CAPTURE_BUNDLE+=("${(j: :)${@}}") + } + antigen-add-hook antigen-bundle antigen-bundle-cached pre + + # Defer loading. + -antigen-load-env-cached () { + local bundle + typeset -A bundle; bundle=($@) + local location=${bundle[dir]}/${bundle[loc]} + + # Load to path if there is no sourceable + if [[ ${bundle[loc]} == "/" ]]; then + _ZCACHE_BUNDLE_SOURCE+=("${location}") + return + fi + + _ZCACHE_BUNDLE_SOURCE+=("${location}") + } + antigen-add-hook -antigen-load-env -antigen-load-env-cached replace + + # Defer sourcing. + -antigen-load-source-cached () { + _ZCACHE_BUNDLE_SOURCE+=($@) + } + antigen-add-hook -antigen-load-source -antigen-load-source-cached replace + + return 0 +} + +# Generate static-cache file at $ANTIGEN_CACHE using currently loaded +# bundles from $_ANTIGEN_BUNDLE_RECORD +# +# Usage +# antigen-cache-gen +# +# Returns +# Nothing +antigen-cache-gen () { + -antigen-cache-generate +} +#compdef _antigen +# Setup antigen's autocompletion +_antigen () { + local -a _1st_arguments + _1st_arguments=( + 'apply:Load all bundle completions' + 'bundle:Install and load the given plugin' + 'bundles:Bulk define bundles' + 'cleanup:Clean up the clones of repos which are not used by any bundles currently loaded' + 'cache-gen:Generate cache' + 'init:Load Antigen configuration from file' + 'list:List out the currently loaded bundles' + 'purge:Remove a cloned bundle from filesystem' + 'reset:Clears cache' + 'restore:Restore the bundles state as specified in the snapshot' + 'revert:Revert the state of all bundles to how they were before the last antigen update' + 'selfupdate:Update antigen itself' + 'snapshot:Create a snapshot of all the active clones' + 'theme:Switch the prompt theme' + 'update:Update all bundles' + 'use:Load any (supported) zsh pre-packaged framework' + ); + + _1st_arguments+=( + 'help:Show this message' + 'version:Display Antigen version' + ) + + __bundle() { + _arguments \ + '--loc[Path to the location ]' \ + '--url[Path to the repository ]' \ + '--branch[Git branch name]' \ + '--no-local-clone[Do not create a clone]' + } + __list() { + _arguments \ + '--simple[Show only bundle name]' \ + '--short[Show only bundle name and branch]' \ + '--long[Show bundle records]' + } + + + __cleanup() { + _arguments \ + '--force[Do not ask for confirmation]' + } + + _arguments '*:: :->command' + + if (( CURRENT == 1 )); then + _describe -t commands "antigen command" _1st_arguments + return + fi + + local -a _command_args + case "$words[1]" in + bundle) + __bundle + ;; + use) + compadd "$@" "oh-my-zsh" "prezto" + ;; + cleanup) + __cleanup + ;; + (update|purge) + compadd $(type -f \-antigen-get-bundles &> /dev/null || antigen &> /dev/null; -antigen-get-bundles --simple 2> /dev/null) + ;; + theme) + compadd $(type -f \-antigen-get-themes &> /dev/null || antigen &> /dev/null; -antigen-get-themes 2> /dev/null) + ;; + list) + __list + ;; + esac +} +zmodload zsh/datetime +ANTIGEN_DEBUG_LOG=${ANTIGEN_DEBUG_LOG:-${ADOTDIR:-$HOME/.antigen}/debug.log} +LOG () { + local PREFIX="[LOG][${EPOCHREALTIME}]" + echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG +} + +ERR () { + local PREFIX="[ERR][${EPOCHREALTIME}]" + echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG +} + +WARN () { + local PREFIX="[WRN][${EPOCHREALTIME}]" + echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG +} + +TRACE () { + local PREFIX="[TRA][${EPOCHREALTIME}]" + echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@\n${PREFIX} ${(j:\n:)funcstack}" >> $ANTIGEN_DEBUG_LOG +} +-antigen-env-setup diff --git a/dotfiles/.local/fzf.zsh b/dotfiles/.local/fzf.zsh new file mode 100644 index 00000000..bcae1b95 --- /dev/null +++ b/dotfiles/.local/fzf.zsh @@ -0,0 +1,13 @@ +# Setup fzf +# --------- +if [[ ! "$PATH" == */usr/local/opt/fzf/bin* ]]; then + export PATH="${PATH:+${PATH}:}/usr/local/opt/fzf/bin" +fi + +# Auto-completion +# --------------- +[[ $- == *i* ]] && source "/usr/local/opt/fzf/shell/completion.zsh" 2> /dev/null + +# Key bindings +# ------------ +source "/usr/local/opt/fzf/shell/key-bindings.zsh" diff --git a/dotfiles/.local/p10k.zsh b/dotfiles/.local/p10k.zsh new file mode 100644 index 00000000..deebda01 --- /dev/null +++ b/dotfiles/.local/p10k.zsh @@ -0,0 +1,1645 @@ +# Generated by Powerlevel10k configuration wizard on 2022-08-29 at 20:49 EDT. +# Based on romkatv/powerlevel10k/config/p10k-classic.zsh, checksum 62739. +# Wizard options: compatible, classic, unicode, darkest, 24h time, flat heads, +# flat tails, 1 line, compact, concise, transient_prompt, instant_prompt=verbose. +# Type `p10k configure` to generate another config. +# +# 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. + autoload -Uz is-at-least && is-at-least 5.1 || return + + # The list of segments shown on the left. Fill it with the most important segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + # os_icon # os identifier + dir # current directory + vcs # git status + # 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=( + 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/) + time # current time + 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=compatible + # 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=false + + # 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='%238F╭─' + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX='%238F├─' + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='%238F╰─' + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX='%238F─╮' + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX='%238F─┤' + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX='%238F─╯' + + # 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=238 + # 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=234 + + # Separator between same-color segments on the left. + typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='%242F\u2502' + # Separator between same-color segments on the right. + typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='%242F\u2502' + # Separator between different-color segments on the left. + typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='' + # Separator between different-color segments on the right. + typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='' + # The right end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' + # The left end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='' + # 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 ":" where 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='%244Fin ' + + #####################################[ 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='%244F' # 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='%244Fon ' + + # 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='%244Ftook ' + + #######################[ 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='nord' + + #################[ 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='⭐' + + ##################################[ 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='%244Fwith ' + + ###[ 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='%244Fat ' + + #[ 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='eb' + + ##########[ 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='az' + + ##########[ 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='%244Fin ' + + ###############################[ 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='%244Fat ' + + # 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=always + + # 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/dotfiles/.local/share/qt5ct/colors/flat-remix-dark.conf b/dotfiles/.local/share/qt5ct/colors/flat-remix-dark.conf new file mode 100644 index 00000000..5217202a --- /dev/null +++ b/dotfiles/.local/share/qt5ct/colors/flat-remix-dark.conf @@ -0,0 +1,4 @@ +[ColorScheme] +active_colors=#ffffffff, #ff1c2029, #ff3c4150, #ff21242d, #ff050609, #ff15171e, #ffffffff, #ffffffff, #ffffffff, #ff272a34, #ff23252e, #ffe7e4e0, #ff2777ff, #fff9f9f9, #ff2777ff, #ff2777ff, #ff21242d, #ffffffff, #ff23252e, #ffffffff, #80ffffff +disabled_colors=#ff808080, #ff1c2029, #ff3c4150, #ff21242d, #ff050609, #ff15171e, #ff808080, #ffffffff, #ff808080, #ff272a34, #ff23252e, #ffe7e4e0, #ff2777ff, #ff808080, #ff2777ff, #ff2777ff, #ff21242d, #ffffffff, #ff23252e, #ffffffff, #80ffffff +inactive_colors=#ffffffff, #ff1c2029, #ff3c4150, #ff21242d, #ff050609, #ff15171e, #ffffffff, #ffffffff, #ffffffff, #ff272a34, #ff23252e, #ffe7e4e0, #ff2777ff, #fff9f9f9, #ff2777ff, #ff2777ff, #ff21242d, #ffffffff, #ff23252e, #ffffffff, #80ffffff \ No newline at end of file diff --git a/dotfiles/.local/share/qt5ct/colors/flat-remix-light.conf b/dotfiles/.local/share/qt5ct/colors/flat-remix-light.conf new file mode 100644 index 00000000..6d4fe6c2 --- /dev/null +++ b/dotfiles/.local/share/qt5ct/colors/flat-remix-light.conf @@ -0,0 +1,4 @@ +[ColorScheme] +active_colors=#ff000000, #ffffffff, #ffffffff, #ffffffff, #ffffffff, #ffffffff, #ff000000, #ff0a0a0a, #ff0a0a0a, #fffafafa, #ffffffff, #ffe7e4e0, #ff2777ff, #ffffffff, #ff2777ff, #ff2777ff, #fffafafa, #ffffffff, #ffffffff, #ff050505, #80000000 +disabled_colors=#ff808080, #ffffffff, #ffffffff, #ffffffff, #ffffffff, #ffffffff, #ff808080, #ff0a0a0a, #ff808080, #fffafafa, #ffffffff, #ffe7e4e0, #ff2777ff, #ff808080, #ff2777ff, #ff2777ff, #fffafafa, #ffffffff, #ffffffff, #ff050505, #80000000 +inactive_colors=#ff000000, #ffffffff, #ffffffff, #ffffffff, #ffffffff, #ffffffff, #ff000000, #ff0a0a0a, #ff0a0a0a, #fffafafa, #ffffffff, #ffe7e4e0, #ff2777ff, #ffffffff, #ff2777ff, #ff2777ff, #fffafafa, #ffffffff, #ffffffff, #ff050505, #80000000 \ No newline at end of file diff --git a/dotfiles/.local/share/qt5ct/qss/fusion-simple-scrollbar.qss b/dotfiles/.local/share/qt5ct/qss/fusion-simple-scrollbar.qss new file mode 100644 index 00000000..62972783 --- /dev/null +++ b/dotfiles/.local/share/qt5ct/qss/fusion-simple-scrollbar.qss @@ -0,0 +1,29 @@ +QScrollBar { background: transparent; } + +QScrollBar:vertical { max-width: 8px; } +QScrollBar:horizontal { max-height: 8px; } + +QScrollBar::handle { + padding: 0; + margin: 2px; + border-radius: 2px; + border: 0; + background: rgba(127, 127, 127, .5); + min-height: 20px; + min-width: 20px; +} +QScrollBar::handle:hover { background: rgba(127, 127, 127, 1); } +QScrollBar::handle:pressed { background: palette(highlight); } + +QScrollBar::add-line , QScrollBar::sub-line { + height: 0; + border: 0; +} + +QScrollBar::up-arrow, QScrollBar::down-arrow { + border: 0; + width: 0; + height: 0; +} + +QScrollBar::add-page, QScrollBar::sub-page { background: none; } \ No newline at end of file diff --git a/dotfiles/.profile b/dotfiles/.profile index 66c118b8..6e8a4651 100644 --- a/dotfiles/.profile +++ b/dotfiles/.profile @@ -1,7 +1,309 @@ -# Add items to PATH +# Easy file sharing from the command line, using transfer.sh +transfer() { + if [ $# -eq 0 ]; then + echo -e "No arguments specified.\nUsage:\n transfer \n ... | transfer ">&2; + return 1; + fi; + if tty -s;then + file="$1"; + file_name=$(basename "$file"); + if [ ! -e "$file" ];then + echo "$file: No such file or directory">&2; + return 1; + fi; + if [ -d "$file" ];then + file_name="$file_name.zip" ,; + (cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null,; + else + cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null; + fi; + else + file_name=$1; + curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null; + fi; +} + +# Install WebDriverAgent on iOS device +appiumwebdriver() { + read -p "Enter the UDID of the device you wish to install WebDriverAgent on: " UDID_INPUT + mkdir -p Resources/WebDriverAgent.bundle + bash ./Scripts/bootstrap.sh -d + cd /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent + xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=${UDID_INPUT}' test +} + +# Change directories and view contents at the same time +cl() { + DIR="$*"; + # if no DIR given, go home + if [ $# -lt 1 ]; then + DIR=$HOME; + fi; + builtin cd "${DIR}" && \ + # use your preferred ls command + ls -F --color=auto +} + +# Open bash with local Docker file +dockerssh() { + if [ -z "$1" ]; then + echo "Supply a Docker container name in order for this command to work." + echo "Usage: dockerssh " + else + docker exec -it $1 /bin/bash + fi +} + +# Checks status of a website on downforeveryoneorjustme.com +down4me() { + curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g'; +} + +# GAM - a command-line tool for Google Workspace. This alias will run gam or install gam if it is not already installed. +gam() { + if type gam &> /dev/null; then + gam "$@" + else + bash <(curl -s -S -L https://git.io/install-gam) + fi +} + +# Opens current repository in browser +gitopen() { + git remote -v | head -n 1 | awk -F "@" '{print $2}' | awk -F " " '{print $1}' | sed 's/:/\//g' | sed 's/.git//g' | awk '{print "http://"$1}' | xargs open +} + +# Open Mac OS X desktop on a Linux machine +macosx() { + docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:big-sur +} + +# Used to provision machines using Ansible +provision () { + if [ -z "$1" ]; then + # Display usage if no parameters are given + echo "Usage: provision " + echo "If an inventory name of 'test' is provided then the inventory should exist in inventories/test.yml" + return 1 + else + cd ~/Playbooks + ansible-galaxy install -r requirements.yml + if [ -z "$2" ]; then + ansible-playbook --ask-vault-pass -i inventories/"$1".yml main.yml + else + ansible-playbook --ask-vault-pass -i inventories/"$1".yml "$2".yml + fi + fi +} + +# Generate a random string of X length +randomstring() { + if [ -z "$1" ]; then + head /dev/urandom | tr -dc A-Za-z0-9 | head -c $1 ; echo '' + else + echo "Pass the number of characters you would like the string to be. Example: randomstring 14" + fi +} + +# Launch rclone admin GUI +rclone-gui() { + rclone rcd --rc-web-gui --rc-user=admin --rc-pass=pass --rc-serve +} + +# Reset Docker to factory settings +resetdocker() { + set +e + CONTAINER_COUNT=$(docker ps -a -q | wc -l) + if [ "$CONTAINER_COUNT" -gt 0 ]; then + docker stop $(docker ps -a -q) + docker rm $(docker ps -a -q) + fi + VOLUME_COUNT=$(docker volume ls -q | wc -l) + if [ "$VOLUME_COUNT" -gt 0 ]; then + docker volume rm $(docker volume ls -q) + fi + NETWORK_COUNT=$(docker network ls -q | wc -l) + if [ "$NETWORK_COUNT" -gt 0 ]; then + docker network rm $(docker network ls -q) + fi + docker system prune -a --force +} + +# Source: https://itnext.io/bash-aliases-are-awesome-8a76aecc96ab +# Type ".. 5" to cd .. 5 times +..() { + N=$(($1)) + if [ $N -lt 1 ]; then + N=1 + fi + while ((N)); do + cd .. + let N-=1 + done; +} + +### Aliases + +# Create an Authelia password hash +alias autheliapassword='docker run authelia/authelia:latest authelia hash-password' + +# Shows IP addresses that are currently banned by fail2ban +alias banned='sudo zgrep "Ban" /var/log/fail2ban.log*' + +# Removes all Ansible roles saved in ~/.ansible +alias clearroles='rm -rf ~/.ansible/roles/*' + +alias connections='nm-connection-editor' + +# Make copy command verbose +alias cp='cp -v' + +# Copies with a progress bar +alias cpv='rsync -ah --info=progress2' + +# Reload docker-compose.yml +alias docker-reboot='docker-compose stop && docker-compose up -d' + +# Download a file +alias download='curl --continue-at - --location --progress-bar --remote-name --remote-time' + +# Download a website +alias downloadsite='wget --mirror -p --convert-links -P' + +# Flush DNS +alias flushdns='sudo systemd-resolve --flush-caches && sudo systemd-resolve --statistics' + +# Get the possible GRUB resolutions +alias grubresolutions='sudo hwinfo --framebuffer' + +# Execute git command with sudo priviledges while retaining .gitconfig +alias gsudo='sudo git -c "include.path="${XDG_CONFIG_DIR:-$HOME/.config}/git/config\" -c \"include.path=$HOME/.gitconfig\"' + +# Create hashed password for Ansible user creation +alias hashpassword='mkpasswd --method=sha-512' + +# Show full output when using ls +alias ls='ls -AlhF --color=auto' + +# Create parent directories automatically +alias mkdir='mkdir -pv' + +# Make mount command output readable +alias mount='mount | column -t' + +# Make mv command verbose +alias mv='mv -v' + +# Show IP address +alias myip='curl http://ipecho.net/plain; echo' + +# Shows local IP addresses +alias mylocalip="ifconfig | grep -Eo 'inet (addr:|adr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'" + +# Show open ports +alias ports='sudo netstat -tulanp' + +# Shuts down the computer, skipping the shutdown scripts +alias poweroff='sudo /sbin/poweroff' + +# Open the Rclone web GUI +alias rclonegui='rclone rcd --rc-web-gui' + +# Reboot the computer +alias reboot='sudo /sbin/reboot' + +# Make rm command verbose +alias rm='rm -vi' + +# Launch the Python Simple HTTP Server +alias serve='python -m SimpleHTTPServer' + +# Generate a SHA1 digest +alias sha1='openssl sha1' + +# Shutdown the computer +alias shutdown='sudo /sbin/shutdown' + +# Speed test +alias speedtest='wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip' + +# Shortcut for config file +alias sshconfig='${EDITOR:code} ~/.ssh/config' + +# Pastebin +alias sprunge='curl -F "sprunge=<-" http://sprunge.us' + +# Alias for sudo vim +alias svim='sudo vim' + +# Disable Tor for current shell +alias toroff='source torsocks off' + +# Enable Tor for current shell +alias toron='source torsocks on' + +# Test Tor connection +alias tortest='curl --socks5-hostname 127.0.0.1:9050 --silent https://check.torproject.org/ | head -25' + +# Unban IP address (e.g. unban 10.14.24.14) +alias unban='sudo fail2ban-client set sshd unbanip' + +# Recursively encrypts files using Ansible Vault +alias unvaultdir='find . -type f -printf "%h/\"%f\" " | xargs ansible-vault decrypt' + +# Alias for updating software +alias update='sudo apt-get update && sudo apt-get upgrade' + +# Sets v as an alias for vim +alias v='vim' + +# Recursively encrypts files using Ansible Vault +alias vaultdir='find . -type f -printf "%h/\"%f\" " | xargs ansible-vault encrypt' + +# Shows nice looking report of weather +alias weather='curl -A curl wttr.in' + +# Change .wget-hsts file location +alias wget="wget --hsts-file ~/.config/.wget-hsts" + +### .local/bin export PATH="$PATH:$HOME/.local/bin" +### Cargo +. "$HOME/.cargo/env" + +if type brew &> /dev/null; then + ### Go + export GOPATH="${HOME}/.local/go" + export GOROOT="$(brew --prefix golang)/libexec" + export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin" + + ### ASDF + . $(brew --prefix asdf)/libexec/asdf.sh +fi + +### Android Studio +export PATH="$PATH:~/Library/Android/sdk/cmdline-tools/latest/bin" +export PATH="$PATH:~/Library/Android/sdk/platform-tools" +export PATH="$PATH:~/Library/Android/sdk/tools/bin" +export PATH="$PATH:~/Library/Android/sdk/tools" + +### gitfuzzy +export PATH="/usr/local/src/gitfuzzy/bin:$PATH" + +### Poetry +export PATH="$HOME/.poetry/bin:$PATH" + +### Volta +export VOLTA_HOME="$HOME/.volta" +export PATH="$VOLTA_HOME/bin:$PATH" + +### SDKMan +export SDKMAN_DIR="$HOME/.local/sdkman" +[[ -s "$HOME/.local/sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.local/sdkman/bin/sdkman-init.sh" + # Running this will update GPG to point to the current YubiKey alias yubikey-gpg-stub='gpg-connect-agent "scd serialno" "learn --force" /bye' +### Vagrant export VAGRANT_HOME="$HOME/.local/vagrant.d" diff --git a/dotfiles/.zshrc b/dotfiles/.zshrc index e69de29b..3c62a272 100644 --- a/dotfiles/.zshrc +++ b/dotfiles/.zshrc @@ -0,0 +1,381 @@ +### Powerline +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 + +### Fig +[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && . "$HOME/.fig/shell/zshrc.pre.zsh" + +### ~/.profile +[[ -f "$HOME/.profile" ]] && . "$HOME/.profile" + +# Configure color-scheme +COLOR_SCHEME=dark # dark/light + +### Aliases +alias cp='cp -v' +alias rm='rm -I' +alias mv='mv -iv' +alias ln='ln -sriv' +alias xclip='xclip -selection c' +command -v vim > /dev/null && alias vi='vim' + +### Colorize +alias ls='ls --color=auto' +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' +alias diff='diff --color=auto' +alias ip='ip --color=auto' +alias pacman='pacman --color=auto' + +### LS & TREE +alias ll='ls -la' +alias la='ls -A' +alias l='ls -F' +command -v lsd > /dev/null && alias ls='lsd --group-dirs first' && \ + alias tree='lsd --tree' +command -v colorls > /dev/null && alias ls='colorls --sd --gs' && \ + alias tree='colorls --tree' + +### CAT & LESS +command -v bat > /dev/null && \ + alias bat='bat --theme=ansi' && \ + alias cat='bat --pager=never' && \ + alias less='bat' +# in debian the command is batcat +command -v batcat > /dev/null && \ + alias batcat='batcat --theme=ansi' && \ + alias cat='batcat --pager=never' && \ + alias less='batcat' + +### TOP +command -v htop > /dev/null && alias top='htop' +command -v gotop > /dev/null && alias top='gotop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' +command -v ytop > /dev/null && alias top='ytop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' +command -v btm > /dev/null && alias top='btm $([ "$COLOR_SCHEME" = "light" ] && echo "--color default-light")' +# themes for light/dark color-schemes inside ~/.config/bashtop; Press ESC to open the menu and change the theme +command -v bashtop > /dev/null && alias top='bashtop' +command -v bpytop > /dev/null && alias top='bpytop' + +# --------------------------------- SETTINGS ---------------------------------- +setopt AUTO_CD +setopt BEEP +#setopt CORRECT +setopt HIST_BEEP +setopt HIST_EXPIRE_DUPS_FIRST +setopt HIST_FIND_NO_DUPS +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_IGNORE_DUPS +setopt HIST_REDUCE_BLANKS +setopt HIST_SAVE_NO_DUPS +setopt HIST_VERIFY +setopt INC_APPEND_HISTORY +setopt INTERACTIVE_COMMENTS +setopt MAGIC_EQUAL_SUBST +setopt NO_NO_MATCH +setopt NOTIFY +setopt NUMERIC_GLOB_SORT +setopt PROMPT_SUBST +setopt SHARE_HISTORY + +HISTFILE=~/.zsh_history +HIST_STAMPS=mm/dd/yyyy +HISTSIZE=5000 +SAVEHIST=5000 +ZLE_RPROMPT_INDENT=0 +WORDCHARS=${WORDCHARS//\/} +PROMPT_EOL_MARK= +TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S\ncpu\t%P' + + +# ZSH completion system +autoload -Uz compinit +compinit -d ~/.cache/zcompdump +zstyle ':completion:*:*:*:*:*' menu select +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' +zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" +zstyle ':completion:*' auto-description 'specify: %d' +zstyle ':completion:*' completer _expand _complete +zstyle ':completion:*' format 'Completing %d' +zstyle ':completion:*' group-name '' +zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s +zstyle ':completion:*' rehash true +zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s +zstyle ':completion:*' use-compctl false +zstyle ':completion:*' verbose true +zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' + +# Key bindings +bindkey -e +bindkey '^U' backward-kill-line +bindkey '^[[2~' overwrite-mode +bindkey '^[[3~' delete-char +bindkey '^[[H' beginning-of-line +bindkey '^[[1~' beginning-of-line +bindkey '^[[F' end-of-line +bindkey '^[[4~' end-of-line +bindkey '^[[1;5C' forward-word +bindkey '^[[1;5D' backward-word +bindkey '^[[3;5~' kill-word +bindkey '^[[5~' beginning-of-buffer-or-history +bindkey '^[[6~' end-of-buffer-or-history +bindkey '^[[Z' undo +bindkey ' ' magic-space + +# Prompt +PROMPT=$'%F{%(#.blue.green)}┌──(%B%F{%(#.red.blue)}%n@%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} ' +RPROMPT=$'%(?.. %? %F{red}%Bx%b%F{reset})%(1j. %j %F{yellow}%Bbg %b%F{reset}.)' + +# ----------------------------------- MISC ----------------------------------- +export VISUAL=vim +export EDITOR=$VISUAL + +# enable terminal linewrap +setterm -linewrap on 2> /dev/null + +# colorize man pages +export LESS_TERMCAP_mb=$'\e[1;32m' +export LESS_TERMCAP_md=$'\e[1;32m' +export LESS_TERMCAP_me=$'\e[0m' +export LESS_TERMCAP_se=$'\e[0m' +export LESS_TERMCAP_so=$'\e[01;33m' +export LESS_TERMCAP_ue=$'\e[0m' +export LESS_TERMCAP_us=$'\e[1;4;31m' +export LESSHISTFILE=- + +# colorize ls +[ -x /usr/bin/dircolors ] && eval "$(dircolors -b)" + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty) + precmd() { print -Pnr -- $'\e]0;%n@%m: %~\a' } + ;; +esac + +# ------------------------------- ZSH PLUGINS --------------------------------- +# Plugin source helper +_source_plugin() { + local plugin_name="$1" + for basedir in /usr/share/zsh/plugins /usr/share + do + plugin="$basedir/$plugin_name/$plugin_name.zsh" + [ -f "$plugin" ] && source "$plugin" && return 0 + done + echo "\033[33m[ ! ]\033[0m ZSH ${plugin_name#zsh-} not installed" + return 1 +} + +# ZSH Autosuggestions +_source_plugin zsh-autosuggestions && ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999' + +# ZSH Syntax Highlighting +if _source_plugin zsh-syntax-highlighting +then + ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern) + ZSH_HIGHLIGHT_STYLES[default]=none + ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=white,underline + ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan,bold + ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline + ZSH_HIGHLIGHT_STYLES[global-alias]=fg=green,bold + ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline + ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=green,underline + ZSH_HIGHLIGHT_STYLES[path]=bold + ZSH_HIGHLIGHT_STYLES[path_pathseparator]= + ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]= + ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[command-substitution]=none + ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[process-substitution]=none + ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=green + ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=green + ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none + ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow + ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow + ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow + ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=magenta + ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[assign]=none + ZSH_HIGHLIGHT_STYLES[redirection]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold + ZSH_HIGHLIGHT_STYLES[named-fd]=none + ZSH_HIGHLIGHT_STYLES[numeric-fd]=none + ZSH_HIGHLIGHT_STYLES[arg0]=fg=cyan + ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold + ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout +fi + +unset -f _source_plugin + +# POWERLEVEL +if ! [[ $(tty) = /dev/tty* ]] +then + if source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme 2> /dev/null + then + s=' ' # fix too wide icons + POWERLEVEL9K_MODE=nerdfont-complete + POWERLEVEL9K_SHORTEN_STRATEGY=truncate_beginning + POWERLEVEL9K_PROMPT_ADD_NEWLINE=true + POWERLEVEL9K_PROMPT_ON_NEWLINE=true + POWERLEVEL9K_RPROMPT_ON_NEWLINE=true + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='${P9K_CONTENT} $(whoami | grep -v "^root\$")' + POWERLEVEL9K_OS_ICON_BACKGROUND=red + POWERLEVEL9K_OS_ICON_FOREGROUND=white + POWERLEVEL9K_ROOT_INDICATOR_BACKGROUND=black + POWERLEVEL9K_ROOT_INDICATOR_FOREGROUND=red + POWERLEVEL9K_SSH_BACKGROUND=white + POWERLEVEL9K_SSH_FOREGROUND=blue + POWERLEVEL9K_FOLDER_ICON= + POWERLEVEL9K_DIR_BACKGROUND=blue + POWERLEVEL9K_DIR_FOREGROUND=black + POWERLEVEL9K_DIR_WRITABLE_BACKGROUND=black + POWERLEVEL9K_DIR_WRITABLE_FOREGROUND=red + POWERLEVEL9K_VCS_CLEAN_FOREGROUND=black + POWERLEVEL9K_VCS_CLEAN_BACKGROUND=green + POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=black + POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=yellow + POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=white + POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=black + POWERLEVEL9K_VCS_UNTRACKED_ICON=● + POWERLEVEL9K_VCS_UNSTAGED_ICON=± + POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON=↓ + POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON=↑ + POWERLEVEL9K_VCS_COMMIT_ICON=$s + POWERLEVEL9K_STATUS_VERBOSE=false + POWERLEVEL9K_STATUS_VERBOSE=false + POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE=true + POWERLEVEL9K_EXECUTION_TIME_ICON=$s + POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 + POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND=black + POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=blue + POWERLEVEL9K_COMMAND_BACKGROUND_JOBS_BACKGROUND=black + POWERLEVEL9K_COMMAND_BACKGROUND_JOBS_FOREGROUND=cyan + POWERLEVEL9K_TIME_ICON= + POWERLEVEL9K_TIME_FORMAT='%D{%I:%M}' + POWERLEVEL9K_TIME_BACKGROUND=black + POWERLEVEL9K_TIME_FOREGROUND=white + POWERLEVEL9K_RAM_ICON= + POWERLEVEL9K_RAM_FOREGROUND=black + POWERLEVEL9K_RAM_BACKGROUND=yellow + POWERLEVEL9K_VI_MODE_FOREGROUND=black + POWERLEVEL9K_VI_COMMAND_MODE_STRING=NORMAL + POWERLEVEL9K_VI_MODE_NORMAL_BACKGROUND=green + POWERLEVEL9K_VI_VISUAL_MODE_STRING=VISUAL + POWERLEVEL9K_VI_MODE_VISUAL_BACKGROUND=blue + POWERLEVEL9K_VI_OVERWRITE_MODE_STRING=OVERTYPE + POWERLEVEL9K_VI_MODE_OVERWRITE_BACKGROUND=red + POWERLEVEL9K_VI_INSERT_MODE_STRING= + POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL='\uE0B2' + POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0B0' + POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='%F{blue}╭─' + POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='%F{blue}╰%f ' + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon root_indicator ssh dir dir_writable vcs) + POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(vi_mode status command_execution_time background_jobs time ram) + unset s + else + echo '\033[33m[ ! ]\033[0m ZSH powerlevel10k not installed' + fi +else + clear + echo + echo +fi + + +switch_powerlevel_multiline_prompt(){ + [ $POWERLEVEL9K_PROMPT_ON_NEWLINE = true ] \ + && POWERLEVEL9K_PROMPT_ON_NEWLINE=false \ + || POWERLEVEL9K_PROMPT_ON_NEWLINE=true + + zle && zle accept-line +} +zle -N switch_powerlevel_multiline_prompt +bindkey ^P switch_powerlevel_multiline_prompt + + +# -------------------------------- FUNCTIONS --------------------------------- +glog() { + setterm -linewrap off 2> /dev/null + + git --no-pager log --all --color=always --graph --abbrev-commit --decorate --date-order \ + --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' "$@" \ + | sed -E \ + -e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+ /├\1─╮\2/' \ + -e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m /\1├─╯\x1b\[m/' \ + -e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+/├\1╮\2/' \ + -e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m/\1├╯\x1b\[m/' \ + -e 's/╮(\x1b\[[0-9;]*m)+\\/╮\1╰╮/' \ + -e 's/╯(\x1b\[[0-9;]*m)+\//╯\1╭╯/' \ + -e 's/(\||\\)\x1b\[m (\x1b\[[0-9;]*m)/╰╮\2/' \ + -e 's/(\x1b\[[0-9;]*m)\\/\1╮/g' \ + -e 's/(\x1b\[[0-9;]*m)\//\1╯/g' \ + -e 's/^\*|(\x1b\[m )\*/\1⎬/g' \ + -e 's/(\x1b\[[0-9;]*m)\|/\1│/g' \ + | command less -r $([ $# -eq 0 ] && echo "+/[^/]HEAD") + + setterm -linewrap on 2> /dev/null +} + +find() { + if [ $# = 1 ] + then + command find . -iname "*$@*" + else + command find "$@" + fi +} + +### Antigen +[[ ! -f ~/.local/antigen.zsh ]] || source ~/.local/antigen.zsh + +if type antigen &> /dev/null; then + antigen use oh-my-zsh + antigen bundle git + antigen bundle bundler + antigen bundle dotenv + antigen bundle macos + antigen bundle rake + antigen bundle rbenv + antigen bundle ruby + antigen bundle k + antigen bundle marlonrichert/zsh-autocomplete + antigen apply +fi + +## TODO +# source /Users/bzalewski/.config/broot/launcher/bash/br + +### fzf +[ -f ~/.local/fzf.zsh ] && source ~/.local/fzf.zsh + +### Google Cloud SDK +if type brew &> /dev/null; then + [[ ! -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc" ]] || source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc" + [[ ! -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc" ]] || source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc" +fi + +## TODO: What is this line? +fpath+=~/.zfunc + +### zoxide +# TODO: Ensure zoxide.vim is installed +type zoxide &> /dev/null && eval "$(zoxide init zsh)" + +### Fig +[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && . "$HOME/.fig/shell/zshrc.post.zsh" + +### Powerline +[[ ! -f ~/.config/p10k.zsh ]] || source ~/.p10k.zsh