diff options
author | Alexander Kiryukhin <i@neonxp.ru> | 2022-07-13 17:01:06 +0300 |
---|---|---|
committer | Alexander Kiryukhin <i@neonxp.ru> | 2024-02-02 02:27:23 +0300 |
commit | 28a673a4673b627ca5932a96ee0ddc67f9abd156 (patch) | |
tree | 21bfa88246e41efa9667191e3ca6906cd8da2b80 | |
parent | a31ceb244f8b7f0d7201fca7c5609bf6b61f98e2 (diff) |
Актуальные dotfile
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .gitmodules | 9 | ||||
-rw-r--r-- | Makefile | 50 | ||||
-rw-r--r-- | brew_inventory.md | 15 | ||||
-rw-r--r-- | git/config | 8 | ||||
-rwxr-xr-x | install.sh | 8 | ||||
-rw-r--r-- | nvim/coc-settings.json | 9 | ||||
-rw-r--r-- | nvim/init.vim | 205 | ||||
-rw-r--r-- | zsh/antigen.zsh | 2057 | ||||
-rw-r--r-- | zsh/completion.zsh | 177 | ||||
m--------- | zsh/omz | 0 | ||||
m--------- | zsh/p10k | 0 | ||||
-rw-r--r-- | zsh/p10k.zsh | 1705 | ||||
-rw-r--r-- | zsh/zshrc | 170 |
14 files changed, 4103 insertions, 312 deletions
diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 1d0b119..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -nvim/plugged/ - diff --git a/.gitmodules b/.gitmodules index 6aa735f..4238383 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "oh-my-zsh"] - path = zsh/omz - url = https://github.com/ohmyzsh/ohmyzsh -[submodule "zsh/omz"] - path = zsh/omz - url = https://github.com/ohmyzsh/ohmyzsh.git +[submodule "zsh/p10k"] + path = zsh/p10k + url = https://gitrepo.ru/NeonXP/powerlevel10k.git diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0bec4bf --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +pwd = $(shell pwd) +osver=$(shell lsb_release -sr) +oscodename=$(shell lsb_release -sc) +arch=$(shell dpkg --print-architecture) + +.PHONY: all +all: /usr/bin/docker /usr/bin/go /usr/bin/nvim dotfiles golibs + +# Docker install +.PHONY: /usr/bin/docker +/usr/bin/docker: + + sudo apt-get install ca-certificates curl + sudo install -m 0755 -d /etc/apt/keyrings + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc + sudo chmod a+r /etc/apt/keyrings/docker.asc + + echo "deb [arch=$(arch) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(oscodename) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt update + sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + +# Go install +.PHONY: /usr/bin/go +/usr/bin/go: + sudo add-apt-repository ppa:longsleep/golang-backports + sudo apt install golang-go + +.PHONY: golibs +golibs: /usr/bin/go + go install github.com/goreleaser/goreleaser@latest + go install github.com/mkchoi212/fac@latest + +# Neovim +.PHONY: /usr/bin/nvim +/usr/bin/nvim: + sudo add-apt-repository -r ppa:neovim-ppa/stable + sudo apt install neovim + +# dotfiles +.PHONY: dotfiles +dotfiles: ~/.gitconfig ~/.gitignore ~/.config/zsh ~/.zshrc + +~/.gitconfig: + @ln -s $(pwd)/git/config ~/.gitconfig || true +~/.gitignore: + @ln -s $(pwd)/git/ignore ~/.gitignore || true +~/.config/zsh: + @ln -s $(pwd)/zsh ~/.config/zsh || true +~/.zshrc: + @ln -s $(pwd)/zsh/zshrc ~/.zshrc || true
\ No newline at end of file diff --git a/brew_inventory.md b/brew_inventory.md index 7529184..261a673 100644 --- a/brew_inventory.md +++ b/brew_inventory.md @@ -10,7 +10,6 @@ Inventory created at: пятница, 7 января 2022 г. 03:53:45 (MSK) - [x] cmake: Cross-platform make - [x] exa: Modern replacement for 'ls' - [x] fac: Command line User Interface for fixing git conflicts -- [x] fish: User-friendly command-line shell for UNIX-like operating systems - [x] fzf: Command-line fuzzy finder written in Go - [x] git: Distributed revision control system - [x] git-delta: Syntax-highlighting pager for git and diff output @@ -22,11 +21,9 @@ Inventory created at: пятница, 7 января 2022 г. 03:53:45 (MSK) - [x] lima: Linux virtual machines - [x] micro: Modern and intuitive terminal-based text editor - [x] mosh: Remote terminal application -- [x] mutt: Mongrel of mail user agents (part elm, pine, mush, mh, etc.) - [x] neovim: Ambitious Vim-fork focused on extensibility and agility - [x] node: Platform built on V8 to build network applications - [x] openttd: Simulation game based upon Transport Tycoon Deluxe -- [x] phpunit: Programmer-oriented testing framework for PHP - [x] podman: Tool for managing OCI containers and pods - [x] pomodoro: Pomodoro timer for nerds - [x] rabbitmq-c: C AMQP client library for RabbitMQ @@ -40,16 +37,9 @@ Inventory created at: пятница, 7 января 2022 г. 03:53:45 (MSK) ## Casks -- [x] bitwarden: (failed to read homepage information) -- [x] firefox-developer-edition: (failed to read homepage information) - [x] font-fira-mono: (failed to read homepage information) - [x] font-fira-mono-nerd-font: (failed to read homepage information) -- [x] goland: (failed to read homepage information) -- [x] iterm2-beta: (failed to read homepage information) - [x] josm: (failed to read homepage information) -- [x] notion: (failed to read homepage information) -- [x] raycast: (failed to read homepage information) -- [x] robo-3t: (failed to read homepage information) - [x] telegram: (failed to read homepage information) - [x] vscodium: (failed to read homepage information) - [x] yandex: (failed to read homepage information) @@ -57,9 +47,7 @@ Inventory created at: пятница, 7 января 2022 г. 03:53:45 (MSK) ## Installed taps - [x] adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver -- [x] caskroom/fonts -- [x] d12frosted/emacs-plus -- [x] gcenx/wine +- [x] homebrew/cask-fonts - [x] go-swagger/go-swagger - [x] golangci/tap - [x] goreleaser/tap @@ -74,7 +62,6 @@ Inventory created at: пятница, 7 января 2022 г. 03:53:45 (MSK) - [x] mongodb/brew - [x] neonxp/tap - [x] osx-cross/avr -- [x] railwaycat/emacsmacport - [x] skyjake/lagrange - [x] tinygo-org/tools - [x] wtfutil/wtfutil @@ -1,7 +1,7 @@ [user] name = Alexander Kiryukhin - email = a.kiryukhin@mail.ru - signingkey = 1F234ED9217CA16DE1ACBA686DF7A2910D0699E9 + email = i@neonxp.ru + signingkey = 35E33E1AB7776B39 [alias] co = checkout @@ -105,8 +105,8 @@ submodulesummary = true [sendemail] - smtpserver = smtp.mail.ru - smtpuser = a.kiryukhin@mail.ru +# smtpserver = smtp.mail.ru +# smtpuser = a.kiryukhin@mail.ru smtpserverport = 25 smtpencryption = tls diff --git a/install.sh b/install.sh deleted file mode 100755 index f13c444..0000000 --- a/install.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -ln -s $(pwd)/nvim ${HOME}/.config/nvim -ln -s $(pwd)/git/config ${HOME}/.gitconfig -ln -s $(pwd)/git/ignore ${HOME}/.gitignore -ln -s $(pwd)/zsh/omz ${HOME}/.oh-my-zsh -ln -s $(pwd)/zsh/zshrc ${HOME}/.zshrc - diff --git a/nvim/coc-settings.json b/nvim/coc-settings.json deleted file mode 100644 index cbac8e1..0000000 --- a/nvim/coc-settings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "languageserver": { - "golang": { - "command": "gopls", - "rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"], - "filetypes": ["go"] - } - } -} diff --git a/nvim/init.vim b/nvim/init.vim deleted file mode 100644 index c5665d7..0000000 --- a/nvim/init.vim +++ /dev/null @@ -1,205 +0,0 @@ -syntax on -set ruler " Show the line and column numbers of the cursor. -set formatoptions+=o " Continue comment marker in new lines. -set textwidth=0 " Hard-wrap long lines as you type them. -set modeline " Enable modeline. -"set esckeys " Cursor keys in insert mode. -set linespace=0 " Set line-spacing to minimum. -set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J) -" More natural splits -set splitbelow " Horizontal split below current. -set splitright " Vertical split to right of current. -if !&scrolloff - set scrolloff=3 " Show next 3 lines while scrolling. -endif -if !&sidescrolloff - set sidescrolloff=5 " Show next 5 columns while side-scrolling. -endif -set display+=lastline -set nostartofline " Do not jump to first character with page commands. -set noerrorbells " No beeps -set backspace=indent,eol,start " Makes backspace key more powerful. -set showcmd " Show me what I'm typing -set showmode " Show current mode. -set noswapfile " Don't use swapfile -set nobackup " Don't create annoying backup files -set encoding=utf-8 " Set default encoding to UTF-8 -set autowrite " Automatically save before :next, :make etc. -set autoread " Automatically reread changed files without asking me anything -set laststatus=2 -set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats -set showmatch " Do not show matching brackets by flickering -set incsearch " Shows the match while typing -set hlsearch " Highlight found searches -set ignorecase " Search case insensitive... -set smartcase " ... but not when search pattern contains upper case characters -set gdefault " Use 'g' flag by default with :s/foo/bar/. -set magic " Use 'magic' patterns (extended regular expressions). - -" Use <C-L> to clear the highlighting of :set hlsearch. -if maparg('<C-L>', 'n') ==# '' - nnoremap <silent> <C-L> :nohlsearch<CR><C-L> -endif - -" Search and Replace -nmap <Leader>s :%s//g<Left><Left> - -" Leader key is like a command prefix. -"let mapleader='z' -"let maplocalleader='\' - -let g:python_host_prog="/usr/local/bin/python2.7" - -let g:session_autosave = 'yes' -let g:session_autoload = 'yes' -let g:session_default_to_last = 1 - -" set cursorcolumn -nmap <Space> <PageDown> -vmap <BS> x - -" Plugins here -call plug#begin('~/.config/nvim/plugged') -Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' -" Plug 'Shougo/deoplete.nvim' -Plug 'Valloric/YouCompleteMe' -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'Chiel92/vim-autoformat' -Plug 'scrooloose/nerdtree' -Plug 'terryma/vim-multiple-cursors' -Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } -Plug 'junegunn/fzf.vim' -Plug 'crusoexia/vim-monokai' -Plug 'projekt0n/github-nvim-theme' -Plug 'neovim/nvim-lspconfig' -Plug 'nvim-treesitter/nvim-treesitter' - -Plug 'mfussenegger/nvim-dap' -Plug 'rcarriga/nvim-dap-ui' -Plug 'theHamsta/nvim-dap-virtual-text' -Plug 'ray-x/guihua.lua' " float term, codeaction and codelens gui support - -Plug 'ray-x/go.nvim' -call plug#end() -lua <<EOF -require 'go'.setup({ - goimport = 'gopls', -- if set to 'gopls' will use golsp format - gofmt = 'gopls', -- if set to gopls will use golsp format - max_line_len = 120, - tag_transform = false, - test_dir = '', - comment_placeholder = ' ', - lsp_cfg = true, -- false: use your own lspconfig - lsp_gofumpt = true, -- true: set default gofmt in gopls format to gofumpt - lsp_on_attach = true, -- use on_attach from go.nvim - dap_debug = true, -}) - -local protocol = require'vim.lsp.protocol' - -EOF -set nu rnu -set tabstop=4 -set shiftwidth=0 -set softtabstop=-1 -set expandtab -set autoindent -set cursorline -set hidden -" Better display for messages -set cmdheight=2 -" Smaller updatetime for CursorHold & CursorHoldI -set updatetime=300 -" don't give |ins-completion-menu| messages. -set shortmess+=c -" always show signcolumns -set signcolumn=yes - -" Use tab for trigger completion with characters ahead and navigate. -" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin. -inoremap <silent><expr> <TAB> - \ pumvisible() ? "\<C-n>" : - \ <SID>check_back_space() ? "\<TAB>" : - \ coc#refresh() -inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" - -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -" deoplete config -let g:deoplete#enable_at_startup = 1 -let g:deoplete#disable_auto_complete = 1 -if has("gui_running") - inoremap <silent><expr><C-Space> deoplete#mappings#manual_complete() -else - inoremap <silent><expr><C-@> deoplete#mappings#manual_complete() -endif - -" UltiSnips config -inoremap <silent><expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" -let g:UltiSnipsExpandTrigger="<tab>" -let g:UltiSnipsJumpForwardTrigger="<tab>" -let g:UltiSnipsJumpBackwardTrigger="<s-tab>" - -" Tell Vim which characters to show for expanded TABs, -" trailing whitespace, and end-of-lines. VERY useful! -if &listchars ==# 'eol:$' - " set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ - set listchars=tab:>\ ,extends:>,precedes:<,nbsp:+ -endif - -" nerdtree config -map <c-n> :NERDTreeToggle<CR> - -" airline settings -let g:airline#extensions#tabline#enabled = 2 -let g:airline#extensions#tabline#fnamemod = ':t' -let g:airline#extensions#tabline#left_sep = ' ' -let g:airline#extensions#tabline#left_alt_sep = '|' -let g:airline#extensions#tabline#right_sep = ' ' -let g:airline#extensions#tabline#right_alt_sep = '|' -let g:airline_powerline_fonts=1 -let g:airline_left_sep = ' ' -let g:airline_left_alt_sep = '|' -let g:airline_right_sep = ' ' -let g:airline_right_alt_sep = '|' -let g:airline_powerline_fonts=0 -let g:airline_theme='base16_default_dark' - -" Multicursor -let g:multi_cursor_use_default_mapping=0 -let g:multi_cursor_next_key='<C-e>' -let g:multi_cursor_quit_key='<Esc>' -let g:multi_cursor_quit_key='<Esc>' - -" YouCompleteMe -let g:ycm_autoclose_preview_window_after_completion = 1 -let g:ycm_min_num_of_chars_for_completion = 1 - -" Other -set mouse= -set list -lua require('github-theme').setup() -"darcula fix to hide the indents: -set nolist - -let NERDTreeIgnore = ['_site'] - -" Buffer handling -nmap L :let &number=1-&number<CR> -nmap <silent> <c-]> :bnext<CR> -nmap <silent> <c-[> :bprevious<CR> -nmap <leader>bq :bp <BAR> bd #<CR> -nmap <leader>bl :ls<CR> -nmap <leader>0 :set invnumber<CR> -" map :q to byffer delete -" http://stackoverflow.com/questions/7513380/vim-change-x-function-to-delete-buffer-instead-of-save-quit -cnoreabbrev <expr> x getcmdtype() == ":" && getcmdline() == 'x' ? 'bd' : 'x' - -nmap <silent> <c-k> :wincmd k<CR> -nmap <silent> <c-j> :wincmd j<CR> -nmap <silent> <c-h> :wincmd h<CR> -nmap <silent> <c-l> :wincmd l<CR> diff --git a/zsh/antigen.zsh b/zsh/antigen.zsh new file mode 100644 index 0000000..e813207 --- /dev/null +++ b/zsh/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 <https://github.com/zsh-users/antigen/contributors> + # Homepage: http://antigen.sharats.me + # License: MIT License <mitl.sharats.me> +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. +# <repo-url>, <plugin-location>, <bundle-type>, <has-local-clone> +[[ $_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=<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 <args...> +-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 <url> [<loc>=/] +# 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 <record> +# 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 <<EOF + +Antigen is a plugin management system for zsh. It makes it easy to grab awesome +shell scripts and utilities, put up on Github. + +Usage: antigen <command> [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 <<EOBUNDLES +# antigen use oh-my-zsh +# +# antigen bundle zsh/bundle +# antigen bundle zsh/example +# +# antigen theme zsh/theme +# +# antigen apply +# EOBUNDLES +# +# Returns +# Nothing +antigen-init () { + local src="$1" line + + # If we're given an argument it should be a path to a file + if [[ -n "$src" ]]; then + if [[ -f "$src" ]]; then + source "$src" + return + else + printf "Antigen: invalid argument provided.\n" >&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: + # <version-hash> <repo-url> + 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 <library-name|url>' >&2 + echo 'Where <library-name> is any one of the following:' >&2 + echo ' * oh-my-zsh' >&2 + echo ' * prezto' >&2 + echo '<url> 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 <<EOC +#-- START ZCACHE GENERATED FILE +#-- GENERATED: $(date) +#-- ANTIGEN v2.2.2 +$(functions -- _antigen) +antigen () { + local MATCH MBEGIN MEND + [[ "\$ZSH_EVAL_CONTEXT" =~ "toplevel:*" || "\$ZSH_EVAL_CONTEXT" =~ "cmdarg:*" ]] && source "$_ANTIGEN_INSTALL_DIR/antigen.zsh" && eval antigen \$@; + return 0; +} +typeset -gaU fpath path +fpath+=(${_fpath[@]}) path+=(${_PATH[@]}) +_antigen_compinit () { + autoload -Uz compinit; compinit -d "$ANTIGEN_COMPDUMP"; compdef _antigen antigen + add-zsh-hook -D precmd _antigen_compinit +} +autoload -Uz add-zsh-hook; add-zsh-hook precmd _antigen_compinit +compdef () {} + +if [[ -n "$ZSH" ]]; then + ZSH="$ZSH"; ZSH_CACHE_DIR="$ZSH_CACHE_DIR" +fi +#--- BUNDLES BEGIN +${(j::)_sources} +#--- BUNDLES END +typeset -gaU _ANTIGEN_BUNDLE_RECORD; _ANTIGEN_BUNDLE_RECORD=($(print ${(qq)_ANTIGEN_BUNDLE_RECORD})) +typeset -g _ANTIGEN_CACHE_LOADED; _ANTIGEN_CACHE_LOADED=true +typeset -ga _ZCACHE_BUNDLE_SOURCE; _ZCACHE_BUNDLE_SOURCE=($(print ${(qq)_ZCACHE_BUNDLE_SOURCE})) +typeset -g _ANTIGEN_CACHE_VERSION; _ANTIGEN_CACHE_VERSION='v2.2.2' + +#-- END ZCACHE GENERATED FILE +EOC + + { zcompile "$ANTIGEN_CACHE" } &! + + # Compile config files, if any + LOG "CHECK_FILES $ANTIGEN_CHECK_FILES" + [[ $ANTIGEN_AUTO_CONFIG == true && -n $ANTIGEN_CHECK_FILES ]] && { + echo ${(j:\n:)ANTIGEN_CHECK_FILES} >! "$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 <path-to/location>]' \ + '--url[Path to the repository <github-account/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/zsh/completion.zsh b/zsh/completion.zsh new file mode 100644 index 0000000..1237e84 --- /dev/null +++ b/zsh/completion.zsh @@ -0,0 +1,177 @@ +#compdef _kind kind + +# zsh completion for kind -*- shell-script -*- + +__kind_debug() +{ + local file="$BASH_COMP_DEBUG_FILE" + if [[ -n ${file} ]]; then + echo "$*" >> "${file}" + fi +} + +_kind() +{ + local shellCompDirectiveError=1 + local shellCompDirectiveNoSpace=2 + local shellCompDirectiveNoFileComp=4 + local shellCompDirectiveFilterFileExt=8 + local shellCompDirectiveFilterDirs=16 + + local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace + local -a completions + + __kind_debug "\n========= starting completion logic ==========" + __kind_debug "CURRENT: ${CURRENT}, words[*]: ${words[*]}" + + # The user could have moved the cursor backwards on the command-line. + # We need to trigger completion from the $CURRENT location, so we need + # to truncate the command-line ($words) up to the $CURRENT location. + # (We cannot use $CURSOR as its value does not work when a command is an alias.) + words=("${=words[1,CURRENT]}") + __kind_debug "Truncated words[*]: ${words[*]}," + + lastParam=${words[-1]} + lastChar=${lastParam[-1]} + __kind_debug "lastParam: ${lastParam}, lastChar: ${lastChar}" + + # For zsh, when completing a flag with an = (e.g., kind -n=<TAB>) + # completions must be prefixed with the flag + setopt local_options BASH_REMATCH + if [[ "${lastParam}" =~ '-.*=' ]]; then + # We are dealing with a flag with an = + flagPrefix="-P ${BASH_REMATCH}" + fi + + # Prepare the command to obtain completions + requestComp="${words[1]} __complete ${words[2,-1]}" + if [ "${lastChar}" = "" ]; then + # If the last parameter is complete (there is a space following it) + # We add an extra empty parameter so we can indicate this to the go completion code. + __kind_debug "Adding extra empty parameter" + requestComp="${requestComp} \"\"" + fi + + __kind_debug "About to call: eval ${requestComp}" + + # Use eval to handle any environment variables and such + out=$(eval ${requestComp} 2>/dev/null) + __kind_debug "completion output: ${out}" + + # Extract the directive integer following a : from the last line + local lastLine + while IFS='\n' read -r line; do + lastLine=${line} + done < <(printf "%s\n" "${out[@]}") + __kind_debug "last line: ${lastLine}" + + if [ "${lastLine[1]}" = : ]; then + directive=${lastLine[2,-1]} + # Remove the directive including the : and the newline + local suffix + (( suffix=${#lastLine}+2)) + out=${out[1,-$suffix]} + else + # There is no directive specified. Leave $out as is. + __kind_debug "No directive found. Setting do default" + directive=0 + fi + + __kind_debug "directive: ${directive}" + __kind_debug "completions: ${out}" + __kind_debug "flagPrefix: ${flagPrefix}" + + if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then + __kind_debug "Completion received error. Ignoring completions." + return + fi + + while IFS='\n' read -r comp; do + if [ -n "$comp" ]; then + # If requested, completions are returned with a description. + # The description is preceded by a TAB character. + # For zsh's _describe, we need to use a : instead of a TAB. + # We first need to escape any : as part of the completion itself. + comp=${comp//:/\\:} + + local tab=$(printf '\t') + comp=${comp//$tab/:} + + __kind_debug "Adding completion: ${comp}" + completions+=${comp} + lastComp=$comp + fi + done < <(printf "%s\n" "${out[@]}") + + if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then + __kind_debug "Activating nospace." + noSpace="-S ''" + fi + + if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then + # File extension filtering + local filteringCmd + filteringCmd='_files' + for filter in ${completions[@]}; do + if [ ${filter[1]} != '*' ]; then + # zsh requires a glob pattern to do file filtering + filter="\*.$filter" + fi + filteringCmd+=" -g $filter" + done + filteringCmd+=" ${flagPrefix}" + + __kind_debug "File filtering command: $filteringCmd" + _arguments '*:filename:'"$filteringCmd" + elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then + # File completion for directories only + local subdir + subdir="${completions[1]}" + if [ -n "$subdir" ]; then + __kind_debug "Listing directories in $subdir" + pushd "${subdir}" >/dev/null 2>&1 + else + __kind_debug "Listing directories in ." + fi + + local result + _arguments '*:dirname:_files -/'" ${flagPrefix}" + result=$? + if [ -n "$subdir" ]; then + popd >/dev/null 2>&1 + fi + return $result + else + __kind_debug "Calling _describe" + if eval _describe "completions" completions $flagPrefix $noSpace; then + __kind_debug "_describe found some completions" + + # Return the success of having called _describe + return 0 + else + __kind_debug "_describe did not find completions." + __kind_debug "Checking if we should do file completion." + if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then + __kind_debug "deactivating file completion" + + # We must return an error code here to let zsh know that there were no + # completions found by _describe; this is what will trigger other + # matching algorithms to attempt to find completions. + # For example zsh can match letters in the middle of words. + return 1 + else + # Perform file completion + __kind_debug "Activating file completion" + + # We must return the result of this command, so it must be the + # last command, or else we must store its result to return it. + _arguments '*:filename:_files'" ${flagPrefix}" + fi + fi + fi +} + +# don't run the completion function when being source-ed or eval-ed +if [ "$funcstack[1]" = "_kind" ]; then + _kind +fi diff --git a/zsh/omz b/zsh/omz deleted file mode 160000 -Subproject e9e8c6b54d594109041bdd4bc3902b40f9ae884 diff --git a/zsh/p10k b/zsh/p10k new file mode 160000 +Subproject 62341054d8aa40ade03fc55bdbc95b9ff2d8d2b diff --git a/zsh/p10k.zsh b/zsh/p10k.zsh new file mode 100644 index 0000000..0efd5ad --- /dev/null +++ b/zsh/p10k.zsh @@ -0,0 +1,1705 @@ +# Generated by Powerlevel10k configuration wizard on 2024-02-01 at 23:16 MSK. +# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 26839. +# Wizard options: awesome-fontconfig + powerline, large icons, unicode, lean, 24h time, +# 1 line, compact, few icons, concise, transient_prompt, instant_prompt=verbose. +# Type `p10k configure` to generate another config. +# +# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate +# your own config based on it. +# +# Tip: Looking for a nice color? Here's a one-liner to print colormap. +# +# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh -o extended_glob + + # Unset all configuration options. This allows you to apply configuration changes without + # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. + unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' + + # Zsh >= 5.1 is required. + [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + + # The list of segments shown on the left. Fill it with the most important segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + # 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) + lf # lf shell (https://github.com/gokcehan/lf) + 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) + chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) + # 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/) + per_directory_history # Oh My Zsh per-directory-history local/global indicator + # cpu_arch # CPU architecture + 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=awesome-fontconfig + # 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=moderate + + # Basic style options that define the overall look of your prompt. You probably don't want to + # change them. + typeset -g POWERLEVEL9K_BACKGROUND= # transparent background + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol + + # When set to true, icons appear before content on both sides of the prompt. When set + # to false, icons go after content. If empty or not set, icons go before content in the left + # prompt and after content in the right prompt. + # + # You can also override it for a specific segment: + # + # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false + # + # Or for a specific segment in specific state: + # + # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false + typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true + + # Add an empty line before each prompt. + typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false + + # Connect left prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX= + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX= + + # The left end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + # The right end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= + + # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll + # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and + # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. + typeset -g POWERLEVEL9K_SHOW_RULER=false + typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·' + typeset -g POWERLEVEL9K_RULER_FOREGROUND=242 + + # Filler between left and right prompt on the first prompt line. You can set it to '·' or '─' + # to make it easier to see the alignment between left and right prompt and to separate prompt + # from command output. It serves the same purpose as ruler (see above) without increasing + # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false + # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact + # prompt. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' + if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then + # The color of the filler. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=242 + # Add a space between the end of left prompt and the filler. + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' + # Add a space between the filler and the start of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' ' + # Start filler from the edge of the screen if there are no left segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' + # End filler on the edge of the screen if there are no right segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' + fi + + #################################[ os_icon: os identifier ]################################## + # OS identifier color. + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND= + # Custom icon. + # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' + + ################################[ prompt_char: prompt symbol ]################################ + # Green prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 + # Default prompt symbol. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + # Prompt symbol in command vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' + # Prompt symbol in visual vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true + # No line terminator if prompt_char is the last segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' + # No line introducer if prompt_char is the first segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + + ##################################[ dir: current directory ]################################## + # Default current directory color. + typeset -g POWERLEVEL9K_DIR_FOREGROUND=31 + # If directory is too long, shorten some of its segments to the shortest possible unique + # prefix. The shortened directory can be tab-completed to the original. + typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique + # Replace removed segment suffixes with this symbol. + typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= + # Color of the shortened directory segments. + typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103 + # Color of the anchor directory segments. Anchor segments are never shortened. The first + # segment is always an anchor. + typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 + # Display anchor directory segments in bold. + typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .go-version + .ruby-version + .lua-version + .java-version + .perl-version + .php-version + .tool-versions + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + stack.yaml + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" + # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains + # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is + # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) + # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers + # and other directories don't. + # + # Optionally, "first" and "last" can be followed by ":<offset>" where <offset> is an integer. + # This moves the truncation point to the right (positive offset) or to the left (negative offset) + # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" + # respectively. + typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false + # Don't shorten this many last directory segments. They are anchors. + typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + # Shorten directory if it's longer than this even if there is space for it. The value can + # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). + # If set to `0`, directory will always be shortened to its minimum length. + typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 + # If set to true, embed a hyperlink into the directory. Useful for quickly + # opening a directory in the file manager simply by clicking the link. + # Can also be handy when the directory is shortened, as it allows you to see + # the full directory that was used in previous commands. + typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + + # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON + # and POWERLEVEL9K_DIR_CLASSES below. + typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 + + # The default icon shown next to non-writable and non-existent directories when + # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. + # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' + + # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different + # directories. It must be an array with 3 * N elements. Each triplet consists of: + # + # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with + # extended_glob option enabled. + # 2. Directory class for the purpose of styling. + # 3. An empty string. + # + # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. + # + # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories + # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=( + # '~/work(|/*)' WORK '' + # '~(|/*)' HOME '' + # '*' DEFAULT '') + # + # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one + # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or + # WORK_NON_EXISTENT. + # + # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an + # option to define custom colors and icons for different directory classes. + # + # # Styling for WORK. + # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 + # + # # Styling for WORK_NOT_WRITABLE. + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 + # + # # Styling for WORK_NON_EXISTENT. + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39 + # + # If a styling parameter isn't explicitly defined for some class, it falls back to the classless + # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls + # back to POWERLEVEL9K_DIR_FOREGROUND. + # + typeset -g POWERLEVEL9K_DIR_CLASSES=() + + # Custom prefix. + # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' + + #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + + # Formatter for Git status. + # + # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: + # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + if (( $1 )); then + # Styling for up-to-date Git status. + local meta='%f' # default foreground + local clean='%76F' # green foreground + local modified='%178F' # yellow foreground + local untracked='%39F' # blue foreground + local conflicted='%196F' # red foreground + else + # Styling for incomplete and stale Git status. + local meta='%244F' # grey foreground + local clean='%244F' # grey foreground + local modified='%244F' # grey foreground + local untracked='%244F' # grey foreground + local conflicted='%244F' # grey foreground + fi + + local res + + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + local branch=${(V)VCS_STATUS_LOCAL_BRANCH} + # If local branch name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" + fi + + if [[ -n $VCS_STATUS_TAG + # Show tag only if not on a branch. + # Tip: To always show tag, delete the next line. + && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line + ]]; then + local tag=${(V)VCS_STATUS_TAG} + # If tag name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show tag name in full without truncation, delete the next line. + (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line + res+="${meta}#${clean}${tag//\%/%%}" + fi + + # Display the current Git commit if there is no branch and no tag. + # Tip: To always display the current Git commit, delete the next line. + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" + fi + + # Display "wip" if the latest commit's summary contains "wip" or "WIP". + if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then + res+=" ${modified}wip" + fi + + if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then + # ⇣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}" + elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then + # Tip: Uncomment the next line to display '=' if up to date with the remote. + # res+=" ${clean}=" + fi + + # ⇠42 if behind the push remote. + (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" + (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " + # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. + (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + # "─" if the number of unstaged files is unknown. This can happen due to + # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower + # than the number of files in the Git index, or due to bash.showDirtyState being set to false + # in the repository config. The number of staged and untracked files may also be unknown + # in this case. + (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" + + typeset -g my_git_format=$res + } + functions -M my_git_formatter 2>/dev/null + + # Don't count the number of unstaged, untracked and conflicted files in Git repositories with + # more than this many files in the index. Negative value means infinity. + # + # If you are working in Git repositories with tens of millions of files and seeing performance + # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output + # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's + # config: `git config bash.showDirtyState false`. + typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 + + # Don't show Git status in prompt for repositories whose workdir matches this pattern. + # For example, if set to '~', the Git repository at $HOME/.git will be ignored. + # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. + typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' + + # Disable the default Git status formatting. + typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true + # Install our own Git status formatter. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' + # Enable counters for staged, unstaged, etc. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 + typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 + # Custom icon. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION= + # Custom prefix. + # typeset -g POWERLEVEL9K_VCS_PREFIX='%fon ' + + # Show status of repositories of these types. You can add svn and/or hg if you are + # using them. If you do, your prompt may become slow even when your current directory + # isn't in an svn or hg repository. + typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + + # These settings are used for repositories other than Git or when gitstatusd fails and + # Powerlevel10k has to fall back to using vcs_info. + typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 + + ##########################[ status: exit code of the last command ]########################### + # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and + # style them independently from the regular OK and ERROR state. + typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true + + # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as + # it will signify success by turning green. + typeset -g POWERLEVEL9K_STATUS_OK=false + typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when some part of a pipe command fails but the overall exit status is zero. It may look + # like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as + # it will signify error by turning red. + typeset -g POWERLEVEL9K_STATUS_ERROR=false + typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when the last command was terminated by a signal. + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160 + # Use terse signal names: "INT" instead of "SIGINT(2)". + typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when some part of a pipe command fails and the overall exit status is also non-zero. + # It may look like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' + + ###################[ command_execution_time: duration of the last command ]################### + # Show duration of the last command if takes at least this many seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 + # Show this many fractional digits. Zero means round to seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Execution time color. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Custom icon. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION= + # Custom prefix. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook ' + + #######################[ background_jobs: presence of background jobs ]####################### + # Don't show the number of background jobs. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false + # Background jobs color. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### + # Default asdf color. Only used to display tools for which there is no color override (see below). + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND. + typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66 + + # There are four parameters that can be used to hide asdf tools. Each parameter describes + # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at + # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to + # hide a tool, it gets shown. + # + # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and + # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: + # + # asdf local python 3.8.1 + # asdf global python 3.8.1 + # + # After running both commands the current python version is 3.8.1 and its source is "local" as + # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, + # it'll hide python version in this case because 3.8.1 is the same as the global version. + # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't + # contain "local". + + # Hide tool versions that don't come from one of these sources. + # + # Available sources: + # + # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" + # - local `asdf current` says "set by /some/not/home/directory/file" + # - global `asdf current` says "set by /home/username/file" + # + # Note: If this parameter is set to (shell local global), it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. + typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) + + # If set to false, hide tool versions that are the same as global. + # + # Note: The name of this parameter doesn't reflect its meaning at all. + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. + typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false + + # If set to false, hide tool versions that are equal to "system". + # + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. + typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true + + # If set to non-empty value, hide tools unless there is a file matching the specified file pattern + # in the current directory, or its parent directory, or its grandparent directory, and so on. + # + # Note: If this parameter is set to empty value, it won't hide tools. + # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. + # + # Example: Hide nodejs version when there is no package.json and no *.js files in the current + # directory, in `..`, in `../..` and so on. + # + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' + typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= + + # Ruby version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168 + # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Python version from asdf. + typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Go version from asdf. + typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Node.js version from asdf. + typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Rust version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' + + # .NET Core version from asdf. + typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134 + # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_DOTNET_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Flutter version from asdf. + typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Lua version from asdf. + typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Java version from asdf. + typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Perl version from asdf. + typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67 + # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Erlang version from asdf. + typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125 + # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Elixir version from asdf. + typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129 + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Postgres version from asdf. + typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31 + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Haskell version from asdf. + typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172 + # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Julia version from asdf. + typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' + + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### + # NordVPN connection indicator color. + typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 + # Hide NordVPN connection indicator when not connected. + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= + # Custom icon. + # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### + # Nnn shell color. + typeset -g POWERLEVEL9K_NNN_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ lf: lf shell (https://github.com/gokcehan/lf) ]####################### + # lf shell color. + typeset -g POWERLEVEL9K_LF_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_LF_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 + + # Display the icon of nix_shell if PATH contains a subdirectory of /nix/store. + # typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=false + + # 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='⭐' + + ##################[ chezmoi_shell: chezmoi shell (https://www.chezmoi.io/) ]################## + # chezmoi shell color. + typeset -g POWERLEVEL9K_CHEZMOI_SHELL_FOREGROUND=33 + # Custom icon. + # typeset -g POWERLEVEL9K_CHEZMOI_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ disk_usage: disk usage ]################################## + # Colors for different levels of disk usage. + typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=220 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=160 + # Thresholds for different levels of disk usage (percentage points). + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 + # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. + typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false + # Custom icon. + # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ ram: free RAM ]####################################### + # RAM color. + typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 + # Custom icon. + # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################################[ swap: used swap ]###################################### + # Swap color. + typeset -g POWERLEVEL9K_SWAP_FOREGROUND=96 + # Custom icon. + # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ load: CPU load ]###################################### + # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. + typeset -g POWERLEVEL9K_LOAD_WHICH=5 + # Load color when load is under 50%. + typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 + # Load color when load is between 50% and 70%. + typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 + # Load color when load is over 70%. + typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 + # Custom icon. + # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ + # Todo color. + typeset -g POWERLEVEL9K_TODO_FOREGROUND=110 + # Hide todo when the total number of tasks is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true + # Hide todo when the number of tasks after filtering is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false + + # Todo format. The following parameters are available within the expansion. + # + # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. + # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. + # + # These variables correspond to the last line of the output of `todo.sh -p ls`: + # + # TODO: 24 of 42 tasks shown + # + # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. + # + # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ + # Timewarrior color. + typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110 + # If the tracked task is longer than 24 characters, truncate and append "…". + # Tip: To always display tasks without truncation, delete the following parameter. + # Tip: To hide task names and display just the icon when time tracking is enabled, set the + # value of the following parameter to "". + typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' + + # Custom icon. + # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## + # Taskwarrior color. + typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74 + + # Taskwarrior segment format. The following parameters are available within the expansion. + # + # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. + # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. + # + # Zero values are represented as empty parameters. + # + # The default format: + # + # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' + # + # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]####### + # Color when using local/global history. + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=135 + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=130 + + # Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon. + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION='' + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION='' + + # Custom icon. + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ cpu_arch: CPU architecture ]################################ + # CPU architecture color. + typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172 + + # Hide the segment when on a specific CPU architecture. + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ context: user@hostname ]################################## + # Context color when running with privileges. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 + # Context color in SSH without privileges. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180 + # Default context color (no privileges, no SSH). + typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 + + # Context format when running with privileges: bold user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' + # Context format when in SSH without privileges: user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' + # Default context format (no privileges, no SSH): user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' + + # Don't show context unless running with privileges or in SSH. + # Tip: Remove the next line to always show context. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith ' + + ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### + # Python virtual environment color. + typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 + # Don't show Python version next to the virtual environment name. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + # If set to "false", won't show virtualenv if pyenv is already shown. + # If set to "if-different", won't show virtualenv if it's the same as pyenv. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='🐍' + + #####################[ anaconda: conda environment (https://conda.io/) ]###################### + # Anaconda environment color. + typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 + + # Anaconda segment format. The following parameters are available within the expansion. + # + # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. + # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. + # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). + # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). + # + # CONDA_PROMPT_MODIFIER can be configured with the following command: + # + # conda config --set env_prompt '({default_env}) ' + # + # The last argument is a Python format string that can use the following variables: + # + # - prefix The same as CONDA_PREFIX. + # - default_env The same as CONDA_DEFAULT_ENV. + # - name The last segment of CONDA_PREFIX. + # - stacked_env Comma-separated list of names in the environment stack. The first element is + # always the same as default_env. + # + # Note: '({default_env}) ' is the default value of env_prompt. + # + # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER + # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former + # is empty. + typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' + + # Custom icon. + typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='🐍' + + ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ + # Pyenv color. + typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 + # Hide python version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) + # If set to false, hide python version if it's the same as global: + # $(pyenv version-name) == $(pyenv global). + typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide python version if it's equal to "system". + typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true + + # Pyenv segment format. The following parameters are available within the expansion. + # + # - P9K_CONTENT Current pyenv environment (pyenv version-name). + # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). + # + # The default format has the following logic: + # + # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or + # starts with "$P9K_PYENV_PYTHON_VERSION/". + # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' + + # Custom icon. + typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='🐍' + + ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ + # Goenv color. + typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37 + # Hide go version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) + # If set to false, hide go version if it's the same as global: + # $(goenv version-name) == $(goenv global). + typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide go version if it's equal to "system". + typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## + # Nodenv color. + typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70 + # Hide node version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) + # If set to false, hide node version if it's the same as global: + # $(nodenv version-name) == $(nodenv global). + typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### + # Nvm color. + typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 + # If set to false, hide node version if it's the same as default: + # $(nvm version current) == $(nvm version default). + typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ + # Nodeenv color. + typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70 + # Don't show Node version next to the environment name. + typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false + # Separate environment name from Node version only with a space. + typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############################[ node_version: node.js version ]############################### + # Node version color. + typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70 + # Show node version only when in a directory tree containing package.json. + typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ go_version: go version (https://golang.org) ]######################## + # Go version color. + typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ java_version: java version (https://www.java.com/) ]#################### + # Java version color. + typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32 + # Show java version only when in a java project subdirectory. + typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true + # Show brief version. + typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false + # Custom icon. + # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### + # Package color. + typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117 + # Package format. The following parameters are available within the expansion. + # + # - P9K_PACKAGE_NAME The value of `name` field in package.json. + # - P9K_PACKAGE_VERSION The value of `version` field in package.json. + # + # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' + # Custom icon. + # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 + # Hide ruby version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) + # If set to false, hide ruby version if it's the same as global: + # $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide ruby version if it's equal to "system". + typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ + # Fvm color. + typeset -g POWERLEVEL9K_FVM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### + # Lua color. + typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32 + # Hide lua version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) + # If set to false, hide lua version if it's the same as global: + # $(luaenv version-name) == $(luaenv global). + typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide lua version if it's equal to "system". + typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ + # Java color. + typeset -g POWERLEVEL9K_JENV_FOREGROUND=32 + # Hide java version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) + # If set to false, hide java version if it's the same as global: + # $(jenv version-name) == $(jenv global). + typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide java version if it's equal to "system". + typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ + # Perl color. + typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67 + # Hide perl version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) + # If set to false, hide perl version if it's the same as global: + # $(plenv version-name) == $(plenv global). + typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide perl version if it's equal to "system". + typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ + # Perlbrew color. + typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 + # Show perlbrew version only when in a perl project subdirectory. + typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true + # Don't show "perl-" at the front. + typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide php version if it's equal to "system". + typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### + # Scala color. + typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160 + # Hide scala version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) + # If set to false, hide scala version if it's the same as global: + # $(scalaenv version-name) == $(scalaenv global). + typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide scala version if it's equal to "system". + typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### + # Haskell color. + typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172 + # Hide haskell version if it doesn't come from one of these sources. + # + # shell: version is set by STACK_YAML + # local: version is set by stack.yaml up the directory tree + # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) + typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) + # If set to false, hide haskell version if it's the same as in the implicit global project. + typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true + # Custom icon. + # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# + # Show kubecontext only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show kubecontext. + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold|kubent|kubecolor|cmctl|sparkctl' + + # Kubernetes context classes for the purpose of using different colors, icons and expansions with + # different contexts. + # + # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current kubernetes context gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current kubernetes context is "deathray-testing/default", its class is TEST + # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134 + # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext + # segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # Within the expansion the following parameters are always available: + # + # - P9K_CONTENT The content that would've been displayed if there was no content + # expansion defined. + # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE + # in the output of `kubectl config get-contexts`. If there is no + # namespace, the parameter is set to "default". + # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the + # output of `kubectl config get-contexts`. + # + # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), + # the following extra parameters are available: + # + # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. + # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. + # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. + # + # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, + # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=gke + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + # + # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=eks + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= + # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + # Append the current context's namespace if it's not "default". + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' + + # Custom prefix. + # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' + + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Don't show terraform workspace if it's literally "default". + typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false + # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current terraform workspace gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' OTHER) + # + # If your current terraform workspace is "project_test", its class is TEST because "project_test" + # doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' OTHER) + typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ terraform_version: terraform version (https://www.terraform.io) ]############## + # Terraform version color. + typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# + # Show aws only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show aws. + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|terraform|pulumi|terragrunt' + + # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current AWS profile gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current AWS profile is "company_test", its class is TEST + # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 + # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # AWS segment format. The following parameters are available within the expansion. + # + # - P9K_AWS_PROFILE The name of the current AWS profile. + # - P9K_AWS_REGION The region associated with the current AWS profile. + typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' + + #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# + # AWS Elastic Beanstalk environment color. + typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Show azure only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show azure. + typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' + + # POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current azure account name 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_AZURE_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AZURE_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' OTHER) + # + # If your current azure account 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_AZURE_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AZURE_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' OTHER) + + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=32 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### + # Show gcloud only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show gcloud. + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' + # Google cloud color. + typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 + + # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or + # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative + # enough. You can use the following parameters in the expansions. Each of them corresponds to the + # output of `gcloud` tool. + # + # Parameter | Source + # -------------------------|-------------------------------------------------------------------- + # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' + # P9K_GCLOUD_ACCOUNT | gcloud config get-value account + # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project + # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. + # + # Obtaining project name requires sending a request to Google servers. This can take a long time + # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud + # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets + # set and gcloud prompt segment transitions to state COMPLETE. + # + # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL + # and COMPLETE. You can also hide gcloud in state PARTIAL by setting + # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and + # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. + typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' + typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' + + # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name + # this often. Negative value disables periodic polling. In this mode project name is retrieved + # only when the current configuration, account or project id changes. + typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 + + # Custom icon. + # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# + # Show google_app_cred only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show google_app_cred. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' + + # Google application credentials classes for the purpose of using different colors, icons and + # expansions with different credentials. + # + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first + # element in each pair defines a pattern against which the current kubernetes context gets + # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion + # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION + # parameters, you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. + # The first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD + # '*:*test*:*' TEST + # '*' DEFAULT) + # + # If your current Google application credentials is "service_account deathray-testing x@y.com", + # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD # These values are examples that are unlikely + # '*:*test*:*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by + # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # You can use the following parameters in the expansion. Each of them corresponds to one of the + # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. + # + # Parameter | JSON key file field + # ---------------------------------+--------------- + # P9K_GOOGLE_APP_CRED_TYPE | type + # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id + # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' + + ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### + # Toolbox color. + typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178 + # Don't display the name of the toolbox if it matches fedora-toolbox-*. + typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' + # Custom icon. + # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin ' + + ###############################[ public_ip: public IP address ]############################### + # Public IP color. + typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 + # Custom icon. + # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ########################[ vpn_ip: virtual private network indicator ]######################### + # VPN IP color. + typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 + # When on VPN, show just an icon without the IP address. + # Tip: To display the private IP address when on VPN, remove the next line. + typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= + # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN + # to see the name of the interface. + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)' + # If set to true, show one segment per matching network interface. If set to false, show only + # one segment corresponding to the first matching network interface. + # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. + typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false + # Custom icon. + # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### + # IP color. + typeset -g POWERLEVEL9K_IP_FOREGROUND=38 + # The following parameters are accessible within the expansion: + # + # Parameter | Meaning + # ----------------------+------------------------------------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt + # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) + typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %70F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %215F⇡$P9K_IP_TX_RATE}' + # Show information for the first network interface whose name matches this regular expression. + # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. + typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' + # Custom icon. + # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ battery: internal battery ]################################# + # Show battery in red when it's below this level and not connected to power supply. + typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 + typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 + # Show battery in green when it's charging or fully charged. + typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 + # Show battery in yellow when it's discharging. + typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 + # Battery pictograms going from low to high level of charge. + typeset -g POWERLEVEL9K_BATTERY_STAGES=('%K{232}▁' '%K{232}▂' '%K{232}▃' '%K{232}▄' '%K{232}▅' '%K{232}▆' '%K{232}▇' '%K{232}█') + # Don't show the remaining time to charge/discharge. + typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false + + #####################################[ wifi: wifi speed ]##################################### + # WiFi color. + typeset -g POWERLEVEL9K_WIFI_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). + # + # # Wifi colors and icons for different signal strength levels (low to high). + # typeset -g my_wifi_fg=(68 68 68 68 68) # <-- change these values + # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values + # + # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' + # + # The following parameters are accessible within the expansions: + # + # Parameter | Meaning + # ----------------------+--------------- + # P9K_WIFI_SSID | service set identifier, a.k.a. network name + # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown + # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second + # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 + # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 + # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + + ####################################[ time: current time ]#################################### + # Current time color. + typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 + # Format for the current time: 09:51:02. See `man 3 strftime`. + typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' + # If set to true, time will update when you hit enter. This way prompts for the past + # commands will contain the start times of their commands as opposed to the default + # behavior where they contain the end times of their preceding commands. + typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false + # Custom icon. + typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION= + # Custom prefix. + # typeset -g POWERLEVEL9K_TIME_PREFIX='%fat ' + + # Example of a user-defined prompt segment. Function prompt_example will be called on every + # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or + # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. + # + # Type `p10k help segment` for documentation and a more sophisticated example. + function prompt_example() { + p10k segment -f 208 -i '⭐' -t 'hello, %n' + } + + # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job + # is to generate the prompt segment for display in instant prompt. See + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # + # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function + # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k + # will replay these calls without actually calling instant_prompt_*. It is imperative that + # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this + # rule is not observed, the content of instant prompt will be incorrect. + # + # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If + # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. + function instant_prompt_example() { + # Since prompt_example always makes the same `p10k segment` calls, we can call it from + # instant_prompt_example. This will give us the same `example` prompt segment in the instant + # and regular prompts. + prompt_example + } + + # User-defined prompt segments can be customized the same way as built-in segments. + # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 + # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt + # when accepting a command line. Supported values: + # + # - off: Don't change prompt when accepting a command line. + # - always: Trim down prompt when accepting a command line. + # - same-dir: Trim down prompt when accepting a command line unless this is the first command + # typed after changing current working directory. + typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=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' @@ -1,66 +1,108 @@ -export PATH=$HOME/.bin:/usr/local/bin:$HOME/go/bin:$PATH -# Path to your oh-my-zsh installation. -export ZSH="$HOME/.oh-my-zsh" -export EDITOR="/usr/local/bin/micro" - -ZSH_THEME="robbyrussell" - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" -# HYPHEN_INSENSITIVE="true" - -# Uncomment one of the following lines to change the auto-update behavior -# zstyle ':omz:update' mode disabled # disable automatic updates -# zstyle ':omz:update' mode auto # update automatically without asking -# zstyle ':omz:update' mode reminder # just remind me to update when it's time - -# Uncomment the following line to change how often to auto-update (in days). -# zstyle ':omz:update' frequency 13 - -COMPLETION_WAITING_DOTS="true" - -DISABLE_UNTRACKED_FILES_DIRTY="true" -# HIST_STAMPS="mm/dd/yyyy" - -ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=yellow,underline" - -plugins=(git zsh-autosuggestions fzf golang) - -source $ZSH/oh-my-zsh.sh - -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions - if [[ -n $SSH_CONNECTION ]]; then - export EDITOR='vim' - else - export EDITOR='a' - fi - -# export ARCHFLAGS="-arch x86_64" - -[ -f ~/.zshrc.local ] && source ~/.zshrc.local -[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh - -### Added by Zinit's installer -if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then - print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f" - command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit" - command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \ - print -P "%F{33} %F{34}Installation successful.%f%b" || \ - print -P "%F{160} The clone has failed.%f%b" +# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. +# Initialization code that may require console input (password prompts, [y/n] +# confirmations, etc.) must go above this block; everything else may go below. +if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi -source "$HOME/.local/share/zinit/zinit.git/zinit.zsh" -autoload -Uz _zinit -(( ${+_comps} )) && _comps[zinit]=_zinit - -# Load a few important annexes, without Turbo -# (this is currently required for annexes) -zinit light-mode for \ - zdharma-continuum/zinit-annex-as-monitor \ - zdharma-continuum/zinit-annex-bin-gem-node \ - zdharma-continuum/zinit-annex-patch-dl \ - zdharma-continuum/zinit-annex-rust - -### End of Zinit's installer chunk +# Exports +export PATH=$HOME/.bin:/usr/local/bin:$HOME/go/bin:$PATH +export EDITOR="nvim" + +# Aliases +[[ ! -f `which exa` ]] || alias ls="exa" +alias ll="ls -la" +alias cp="cp -i" # Confirm before overwriting something +alias df='df -h' # Human-readable sizes +alias free='free -m' # Show sizes in MB +alias gitu='git add . && git commit && git push' + +## Options section +setopt correct # Auto correct mistakes +setopt extendedglob # Extended globbing. Allows using regular expressions with * +setopt nocaseglob # Case insensitive globbing +setopt rcexpandparam # Array expension with parameters +setopt nocheckjobs # Don't warn about running processes when exiting +setopt numericglobsort # Sort filenames numerically when it makes sense +setopt nobeep # No beep +setopt appendhistory # Immediately append history instead of overwriting +setopt histignorealldups # If a new command is a duplicate, remove the older one +setopt autocd # if only directory path is entered, cd there. +setopt inc_append_history # save commands are added to the history immediately, otherwise only when shell exits. +setopt histignorespace # Don't save commands that start with space + +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case insensitive tab completion +zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Colored completion (different colors for dirs/files/etc) +zstyle ':completion:*' rehash true # automatically find new executables in path +# Speed up completions +zstyle ':completion:*' accept-exact '*(N)' +zstyle ':completion:*' use-cache on +zstyle ':completion:*' cache-path ~/.zsh/cache +HISTFILE=~/.zsh_history +HISTSIZE=10000 +SAVEHIST=10000 +#export EDITOR=/usr/bin/nano +#export VISUAL=/usr/bin/nano +WORDCHARS=${WORDCHARS//\/[&.;]} # Don't consider certain characters part of the word + +autoload -U compinit colors zcalc +compinit -d +colors + +# Color man pages +export LESS_TERMCAP_mb=$'\E[01;32m' +export LESS_TERMCAP_md=$'\E[01;32m' +export LESS_TERMCAP_me=$'\E[0m' +export LESS_TERMCAP_se=$'\E[0m' +export LESS_TERMCAP_so=$'\E[01;47;34m' +export LESS_TERMCAP_ue=$'\E[0m' +export LESS_TERMCAP_us=$'\E[01;36m' +export LESS=-R + + +## Plugins section: Enable fish style features +# Use syntax highlighting +#source ${HOME}/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +# Use history substring search +#source ${HOME}/.zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh +# bind UP and DOWN arrow keys to history substring search +zmodload zsh/terminfo +bindkey "$terminfo[kcuu1]" history-substring-search-up +bindkey "$terminfo[kcud1]" history-substring-search-down +bindkey '^[[A' history-substring-search-up +bindkey '^[[B' history-substring-search-down + +bindkey -e +bindkey '^[[7~' beginning-of-line # Home key +bindkey '^[[H' beginning-of-line # Home key +if [[ "${terminfo[khome]}" != "" ]]; then + bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line +fi +bindkey '^[[8~' end-of-line # End key +bindkey '^[[F' end-of-line # End key +if [[ "${terminfo[kend]}" != "" ]]; then + bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line +fi +bindkey '^[[2~' overwrite-mode # Insert key +bindkey '^[[3~' delete-char # Delete key +bindkey '^[[C' forward-char # Right key +bindkey '^[[D' backward-char # Left key +bindkey '^[[5~' history-beginning-search-backward # Page up key +bindkey '^[[6~' history-beginning-search-forward # Page down key + +# Navigate words with ctrl+arrow keys +bindkey '^[Oc' forward-word # +bindkey '^[Od' backward-word # +bindkey '^[[1;5D' backward-word # +bindkey '^[[1;5C' forward-word # +bindkey '^H' backward-kill-word # delete previous word with ctrl+backspace +bindkey '^[[Z' undo # Shift+tab undo last action + + +source ~/.config/zsh/p10k.zsh +source ~/.config/zsh/p10k/powerlevel10k.zsh-theme +source ~/.config/zsh/antigen.zsh + +antigen bundle zsh-users/zsh-syntax-highlighting +antigen bundle zsh-users/zsh-history-substring-search +antigen apply |