Closed willemw12 closed 2 years ago
todo.sh
is still using the old /etc/bash_completion.d/
location; your quoted link mentions that as well:
The other directory which is only present for backwards compatibility, its usage is no longer recommended, is compatdir (get it with
pkg-config --variable=compatdir bash-completion
). From this directory, files are loaded eagerly whenbash_completion
is loaded.
Lazy loading sounds good; however, I think many users define an alias (as todo.sh
is too long to type, and I personally find that .sh
extension is a horrible leak of an implementation detail), and lazy loading would make that aliasing more difficult that just having the _todo
completion function already available.
alias tt='todo.sh'
complete -F _todo tt
I wouldn't mind switching to lazy loading if that doesn't negatively affect aliasing. Unless that is possible, I think it's better to stick with eager loading. Alternatively, we could try to arrive at a more generally-accepted default name (maybe plain todo
?), so that there's less need for shortening the default. But that's a big incompatible change, requiring lots of feedback from a rather inactive community.
Bash does not source the "todo" completion file on Arch Linux. Is that not the case on other systems/distros?
When make installs the completion file as "todo.sh" instead of "todo", is that not a non-breaking compatible fix for this issue?
If you want to move to command "todo", then make could create a symlink from "todo" to "todo.sh", if no other comparable project has that name already in use.
I've been using todo.sh
for such a long time that I've never actually used the Makefile for installing. The Linux install instructions mention that the default location for the completion is /etc/bash_completion.d/todo
, and as that is the legacy location with eager loading, the filename (todo
vs. todo.sh
) doesn't matter there.
You've been referring to the new completion location with lazy loading, and there the filename of the completion script has to be identical to the command's name (so todo.sh
) for the lazy loading to work.
If you want to use the Makefile
for that (with a custom BASH_COMPLETION=/usr/share/bash-completion/completions
), this line would need to have the .sh
extension appended. That's an inconsequential change to make, as the name doesn't matter in the legacy location that todo.sh
is still using.
I don't know how todo.sh
is installed on Arch Linux. Completion should work if they use the /etc/bash_completion.d/
location, but if they've switched to the new location without renaming the target file to todo.sh
, then yes it wouldn't work. But isn't that a bug in the Arch packaging? As mentioned, this project still recommends to use the legacy completion location, but we could adapt the Makefile to allow (Arch Linux) packagers to use it to create a package that targets the new lazy-load location. However, I would be prefer to switch to lazy loading for core todo.sh
as well, as long as the problems with aliasing that I've mentioned can be solved.
I am the packager (same name). To see how it is built: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=todotxt. I think I'll patch the makefile instead of calling mv
to rename the completion file. Tab-completion seems to work just fine.
Closing the issue. Thanks, it is a bit clearer now what is going on with installing the completion file.
The completion file "todo" is not source by bash. I had to renamed it to "todo.sh". See https://aur.archlinux.org/packages/todotxt.
The completion file has to be the same name as the executable. See https://github.com/scop/bash-completion: "completions are automatically loaded on demand based on invoked commands' names, so be sure to name your completion file accordingly". File "todo" is sourced by zsh's bash completion though.
Also, see https://github.com/scop/bash-completion and at least on Arch Linux: the recommended default completion directory is pkg-config's "completionsdir" (/usr/share/bash-completion/completions), not "compatdir" (/etc/bash_completion.d) as is mentioned on https://github.com/todotxt/todo.txt-cli.