3

Context

  • zsh shell,
  • oh-my-zsh framework,
  • no special zsh's configuration (same problem with or without zsh-completions): see .zshrc at the end.

Trouble

If a directory contains:

  • a makefile with targets: hello, hello.o and main.o,
  • say, 3 files foo, bar and baz,

invoking make + TAB displays as completion:

bar baz foo hello hello.o main.o makefile

instead of only the makefile' s targets.

Question

How can I customize zsh in order it behaves as bash (which displays only the makefile' s targets) in this respect?

Configuration file

Here is my .zshrc:

export ZSH=/home/bitouze/.oh-my-zsh

ZSH_THEME="gnzh"

plugins=(git zsh-completions)
autoload -U compinit && compinit

source $ZSH/oh-my-zsh.sh

export LANG=fr_FR.UTF-8

source $HOME/.aliases

# texdoc completion
compctl -k "(($(grep ^name $(kpsewhich -var-value TEXMFROOT)/tlpkg/texlive.tlpdb | grep -v '\.' | awk '{print $2}' | tr '\n' ' ')))" texdoc

export ANDROID_HOME="/home/bitouze/Android/Sdk"
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

export JAVA_HOME=/usr/lib/jvm/jre


#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/home/bitouze/.sdkman"
[[ -s "/home/bitouze/.sdkman/bin/sdkman-init.sh" ]] && source "/home/bitouze/.sdkman/bin/sdkman-init.sh"
3

You can ask zsh to only display targets tag for make command completion with

zstyle ':completion:*:*:make:*' tag-order 'targets'

Add this somewhere after the line

autoload -U compinit && compinit
  • Works nicely! Strange this zstyle is not the default. – Denis Bitouzé Feb 7 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.