Skip to content
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

Merged
merged 4 commits into from Feb 14, 2019
Merged

zsh auto completion #1292

merged 4 commits into from Feb 14, 2019

Conversation

trevorlinton
Copy link
Contributor

No description provided.

Copy link
Member

@bcoe bcoe left a 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.

@@ -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
Copy link
Member

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.

Copy link
Contributor Author

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[@]\}"))
Copy link
Member

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.

Copy link
Contributor Author

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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach 👍

@bcoe bcoe requested a review from aorinevo February 12, 2019 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants