Search code examples
zsh-completion

How can I get zsh to inherit the complete autocompletion?


I have an little shell script (named "run") which redirects all output of a program to /dev/null:

#!/bin/bash
$@ &> /dev/null &
disown +

How can I say zsh that the whole autocompletion shall work for this?

I mean

$ run git com<TAB>

autocomplete to

$ run git commit

Solution

  • I was able to make that work by adding:

    compdef _command run
    

    to my .zshrc file.

    I've based my answer on this bash question. It was worth giving it a try with compdef - surprisingly it worked. As I'm still zsh/autocompletion newbie I cannot explain the inner workings and you should probably go through the documentation or other sources to find more on the topic.