-
Notifications
You must be signed in to change notification settings - Fork 82
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 autocompletion for sudo #145
Comments
Clink v1.3.13 added support for chaining parsers. Here is a simple argmatcher for sudo.lua clink.argmatcher('sudo'):chaincommand() |
Oh, cool, didn't know that. Thank you! |
It's easy to add a sudo completion script. But there are several different sudo implementations for Windows, and different ones have different flags. I'm exploring some options for what's the best way to add this. |
Requires Clink v1.3.40 to work fully properly.
Closing because it is fixed in the dev branch, and closing it helps me keep track of the remaining work for the next release (which will include the dev changes). |
It'd be nice to have it by default indeed. Thank you! |
* WIP [common] Adds basic wrapper for tables * WIP [common] Fixes tables wrapper to assign metatable correctly * WIP [common] Rework matchers using new table wrapper * Fix #103; show also remote branches in git merge. * Fix #117; .init.lua isn't loaded under some circumstances. The "." at the beginning of the ".init.lua" file name marks it as a hidden file in Linux and some sync programs. That can cause sync programs to not copy the file. Renaming to "!init.lua" resolves that problem, while still ensuring the script is loaded before any of the other completion scripts. * Fixing #117 requires a change in Cmder. So, for best compatibility, clink-completions will have both .init.lua and !init.lua files. * Explicitly add the completions directory. This enables newer Clink versions to load and use completions scripts on demand, even in Cmder (which manually loads clink-completions scripts, so Clink doesn't know about their script directory). * Fix #16; add curl completions. * Fix #145; add sudo argmatcher. Requires Clink v1.3.40 to work fully properly. * Rename to path_module so builtin path APIs are available. * Fix base git flags bleeding thru to commands. `git ls-files` doesn't have a linked argmatcher, so the `git` flags were bleeding into it. And etc for other commands. * Smarter completions for git add and git checkout. It's very unusual to add or checkout unchanged files. So `git add` uses `git status -uall` to generate file matches. And `git checkout` uses `git status -uno` to generate file matches. * Fix `hide=true` for linked argmatchers. * Fix #131; add winget completions. * Simplify help_parser unsupported short circuit. Return nothing, rather than returning an empty table. This makes it easier for a caller to recognize it's not supported. * matchers.ext_files improvements. - It uses new APIs when available. - It accepts a list of wildcards and adds them all at once, which makes adding directories much more efficient (only one time). * Add comments for some matchers module exports. * Add some common argmatchers. * Add robocopy argmatcher. * Some explicit version checks, just in case. * Add premake5 argmatcher. * Add msbuild argmatcher. * Add argmatchers for GNU grep and sed. * Better capitalization function in robocopy argmatcher. * Add adb/fastboot/scrcopy argmatchers. * Fix typo in winget complete position. * Fix #76; better display of yarn run completions. This colors the yarn run matches. In old Clink versions, it has no effect. * Fix `yarn` completions. While improving `yarn run` completions, `yarn` completions lost the `run` matches. Also, apply color to yarn local module matches, to differentiate them from yarn commands. * Clean luacheck warnings. * Fix typo in yarn run completions. * Fix some back-compat issues for v0.4.9. * Tell luacheck about another Clink API.
I made a native C++ I'll extend the |
Nice! Do you plan on making it available through Scoop? |
Anyone can make it available through scoop. I can take a look, though. However, since scoop uses batch script shims (I don't understand why), the way that batch script parse command lines can interfere with some command lines (for example, commas or equal signs or quotes etc). So that will sometimes interfere with usage of sudo. |
There's another complication -- x86 versus x64 (and eventually arm64). Dealing with complexities of automatic multi-platform support on the same machine is something that involves a bunch of extra complexity (x64 machines should use x64 or x86 depending on the current context). I suppose I could publish scoop for only x64 or for only x86, but either of those will malfunction in subtle ways in some cases on x64 machines, and x64 won't work at all on x86 machines. So, making it available through scoop really involves solving other things as well. Eventually, perhaps. |
Cool, thanks for the explanation. |
It looks like scoop has a way to allow installing x64 or x86 depending on the machine architecture. Not a perfect solution, but good enough. |
gsudo is another sudo for Windows. There are pros/cons between gsudo and the sudo-windows I published, but I'm quite happy to let gsudo be the preferred sudo for Windows, and gsudo is already on Scoop. So I will not add sudo-windows to Scoop. And I've added |
It would be nice to have completions for sudo - it's a PowerShell script somewhat mimicking what
sudo
does on UNIX-like systems (shows UAC prompt if you have that set up, but executes commands as admin without a prompt if the UAC prompt is disabled - so it's handy for executing commands in place with elevated privileges without having to open the shell in an elevated window).Functionally I see this done in a pass-through approach of some way; any suggestions shown after
sudo
should function the same way as if nosudo
was entered. I can't think of any edge cases.Way to reproduce:
sudo scoop update autohotkey
Expected result: after entering
sudo scoop u
, suggestions should kick in and showupdate
(the same way as when you enter justscoop u
); same thing for other commands supported by completions.Actual result: entering
sudo scoop u
, theu
gets expanded into subdirectories starting with "u" that happen to be in the CWD but not into theupdate
subcommand ofscoop
.The text was updated successfully, but these errors were encountered: