Skip to content
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 bash completion #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

lucasew
Copy link

@lucasew lucasew commented Sep 11, 2023

I use bash as my daily driver shell and missed the completions so I tried making one.

It doesn't show the descriptions of the commands but lists them already.

This is my first time hacking around completions tho.

@ianthehenry
Copy link
Owner

Hey neat thanks! I’m on vacation this week but I’ll take a look when I get back.

lucasew added a commit to lucasew/nixcfg that referenced this pull request Sep 12, 2023
Signed-off-by: lucasew <[email protected]>
@ianthehenry
Copy link
Owner

Hey! Okay sorry I completely forgot to look at this when I got back from vacation.

I tried to test this with the extremely old version of bash that ships with macOS and found that it didn't work. The error I get is:

$ sd <TAB> bash: [: -v: unary operator expected
realpath: : No such file or directory
bash: COMP_WORDS: bad array subscript

Specifically that's:

$ bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin22)
Copyright (C) 2007 Free Software Foundation, Inc.

Although the error here appears to be from /bin/[. I suspect this is just a difference between BSD test and GNU coreutils test? By replacing [] checks with [[ ]] checks we can remove the dependence on the rest of the system and keep things in pure bash. It looks like that [] construct does work on Linux with a newer bash.

Slightly unrelated but I would replace the ls | while read with a glob expansion? I'm not sure if there's a difference that I'm not seeing but a glob seems more natural.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants