-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from timsschoen/master
Adding autocompletion for commands and while installing packages
- Loading branch information
Showing
7 changed files
with
236 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#/usr/bin/env bash | ||
_ughub_completions() | ||
{ | ||
local suggestions=$(ughub getcompletions ${COMP_WORDS[@]:1}) | ||
COMPREPLY=($(compgen -W "${suggestions[@]}" -- "${COMP_WORDS[-1]}")) | ||
} | ||
|
||
complete -F _ughub_completions ughub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function __fish_ughub_packages | ||
ughub list --namesonly | ||
end | ||
|
||
function __fish_ughub_installed_packages | ||
ughub list --namesonly --installed | ||
end | ||
|
||
set -l ughub_commands (ughub help --commands) | ||
for c in {$ughub_commands} | ||
complete -f -c ughub -n "not __fish_seen_subcommand_from $ughub_commands" -a $c -d (ughub help $c --short) | ||
complete -f -c ughub -n "__fish_seen_subcommand_from $c" -a "(ughub getcompletions $c)" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$scriptblock = { | ||
param($wordToComplete, $commandAst, $cursorPosition) | ||
|
||
$tokens = $commandAst.Extent.Text.Trim() -split ' ' | ||
$first, $rest = $tokens | ||
$completions = &"ughub" getcompletions $rest | ||
|
||
$completions | Where-Object {$_ -like "${wordToComplete}*"} | ForEach-Object { | ||
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | ||
} | ||
} | ||
|
||
Register-ArgumentCompleter -Native -CommandName ughub -ScriptBlock $scriptblock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.