-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic tab completion support for Bash and Zsh (II) #432
Conversation
Any comment? I see that some PRs are merged so I assume that this PR was overlooked? This PR seems trivial enough to review. |
This Pull Request should be straightforward to review. Please give it another shot. |
Hello! Is this going to be reviewed? I came here searching for "chruby bash completion" |
Thanks for reminding me. I think we can rebase this and merge it into the 0.4.0 branch. |
I manually rebased the commit against the 0.4.0 branch and merged it locally. I am just curious why we can't install the completion files in the |
I think it makes sense to include them in standard I haven’t made up my mind though. It does sound better to the community if each distribution doesn’t have to write it separately. Any suggestions? Would it be useful, for example, to have a Make target called |
By the way, I should have used so I think having a |
@FranklinYu I think we could auto-detect the bash completion directory in the The traditional way to handle OS specific directories would be to create a I checked Fedora's bash completion setup and they do have a I rebased and merged your branch into 0.4.0 branch, but haven;t pushed it yet. You could push another commit(s) to your branch and I could cherry-pick those in as well. |
Sorry, you are totally correct. I was under the impression that they put completions under Fedora and Arch Linux don’t provide the shim, so user would directly source the real file. I think the above covers Debian family (including Ubuntu) and Fedora family, so it should be good enough. From my understanding of Linux filesystem structure, I actually prefer the “better detection strategy” you mentioned, because the file belongs to part of the package, while files in A follow-up questions: now that we detect whether the directory exist, there are many ways to do conditionals:
Option 1 allows user to override the |
@FranklinYu I would imagine that a simple |
If it's possible to have separate auto-completions installation task – that will be wonderful for Gentoo ebuilds (zsh-autocompletions and bash-autocompletions are global USE flags, so completions would be installed for users asking for those). If not, then I will have to copy relevant installation instructions from Makefile to ebuild :D |
@ixti I’m happy to learn how Gentoo handles completions. Does Gentoo prefer a single Make target like |
@postmodern Thinking about it again, I’m concerned that Create 3 different installation target: This at least covers Debian family, Red Hat family, Arch Linux family, Gentoo family (according to the discussion above), and MacPorts. I also verified that it works with Alpine Linux (which is consistent with other Linux distributions). BTW I’m pushing the commit for Zsh since it’s less messy than Bash. I don’t have a chance to verify it on the SUSE family or the Slackware family. |
Here's current ebuild I maintain: https://github.com/gentoo/guru/blob/master/dev-ruby/chruby/chruby-0.3.9-r3.ebuild If/when chruby will have src_install() {
local emakeargs=(
DESTDIR="$D"
PREFIX="${D}/usr"
)
emake "${emakeargs[@]}" install
use zsh-completion && emake "${emakeargs[@]}" install-zsh-completion
use bash-completion && emake "${emakeargs[@]}" install-bash-completion
insinto "/etc/profile.d"
newins "${FILESDIR}/systemwide.sh" "chruby.sh"
} |
Thanks. Then it favors my proposal in #432 (comment). By the way, I did some research and found this: install -Dvm0644 completions/bash/yt-dlp "$b/%_datadir/bash-completion/completions/yt-dlp" from the |
In fact, for Gentoo ebuild most likely I will go a bit different direction (won't need make task): use bash-completion && newbashcomp "path/to/bash-completions" "${PN}"
use zsh-completion && {
insinto /usr/share/zsh/site-functions
newins "path/to/zsh-completion" "_${PN}"
} |
Just figured out Gentoo policy on small files: https://projects.gentoo.org/qa/policy-guide/installed-files.html#pg0301 Thus, in the ebuild I will install those unconditionally: newbashcomp "path/to/bash-completions" "${PN}"
insinto /usr/share/zsh/site-functions
newins "path/to/zsh-completion" "_${PN}" |
This seems reasonable. Zsh users would probably not want Bash completion rules to be installed, and Bash users would probably not care about Zsh completion rules. Having separate installation tasks and allowing the user (or package build script) to pick which additional installation tasks to run seems reasonable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency there should also be a install-bash-completion
target.
Additionally, you could skip installing zsh or bash completion rules if zsh
/bash
cannot be found (ex: command -v zsh && ...
).
We could also move the completion files into a separate |
I like the idea, but I’m thinking about a directory name other than
What do you think? |
After this change, the `install` target will skip them, since they should be installed separately.
I went with the third option. Please let me know if you prefer otherwise. |
I don't have a strong preference, but WDYT about:
That would make Makefile look a bit nicer too: install-bash-completion:
mkdir -p $(bash_comp_dir)
cp completions/bash/chruby $(bash_comp_dir)
install-zsh-completion:
mkdir -p $(zsh_comp_dir)
cp completions/zsh/_chruby $(zsh_comp_dir) And in homebrew formulae: zsh_completion.install 'completions/zsh/_chruby'
bash_completion.install 'completions/bash/chruby' |
I was randomly searching around on GitHub trying to figure out if there was a defacto standard. I found the following directories:
Since there's no clear winner, I will accept |
For Zsh completion, I found that some distributions (notably Debian) actually prefers
Do we want to follow this instead? |
IMO we better don't. :D |
Manually squash merged into the 0.4.0 branch (see e175d19). Thank you for your |
For posterity: indeed the default directory is https://github.com/zsh-users/zsh/blob/master/configure.ac#L308-L315 Homebrew, MacPorts, Fedora, Arch Linux, and Alpine Linux preserve this default behavior. Debian, in contrast, sets it to https://salsa.debian.org/debian/zsh/-/blob/dc50ace5801fc79114993a0d9fb26fc674aa33e4/debian/rules#L35 The change was introduced in 2011. |
This is a continuation of @callahad's work. Homebrew formula and Fedora package should put those two files in correct location such that user don’t need to explicitly source them (especially Zsh).
Closes #297.
Fixes #27.