keybase / keybase-issues

A single repo for managing publicly recognized issues with the keybase client, installer, and website.
900 stars 37 forks source link

keybase client should support zsh completion #519

Open bgpugh opened 10 years ago

bgpugh commented 10 years ago

For feature parity with https://github.com/keybase/keybase-issues/issues/147 ;-)

emory commented 10 years ago

Isn't that entirely dependent upon the shell complete grammar? I mean, I can get why a bash user is confused and all. Is it important that keybase do this for us or can't we just create one and let people use it if they want?

i'll get it started:

 #compdef keybase
 #autoload

 # keybase zsh completion

 local -a _1st_arguments
 _1st_arguments=(
     'login:keybase login'
     'logout:keybase logout'
     'decrypt:decrypt message'
     'encrypt:encrypt message'
     'help:halp'
 )
ghost commented 10 years ago

With followingcommands from stackoverflow

autoload bashcompinit
bashcompinit
source /path/to/your/bash_completion_file

I was able to activate the bash-completion in zsh. Only thing not working is when it is trying to complete filenames or directories since zsh don't know what to make out of the _filedir helper function

rbirnie commented 9 years ago

I have a sweet spot in my heart for auto completion. Here ya go: oh-my-zsh-keybase

malgorithms commented 9 years ago

hey, nice to see keybase dir sign on the project. I was thinking no one was using that :-)

rbirnie commented 9 years ago

I saw keybase dir sign on the bash autocomplete script repo and thought "what a great idea" so included it in mine as well. Its a pretty neat feature, I'm sure I'll find other places to use it as well.

espoelstra commented 5 years ago

The upstream CLI library used in Keybase appears to support ZSH or Bash for completion. It should just require edits similar to the PR above be made to add the --generate-zsh-completion flag and enable it on all the commands.

blaggacao commented 4 years ago

Here is what I did, adapted from: https://github.com/urfave/cli/blob/master/autocomplete/zsh_autocomplete

       │ File: .oh-my-zsh/completions/_keybase
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ #compdef keybase
   2   │ 
   3   │ _cli_zsh_autocomplete() {
   4   │ 
   5   │   local -a opts
   6   │   local cur
   7   │   cur=${words[-1]}
   8   │   if [[ "$cur" == "-"* ]]; then
   9   │     opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)
       │ }")
  10   │   else
  11   │     opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
  12   │   fi
  13   │ 
  14   │   if [[ "${opts[1]}" != "" ]]; then
  15   │     _describe 'values' opts
  16   │   else
  17   │     _files
  18   │   fi
  19   │ 
  20   │   return
  21   │ }
  22   │ 
  23   │ compdef _cli_zsh_autocomplete keybase

I assume https://github.com/rbirnie/oh-my-zsh-keybase/blob/master/keybase/_keybase printout is nicer, though. But the above auto-updates...