Unix - Custom autocomplete functions

From NoskeWiki
Revision as of 17:06, 6 February 2019 by NoskeWiki (talk | contribs) (Created page with "==About== {{DaughterPage|mother=Unix}} Programmable completion is a powerful tool which allows you to type any string (say: "<i>myprintprogram</i>") and then if you hit...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

About

NOTE: This page is a daughter page of: Unix


Programmable completion is a powerful tool which allows you to type any string (say: "myprintprogram") and then if you hit [tab],[tab] (tab key twice) it will show you the options available (eg: "--printhtml --printtxt help").

Simle Completion Function in Bash

~/autocomplete_foo.sh:

#! /bin/csh
_foo()
{
  local cur=${COMP_WORDS[COMP_CWORD]}
  COMPREPLY=( $(compgen -W "alpha beta bar baz" -- $cur) )
}
complete -F _foo foo

Now test by typing:

$ ~/autocomplete_foo.sh
$ foo b[TAB][TAB]
  beta bar baz

Simle Completion Function in Zsh

This represents a page the author has not finished yet, but hopefully will finish soon! As a wiki I can't guarantee the accuracy on any of these pages, but pages with this logo I can almost certainly guarantee DO contain errors and/or big omissions.


Links