mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 12:23:22 +00:00
feat: add alias auto-detection to completion scripts
Bash, zsh, and PowerShell completion scripts now auto-detect aliases pointing to skillshare (e.g. alias ss=skillshare) and register completions for them. Also adds powershell/nushell to the shell options in all completion scripts.
This commit is contained in:
@@ -25,7 +25,7 @@ _skillshare() {
|
||||
local extras_subcmds="init list remove collect source mode"
|
||||
local backup_subcmds="restore"
|
||||
local audit_subcmds="rules"
|
||||
local completion_subcmds="bash zsh fish"
|
||||
local completion_subcmds="bash zsh fish powershell nushell"
|
||||
|
||||
# Per-command flags
|
||||
local init_flags="--source -s --remote --copy-from -c --no-copy --targets -t --all-targets --no-targets --mode -m --git --no-git --skill --no-skill --discover -d --select --subdir --dry-run -n --help -h"
|
||||
@@ -179,4 +179,12 @@ _skillshare() {
|
||||
}
|
||||
|
||||
complete -F _skillshare skillshare
|
||||
|
||||
# Auto-detect aliases pointing to skillshare and register completion for them
|
||||
if command -v alias >/dev/null 2>&1; then
|
||||
while IFS= read -r _ss_alias; do
|
||||
complete -F _skillshare "$_ss_alias"
|
||||
done < <(alias 2>/dev/null | sed -n "s/^alias \([^=]*\)=['\"].*skillshare['\"]$/\1/p")
|
||||
unset _ss_alias
|
||||
fi
|
||||
`
|
||||
|
||||
@@ -290,7 +290,7 @@ complete -c skillshare -n '__fish_skillshare_using_command analyze' -l json -d '
|
||||
complete -c skillshare -n '__fish_skillshare_using_command analyze' -l help -s h -d 'Show help'
|
||||
|
||||
# completion
|
||||
complete -c skillshare -n '__fish_skillshare_using_command completion' -a 'bash zsh fish' -d 'Shell type'
|
||||
complete -c skillshare -n '__fish_skillshare_using_command completion' -a 'bash zsh fish powershell nushell' -d 'Shell type'
|
||||
complete -c skillshare -n '__fish_skillshare_using_command completion' -l install -d 'Install completion script'
|
||||
complete -c skillshare -n '__fish_skillshare_using_command completion' -l help -s h -d 'Show help'
|
||||
`
|
||||
|
||||
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
const powershellCompletionScript = `# skillshare PowerShell completion
|
||||
|
||||
Register-ArgumentCompleter -Native -CommandName skillshare -ScriptBlock {
|
||||
$_skillshareCompleter = {
|
||||
param($wordToComplete, $commandAst, $cursorPosition)
|
||||
|
||||
$commands = @{
|
||||
@@ -147,4 +147,11 @@ Register-ArgumentCompleter -Native -CommandName skillshare -ScriptBlock {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Register-ArgumentCompleter -Native -CommandName skillshare -ScriptBlock $_skillshareCompleter
|
||||
|
||||
# Auto-detect aliases pointing to skillshare and register completion for them
|
||||
Get-Alias -ErrorAction SilentlyContinue | Where-Object { $_.Definition -eq 'skillshare' } | ForEach-Object {
|
||||
Register-ArgumentCompleter -Native -CommandName $_.Name -ScriptBlock $_skillshareCompleter
|
||||
}
|
||||
`
|
||||
|
||||
@@ -458,7 +458,7 @@ _skillshare() {
|
||||
;;
|
||||
completion)
|
||||
_arguments \
|
||||
'1:shell:(bash zsh fish)' \
|
||||
'1:shell:(bash zsh fish powershell nushell)' \
|
||||
'--install[Install completion script]' \
|
||||
'--help[Show help]' \
|
||||
'-h[Show help]'
|
||||
@@ -469,4 +469,12 @@ _skillshare() {
|
||||
}
|
||||
|
||||
_skillshare "$@"
|
||||
|
||||
# Auto-detect aliases and register completion for them
|
||||
() {
|
||||
local _ss_name
|
||||
for _ss_name in ${(k)aliases}; do
|
||||
[[ "${aliases[$_ss_name]}" == "skillshare" ]] && compdef _skillshare $_ss_name
|
||||
done
|
||||
}
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user