-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Completions don't work with ntl
alias on zsh
#6940
Comments
It appears that the reason for this is that shell completions are command-specific and do not automatically propagate to aliases without explicit configuration in either the completion script or the shell configuration. Either of these fix the issue in zsh:
###-begin-netlify-completion-###
if type compdef &>/dev/null; then
_netlify_completion () {
local reply
local si=$IFS
IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" /Users/ben/.nvm/versions/node/v21.6.2/lib/node_modules/netlify-cli/dist/lib/completion/script.js completion -- "${words[@]}"))
IFS=$si
_describe 'values' reply
}
compdef _netlify_completion netlify ntl # Add `ntl` here <----------------
fi
###-end-netlify-completion-###
# rest of zsh/bash/fish config ...
compdef ntl=netlify |
It doesn't look like However, we can write the completion script to add the This logic would work for zsh: // ... completion script installation
const completionScriptPath = join(homedir(), `.config/tabtab/${parent.name()}.zsh`)
if (fs.existsSync(completionScriptPath)) {
let completionScript = fs.readFileSync(completionScriptPath, 'utf8')
completionScript = completionScript.replace(
/compdef _netlify_completion netlify/,
'compdef _netlify_completion netlify ntl',
)
fs.writeFileSync(completionScriptPath, completionScript, 'utf8')
log(`Added alias 'ntl' to completion script.`)
}
// ... rest of file One problem with this approach is that it would require separate logic for zsh, bash, and fish, since they each have different mechanisms for defining completions |
ntl
aliasntl
alias on zsh
@benhancock It seems like this isn't done automatically? I reinstalled both completions as well as Sorry if I'm doing something wrong here, not super familiar with this stuff... |
@alexschcom That’s interesting! The script isn’t supposed to add
If it does contain If it doesn't contain |
Nope, unfortunately not... ###-begin-netlify-completion-###
if type compdef &>/dev/null; then
_netlify_completion () {
local reply
local si=$IFS
IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" /opt/homebrew/lib/node_modules/netlify-cli/dist/lib/completion/script.js completion -- "${words[@]}"))
IFS=$si
_describe 'values' reply
}
compdef _netlify_completion netlify ntl
fi
###-end-netlify-completion-### |
Describe the bug
Completions work with the
netlify
command, but not with thentl
alias. Trying to use tab withntl
does not produce any completions.Thanks to @alexschcom for pointing this issue out
Steps to reproduce
completion:install
for zshnetlify bl
and presstab
. This should autocomplete tonetlify blobs
ntl bl
and presstab
. This does not autocompleteConfiguration
No response
Environment
System:
OS: macOS 15.0
CPU: (8) arm64 Apple M2
Memory: 91.16 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.6.2 - ~/.nvm/versions/node/v21.6.2/bin/node
Yarn: 1.22.21 - ~/.nvm/versions/node/v21.6.2/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v21.6.2/bin/npm
pnpm: 9.12.0 - ~/.nvm/versions/node/v21.6.2/bin/pnpm
npmGlobalPackages:
netlify-cli: 17.37.2
The text was updated successfully, but these errors were encountered: