zinit icon indicating copy to clipboard operation
zinit copied to clipboard

[bug]: docker compose completion does not work

Open Chucky2401 opened this issue 6 months ago • 0 comments

What happened?

I followed this video to begin with zsh and zinit: https://www.youtube.com/watch?v=ud7YxC33Z3w&pp=ygUDenNo. And this one to add more features: https://www.youtube.com/watch?v=mmqDYw9C30I. I would like to load the OMZ plugin docker-compose for docker compose completion but it doesn't work at all. I made my test on WSL2-Alpine, I tried on a Debian on a Raspberry Pi 5, and same results.

Steps to reproduce

  1. Load the docker-compose with OMZP: zinit snippet OMZP::docker-compose
  2. source ~/.zshrc
  3. Try with completions only: zi ice as"completion" zinit snippet OMZP::docker-compose/_docker-compose

Relevant output

with `zinit snippet OMZP::docker-compose`

Setting up snippet: OMZP::docker-compose
==> Downloading OMZP::docker-compose (with curl, wget, lftp)
##################################################################################################################################################################################################################################### 100.0%
==> Compiling OMZP::docker-compose [OK]


Or with
```shell
zi ice as"completion"
zinit snippet OMZP::docker-compose/_docker-compose`

```shell
Setting up snippet: OMZP::docker-compose/_docker-compose
==> Downloading OMZP::docker-compose/_docker-compose (with curl, wget, lftp)
##################################################################################################################################################################################################################################### 100.0%
==> Compiling _docker-compose [OK]
==> Installed 1 completion

but do docker compose <TAB> nothing happens

If a run zinit update I got this

Updating snippet: OMZP::docker-compose
==> Downloading OMZP::docker-compose (with Subversion)
Warning: Subversion not found , please install it to use `svn' ice.
.zinit-mirror-using-svn:12: command not found: svn
.zinit-mirror-using-svn:13: command not found: svn
==> Skipped re-installing 1 completion


### Screenshots and recordings

https://asciinema.org/a/VVxDomcIUTmM4tbKsQAxLLVhD

### Operating System & Version

OS: linux-musl | Vendor: alpine | Machine: x86_64 | CPU: x86_64 | Processor: unknown | Hardware: x86_64

### Zsh version

zsh 5.9 (x86_64-alpine-linux-musl)

### Terminal emulator

xterm-256color

### If using WSL on Windows, which version of WSL

WSL 2

### Additional context

Here all my .zshrc file
```shell
# Import functions
. ~/.local/share/sh/scripting_func

# Configuration
ZSH_NEXT_UPDATE="${XDG_DATA_HOME:-${HOME}/.local/share}/zsh/next_update"
ZINIT_INSTALL=0
FZF_INSTALL=0
FZF_GIT_INSTALL=0

if [ ! -f "$ZSH_NEXT_UPDATE" ]; then
        mkdir -p "$(dirname $ZSH_NEXT_UPDATE)"
        date -d "+10 days" +"%Y-%m-%dT%H-%M-%S%:z" > $ZSH_NEXT_UPDATE
fi

DATE_NEXT_UPDATE="$(cat $ZSH_NEXT_UPDATE)"
DATE_NOW_FORMAT="$(date +"%Y-%m-%dT%H-%M-%S%:z")"

# Set the directory we want to store zinit and plugins
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"

if cat /etc/group | grep -qw 'sudo'; then
        SUDO_GROUP="sudo"
fi

if cat /etc/group | grep -qw 'wheel'; then
        SUDO_GROUP="wheel"
fi

# Download Zinit, if it's not there yet
if [ ! -d "$ZINIT_HOME" ]; then
  message "Install Zinit"
        ZINIT_INSTALL=1
        mkdir -p "$(dirname $ZINIT_HOME)"
        git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi

# Set-up fzf with git if not Arch
if ! head -1 /etc/os-release | cut -d "=" -f 2 | grep -Eqw "Arch"; then
        # Set the directory for fzf
        FZF_HOME="${HOME}/.fzf"

        if [ ! -d "$FZF_HOME" ]; then
    message "Install fzf from Git repository"
    FZF_INSTALL=1
                git clone --depth 1 https://github.com/junegunn/fzf.git "$FZF_HOME"
                $FZF_HOME/install --key-bindings --completion --no-update-rc
        fi

        if [[ $FZF_INSTALL -eq 0 && "$DATE_NEXT_UPDATE" < "$DATE_NOW_FORMAT" ]]; then
    message "Update fzf from Git repository"
                nohup git -C "$FZF_HOME" fetch &> /dev/null ; git -C "$FZF_HOME" pull &> /dev/null ; $FZF_HOME/install --key-bindings --completion --no-update-rc &> /dev/null
        fi
fi

# fzf git
FZF_GIT_HOME="${HOME}/.fzf-git"

if [ ! -d "$FZF_GIT_HOME" ]; then
  message "Install fzf-git"
  FZF_GIT_INSTALL=1
        git clone https://github.com/junegunn/fzf-git.sh.git "$FZF_GIT_HOME"
fi

if [[ $FZF_GIT_INSTALL -eq 0 && "$DATE_NEXT_UPDATE" < "$DATE_NOW_FORMAT" ]]; then
  message "Update fzf-git"
        nohup git -C "$FZF_GIT_HOME" fetch &> /dev/null ; git -C "$FZF_GIT_HOME" pull &> /dev/null
fi

# Oh-my-posh
OMP_DIR="/usr/local/bin"
OMP_FULL_PATH="$OMP_DIR/oh-my-posh"
if [ ! -f "$OMP_FULL_PATH" ]; then
        #if groups "$USER" | grep -qw "$SUDO_GROUP"; then
  if have_sudo_access; then
      message "Install Oh-my-posh (which may request your password)..."
      execute_sudo "/bin/bash" "-c" "$(curl -s https://ohmyposh.dev/install.sh)" "-d" "$OMP_DIR"
        else
      message "You are not a member of '$SUDO_GROUP' group. You must install manually oh-my-posh with root permission."
      message "You have 2 solutions:"
      echo " - Use ${shell_bold_italic}su${shell_reset}: ${shell_underline}su -c \"\$(curl -s https://ohmyposh.dev/install.sh) -d ${OMP_DIR}${shell_reset}\""
      echo " - Be member of ${shell_bold_italic}${SUDO_GROUP}${shell_reset} and run: ${shell_underline}sudo /bin/bash -c \"\$(curl -s https://ohmyposh.dev/install.sh) -d ${OMP_DIR}\"${shell_reset}"
      #message "Here the command to use as ${shell_bold}root${shell_reset}: ${shell_underline}\$(curl -s https://ohmyposh.dev/install.sh) -d $OMP_DIR${shell_reset}"
            echo "Press ${shell_bold}any keys${shell_reset} to continue..." ; read dummy
        fi
fi

# Source/Load zinit
source "${ZINIT_HOME}/zinit.zsh"
if [[ $ZINIT_INSTALL -eq 0 && "$DATE_NEXT_UPDATE" < "$DATE_NOW_FORMAT" ]]; then
        message "Update Zinit"
        zinit self-update &> /dev/null
        zinit update &> /dev/null
        date -d "+10 days" +"%Y-%m-%dT%H-%M-%S" > $ZSH_NEXT_UPDATE
fi

# Add in zsh plugins
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
zinit light Aloxaf/fzf-tab

# Add in snippets
zinit snippet OMZP::git
zinit snippet OMZP::sudo
zinit snippet OMZP::command-not-found
# zinit wait lucid as"completion" for \
#   OMZP::docker/completions/_docker \
#   OMZP::docker-compose/_docker-compose
#
zi ice as"completion"
zinit snippet OMZP::docker/completions/_docker
zi ice as"completion"
zinit snippet OMZP::docker-compose/_docker-compose
# zi ice svn
# zinit snippet OMZP::docker-compose

# Load completions
autoload compinit && compinit
# zicompinit

zinit cdreplay -q

eval "$(oh-my-posh init zsh --config ~/.config/ohmyposh/mytheme.omp.json)"

# Keybindings
bindkey -e
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward
# Useless if PuTTy set with 'xterm' for Home and End keys
bindkey '^[[1~' beginning-of-line
bindkey '^[[4~' end-of-line
bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line
bindkey '^[[3~' delete-char
bindkey '^[[1;5D' backward-word
bindkey '^[[1;5C' forward-word

# History
HISTSIZE=5000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups

# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls $realpath'

# Set alias for Debian-based image distribution
if head -1 /etc/os-release | cut -d "=" -f 2 | grep -Eqw "Debian|Ubuntu"; then
  alias bat="batcat"
fi

alias ls="eza --group-directories-first -l --no-filesize --icons=always --no-time --no-user --no-permissions"

if [[ $(uname -m) = "aarch64" ]]; then
  alias ll="eza --group-directories-first -lgh --icons=always"
else
  alias ll="eza --group-directories-first -lgh --git --icons=always"
fi

alias la="ll -a"
alias susu="sudo su -"
alias vi="nvim"
alias lg="lazygit"

# Shell integrations
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
eval "$(fzf --zsh)"

# FZF customisation
if which fdfind > /dev/null; then
        FD_BINARY=$(which fdfind | rev | cut -d'/' -f 1 | rev)
else
        FD_BINARY=$(which fd | rev | cut -d'/' -f 1 | rev)
fi

# Use fd instead of find
export FZF_DEFAULT_COMMAND="$FD_BINARY --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="$FD_BINARY --type=d --hidden --strip-cwd-prefix --exclude .git"

_fzf_compgen_path() {
        "$FD_BINARY" --hidden --exclude .git . "$1"
}

_fzf_compgen_dir() {
        "$FD_BINARY" --type=d --hidden --exclude .git . "$1"
}

source ${FZF_GIT_HOME}/fzf-git.sh

# Preview with fzf
export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always --line-range :500 {}'"
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"

_fzf_comprun() {
        local command=$1
        shift

        case "$command" in
                cd)           fzf --preview 'eza --tree --color=always | head -200' "$@";;
                export|unset) fzf --preview "eval 'echo \$' {}" "$@";;
                ssh)          fzf --preview 'dig {}' "$@" ;;
                *)            fzf --preview "--preview 'bat -n --color=always --line-range :500 {}'" "$@" ;;
        esac
}

# If in WSL
if [[ $(uname -r) =~ "-microsoft-.+-WSL" ]]; then
  export GPG_TTY=$(tty)
fi

# Import ssh key
if ! ssh-add -l &> /dev/null; then
  eval $(ssh-agent) &> /dev/null
  ssh-add -k
fi

# Import custom functions
for script in ~/.local/share/sh/*.sh ; do
  if [ -r "$script" ] ; then
    . "$script"
  fi
done

unset script
unset ZSH_NEXT_UPDATE ZINIT_INSTALL FZF_INSTALL FZF_GIT_INSTALL
unset DATE_NEXT_UPDATE DATE_NOW_FORMAT
unset OMP_DIR OMP_FULL_PATH

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Chucky2401 avatar Aug 10 '24 19:08 Chucky2401