What's the easiest way to add custom filename autocomplete behavior for a command?

4

2

I want to add some rudimentary filename completion for programs like ghc, ghci (Haskell compilers), lyx (typesetting program), namely that hitting [tab] after one of the above should offer autocomplete suggestions for files ending in ".hs" or ".lyx".

What's the easiest way to do this in zsh?

gatoatigrado

Posted 2011-06-12T21:58:20.150

Reputation: 1 075

Answers

4

compdef '_files -g "*.hs *.lyx"' ghc ghci lyx

See man zshcompsys | less -p '^\s*compdef \[' and generally man zshcompsys.

peth

Posted 2011-06-12T21:58:20.150

Reputation: 7 990

fantastic, thanks so much!! (The question was badly worded; I actually meant compdef '_files -g "*.hs"' ghc ghci; compdef '_files -g "*.lyx"' lyx) – gatoatigrado – 2011-06-13T17:27:30.063