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
zsh auto completion #1292
zsh auto completion #1292
Conversation
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 is looking great to me 👍 one minor correction.
lib/completion.js
Outdated
@@ -79,8 +79,10 @@ module.exports = function completion (yargs, usage, command) { | |||
|
|||
// generate the completion script to add to your .bashrc. | |||
self.generateCompletionScript = function generateCompletionScript ($0, cmd) { | |||
let zshShell = process.env.SHELL && process.env.SHELL.indexOf('zsh') !== -1 |
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.
I believe this could be const
and not let
.
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.
fixed.
{ | ||
local reply | ||
local si=$IFS | ||
IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "$\{words[@]\}")) |
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.
interesting, at the end of the day this isn't too far off bash completion.
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.
yeah, not to much of a difference really.
@@ -196,10 +196,21 @@ describe('Completion', () => { | |||
}) | |||
|
|||
describe('generateCompletionScript()', () => { | |||
it('replaces application variable with $0 in script', () => { | |||
it('replaces application variable with $0 in script (bash)', () => { | |||
process.env.SHELL = '/bin/bash' |
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.
I like this approach 👍
No description provided.