90

I want to learn how to write bash completion scripts. Which tutorial would you recommend?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
tshepang
  • 65,642
  • 2
    What do you mean by "bash completion tutorial"? Please explain. – Patkos Csaba Dec 10 '10 at 21:14
  • 1
    the explanation is needed on the word "tutorial", what do you actually need? – phunehehe Dec 11 '10 at 00:26
  • 2
    @Tshepang: I guess you mean you want to learn how to write bash completion routines? Using bash completion is pretty easy, you just hit the tab key. – intuited Dec 11 '10 at 04:45
  • 11
    You may want to check out the link I provide in my answer here: http://unix.stackexchange.com/questions/1800/custom-autocomplete – Steven D Dec 11 '10 at 05:45
  • so this will become a duplicate I guess – phunehehe Dec 11 '10 at 16:56
  • 2
    @Tshepang People don't generally delete comments, particularly ones that are still valid like Steven's. Keep in mind that the answers here aren't just for you -- they're for everyone who googles "bash completion tutorial" in the future – Michael Mrozek Dec 13 '10 at 15:28
  • 10
    How come this question is considered "too broad" ? That's ridiculous. It's perfectly valid, and answers provided prove it's not so easy to find out. – Cyan Mar 19 '15 at 00:02
  • The Advanced Bash-Scripting Guide is always a good starting point: http://www.tldp.org/LDP/abs/html/tabexpansion.html – ceving Dec 07 '15 at 11:24
  • Hi @terdon, since this question is rightfully closed, can a question this was flagged as a dupe of be reopened? http://unix.stackexchange.com/q/1800 is a good question, and should be reopened if this one is closed. – cat Apr 10 '16 at 14:00
  • 1
    @cat fair enough, done. – terdon Apr 11 '16 at 07:47
  • I recommend next: http://askubuntu.com/a/483149/24155 – Eduardo Cuomo Jun 24 '16 at 14:32
  • 1
    I wrote one, you can find it here: https://iridakos.com/tutorials/2018/03/01/bash-programmable-completion-tutorial.html – Lazarus Lazaridis Sep 28 '18 at 17:44

2 Answers2

60

There aren't that many bash completion tutorials around, but this one is pretty good:

Introduction to Bash Completion

  • Part 1 is for general knowledge
  • Part 2 covers creating scripts in /etc/bash_completion.d/
wag
  • 35,944
  • 12
  • 67
  • 51
22

I would start by looking at the library of bash completions already put together by the folks here:

http://bash-completion.alioth.debian.org/

They also have a mailing list:

http://lists.alioth.debian.org/mailman/listinfo/bash-completion-devel

Victor
  • 133