-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Refactor completion for defaults
command
#1928
Conversation
I've just noticed that using |
1f81b92
to
70ee0ac
Compare
70ee0ac
to
8444bb7
Compare
defaults
commanddefaults
command
8444bb7
to
ca05f34
Compare
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.
This looks like a legit effort to re-work the completion, and @gaelicWizard seems to be pretty invested it. So I'm guessing they use it regularly?
However: Regarding the use of =~ ${cmds// /|}
:
With cmds
being array, this simply does not work. ${cmds}
simply resolves to read
(i.e the first element in the array) - Its the default behavior in bash when referencing an array like a scalar.
I'm happy with the value being an array, but I suggest to use the _bash-it-array-contains-element
method that we added for this purpose.
Additionally, if you decide to revert the usage of an array:
- if its going to use regex (
=~
) to match, then per my previous comment you must anchor your values:
anchor with ^( and )$
=~ ^(${cmds// /|})$
This ensures that only fully matching words will match.
- Additionally as mentioned, this works:
== @(${cmds// /|})
This is the technique I would probably go for if I didn't already have _bash-it-array-contains-element
Lastly:
Per discussion in #1924 , if jmah does decide to re-take ownership of the completion, I'm inclined to let them have it (it its original form), vendor it back into bash-it, and submit bug fixes upstream.
Definitely. |
I converted it to an array after that and...oops. I was fighting with a different part of it and ended up making lots of arrays instead of wordplitting. Back to the drawing board! |
ca05f34
to
1812dd2
Compare
We specifically want to match partial words; this is a completion handler! 😜
I had not thought to use I've just reverted the change to making it an array and tested everything myself again. I think I need to write some BATS testing for this. Like I said before, completions are a new area of scripting to me. so many edge cases! Thanks for helping me with this @davidpfarrell!
I've never seen this syntax before;
This is literally how I learned Bash It existed 😆 |
It's part of |
I simply cannot make this work with any form of What am I missing? |
1812dd2
to
35fe436
Compare
Ok, this branch is working as-is and ready for merge, using The version using @davidpfarrell, can we require |
83b3ca1
to
91a6c18
Compare
Mwahahaha! It's all over now! I've learned BATS! I'm unstoppable!! Mwahahahahahah!! 🤣🤪 Alsö, I totally just checked in a failing test to my previously-passing PR so...good job me. Anyway, should have that one fixed shortly. |
9f9e3f3
to
e7597b6
Compare
Hmm, did you already create a repo for the defaults completion? I'll try to vendor it myself 😄 |
I dont see any repo that you opened @gaelicWizard, so let me know when you open one! |
@NoahGorny, I've just put up https://github.com/gaelicWizard/bash-progcomp and tagged v2.0.0. I'll do a v2.0.1 and probably a v2.0.2 as I expand the BATS tests. |
Either way, I figured out the benefits of @buhl's fork! I can amend commits! So, easy enough to just |
0502b06
to
9ea6002
Compare
I did not close this. @NoahGorny? |
Are you sure? |
Yeah, it says I did, but I wasn't able to re-open it then...but now I am...!! 🙃 |
Sorry, I just realized that sounded like I was accusing you. I wasn't! I was asking you to help ♥ |
238ec88
to
31cf790
Compare
Pulling things like this out of bash-it makes them more accessible to the community. You are definitely the best person to own this particular completion - Makes me feel bad I don't use Nice work ! |
Hi @gaelicWizard, let me know if you need any help with the vendoring process- you rock 😃 |
e07d1d8
to
cb80d65
Compare
@NoahGorny, I'm giving up on
On a freshly cloned repo, this tells me
and then leaves me with a merge conflict and a dirty tree. Halp?! |
Upon googling the error, It looks like the Maybe the internal git handler for the vendor action is invoking that? You can install a gnu version of mv using with brew (see I've done this on my mac. The package actually installs the binaries with names like There's also instructions on using them as the native names en-mass:
Confirmed the
NOTE: The bash-it git aliases also have a What I did (just now): I maintain my own I did:
Now just mv is configured to use the gnu version. Hope that helps! |
Thanks to @davidpfarrell, I just edited the git-vendor script to use a more normal syntax and now it works! It doesn't handle files starting with periods, but that was easy enough to hack around. |
7d0d348
to
a60abc0
Compare
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.
Best I can tell, this seems baked and ready to go.
/side note:
I'm not up to speed on our vendoring procedures, but is it our practice to vendor an entire repo? i.e instead of just the file(s) we need for execution + LICENSE ?
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.
Hi @gaelicWizard
Please rebase, and then we can merge this 😄
…omp@v2.0.1" git-vendor-name: bash-progcomp git-vendor-dir: vendor/github.com/gaelicWizard/bash-progcomp git-vendor-repository: https://github.com/gaelicWizard/bash-progcomp git-vendor-ref: v2.0.1
a60abc0
to
6a41dbc
Compare
Rebased and ready to go 👍 |
Description
I accidentally rewrote the completion functions for the Mac OS X
defaults
command. This version is case-insensitive for all completions, uses$IFS
to allow for spaces in domain and value names, and works for all my ad hoc testing.Motivation and Context
This was an offshoot from another issue and PR and I ended up down the rabbit hole. But now I know way more about Bash's programmable completion!
The goal was to allow case-insensitive completion of domain names, for which an existing PR was pending. That PR had some weirds in it and ended up not actually achieving its goal, so I accidentally fixed it.
How Has This Been Tested?
Tested locally, and all tests pass.
Types of changes
Checklist:
clean_files.txt
and formatted it usinglint_clean_files.sh
.