HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
scop
bash-completion
Shell2018–2026
scop / bash-completion

bash-completion

Programmable completion functions for bash

10Distinct people
11Mentions
0Explicit recommenders
3.5KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Programmable completion functions for bash

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 12:54:37 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year11 dated mentions

Observed mentions: 2018-04-30 21:48:11 UTC to 2026-03-01 17:31:37 UTC.

01232018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC202
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC202
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC303
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC000
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC000
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC101
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC202
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC110

What Hacker News says

11 sources
For CLIs - most reasonable commands either have a `-h`, `--help`, `-help`, `/?`, or what have you. And manpages exist. Hunt the verb isn't really a problem for CLIs. And furthermore - aren't there shells that will give you the --help if you try to tab-complete certain commands? Obviously there's the issue of a lack of standardization for how command-line switches work, but broadly speaking it's not difficult to have a list of common (or even uncommon) commands and how their args work. (spends a few minutes researching...) This project evidently exists, and I think it's even fairly well supported in e.g. Debian-based systems: https://github.com/scop/bash-completion.
In John Giannandrea to retire from Apple
I was referring to the bash-completion project, the default on Debian/Ubuntu - https://github.com/scop/bash-completion/ But yes, ble.sh also has a shell parser in shell, although it uses a state machine style that's more principled than bash regex / sed crap. --- Also, distro build systems like Alpine Linux and others tend to parse shell in shell (or with sed). They often need package metadata without executing package builds, so they do that by trying to parse shell. In YSH, you will be able to do that with reflection, basically like Lisp/Python/Ruby, rather than ad hoc parsing. --- I'm glad to hear you can see the effect of the optimizations ! That took a long time :-) Some more benchmarks here, which I'll write about: https://oils.pub/release/0.33.0/benchmarks.wwz/osh-runtime/
In Parsing JSON in Forty Lines of Awk
I have the same habit. The lack of tilde expansion after the equals sign has helped a bit in breaking this habit, however. Interestingly, bash does do tilde expansion, but not tab completion, after the first equal sign, and after every colon, in variable-style arguments: $ /bin/echo --foo=~ bar=~:~root --foo=~ bar=/home/jtm:/root While tab completion can be fixed in appropriate contexts using custom completion functions (e.g., [1]), AFAIK there's no way to customize tilde expansion contexts (other than the fact that tilde expanding variable-style arguments is disabled in POSIX mode). [1] https://github.com/scop/bash-completion/blob/8a8880db78e9b04...
In "Rules" that terminal programs follow
When you install bash-completion on your system, usually a function is defined to autocomplete make rules for you. It works with all projects, as it does not rely on the rules being specially marked. (https://github.com/scop/bash-completion/blob/master/completi...) Before I knew about it, I had written a similar thing: # Autocomplete make rules _make () { local cur prev words cword cmdline _init_completion || return # command to generate the rules words="$(make -pRrq |\ awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($1 !~ "^[#.]") {print $1}}' |\ sort | egrep -v -e '^[^[:alnum:]]' | xargs)" COMPREPLY+=( $( compgen -W "$words" -- $cur) ) } if declare -f _init_completion > /dev/null; then complete -F _make make fi It relies o
Read the rest
n `make -pRrq`, that is a very useful command to debug your makefiles, especially in a big project. The option `-p` prints the make data-base, -R and -r removes the implicit rules and variables, and -q indicates only asking make a question about current state, avoid executing anything. Well, it worked for a time, but the bash-completion one is nicer (though much, much more complex). Very nice however to know about `-pRrq`, definitely helps when working on big projects.
In How to list all the targets on a Makefile
These [0] two [1] sections of the GNU Bash man pages were very useful. I also found that this tutorial [2] provided a useful perspective. I spent a small amount of time looking through the bash-completion [3] project as well as the git bash completions [4]. Generally, my process for writing is google around until I have some base level of knowledge, then building one or more demo applications to ensure my understanding is correct. Then as I'm writing the blog post I'll be refining the demo applications into examples for the blog post and/or library code that I want to open source. [0]: https://www.gnu.org/software/bash/manual/html_node/Programma... [1]: https://www.gnu.org/software/bash/manual/html_node/Programma... [2]: https://hackaday.com/2018/01/19/linux-fu-custom-bash-command... [3]: https://github.com/scop/bash-completion [4]: https
Read the rest
In Shell Completions in Rust
I'm working in this area right now if you want to help :) http://www.oilshell.org/ I took a survey of what people use here: https://lobste.rs/s/z96uyr/survey_what_shell_completion_scri... That produced a link to this old project which tried to do something like what you want: a completion system that works for multiple shells (in this case, by code generation from a DSL) https://github.com/mbrubeck/compleat It's easy for you to say "completion should be specified in the binary" without actually specifying HOW. That's not straightforward, although I agree it's a good goal. ----- Right now I'm implementing a bash-compatible completion API, and I'm actually getting pretty far without too much code. git-completion.bash is 3000 lines of code, so it's actually easier to emulate bash (with all its warts) than to write an entirely new completio
Read the rest
n system AND THEN write 3000+ lines of git completion in that hypothetical system. https://github.com/oilshell/oil/issues/175 FWIW git is also the biggest completion script in the zsh source tree by a factor of 2 -- ~7000 lines IIRC with the next largest being around ~3000 lines. Eventually Oil should have something better than bash completion, but the first step is taking advantage of ~40K lines of existing code in the bash-completion [1] project. I also looked at emulating zsh but that would be a lot more work than emulating bash. [1] https://github.com/scop/bash-completion
In Creating a bash completion script

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.