From 8f4e94bc3e83a60fa7b5ef84ace88337e266cd96 Mon Sep 17 00:00:00 2001 From: Ambrose Chua Date: Fri, 10 Feb 2023 10:18:13 +0800 Subject: [PATCH] Add additional downloadable completions --- .config/zsh-completions/download.sh | 19 +++++++++++++++++++ .dockerignore | 4 ++++ .gitignore | 4 ++++ .zshrc | 22 ++++++++++++---------- 4 files changed, 39 insertions(+), 10 deletions(-) create mode 100755 .config/zsh-completions/download.sh diff --git a/.config/zsh-completions/download.sh b/.config/zsh-completions/download.sh new file mode 100755 index 0000000..7107117 --- /dev/null +++ b/.config/zsh-completions/download.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -eu + +wget \ + --output-document zsh-completions.tar.gz \ + https://github.com/zsh-users/zsh-completions/archive/refs/heads/master.tar.gz +tar -xzf zsh-completions.tar.gz \ + --strip-components=2 \ + zsh-completions-master/src +rm zsh-completions.tar.gz + +wget \ + --output-document _docker \ + https://github.com/docker/cli/raw/master/contrib/completion/zsh/_docker + +wget \ + --output-document _docker-compose \ + https://github.com/greymd/docker-zsh-completion/raw/master/repos/docker/compose/master/contrib/completion/zsh/_docker-compose diff --git a/.dockerignore b/.dockerignore index 7e35507..ec7ed0d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -44,6 +44,9 @@ !.config/wofi !.config/yabai !.config/yadm +!.config/zsh-completions +.config/zsh-completions/* +!.config/zsh-completions/download.sh .deno/bin .docker/.buildNodeID .docker/.token_seed* @@ -119,6 +122,7 @@ !.xkb .zcompdump .zoom +.zshrc-theme !.zshrc diff --git a/.gitignore b/.gitignore index 7d67803..1f6e3d3 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,9 @@ !.config/wofi !.config/yabai !.config/yadm +!.config/zsh-completions +.config/zsh-completions/* +!.config/zsh-completions/download.sh .deno/bin .docker/.buildNodeID .docker/.token_seed* @@ -119,4 +122,5 @@ !.xkb .zcompdump .zoom +.zshrc-theme !.zshrc diff --git a/.zshrc b/.zshrc index ae59b3e..e4ada10 100644 --- a/.zshrc +++ b/.zshrc @@ -46,10 +46,10 @@ sup() { prompt_run_count=0 on_second_prompt() { if [[ "$prompt_run_count" == 1 ]] && [[ "$USER" != "root" ]]; then - #zmodload zsh/zprof + zmodload zsh/zprof load_slower load_slowest - #zprof + zprof fi (( prompt_run_count = prompt_run_count + 1 )) } @@ -187,7 +187,6 @@ if [[ "$TERM" == "xterm-kitty" ]] && which kitty 2>&1 >/dev/null; then alias ssh="kitty +kitten ssh" fi setup_term_integration -#slower_functions+=( setup_term_integration ) # term fixes @@ -209,6 +208,9 @@ setup_completion() { autoload -Uz bashcompinit bashcompinit fi + # Add default completions + fpath+="$HOME/.config/zsh-completions" + # Style completions zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} zstyle ':completion:*' auto-description 'specify: %d' zstyle ':completion:*' completer _expand _complete _correct _approximate @@ -224,18 +226,19 @@ setup_completion() { zstyle ':completion:*' verbose true zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' -} -slower_functions+=( setup_completion ) -setup_completion_more() { - # Depends: - setup_completion - + # Setup fast apps if which mc 2>&1 >/dev/null; then complete -o nospace -C mc mc fi if which earthly 2>&1 >/dev/null; then complete -o nospace -C earthly earthly fi +} +slower_functions+=( setup_completion ) +setup_completion_more() { + # Depends: + setup_completion + if which kubectl 2>&1 >/dev/null; then source <(kubectl completion zsh) fi @@ -243,7 +246,6 @@ setup_completion_more() { [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" fi } -#slower_functions+=( setup_completion_more ) slowest_functions+=( setup_completion_more ) # color pagination