I needed to get the fingerprint of a ssh key using:
$ ssh-keygen -lf ~/.ssh/id_rsa_user.pub
after typing:ssh-keygen -lf ~/.ss
TAB It was not giving any options.
I had to do:
$ compdef _files ssh-keygen
After that I was available to autocomplete using the files path, but the command autocomplete stop working, so if if I type ssh-keygen -
Tab I don't see any more this output:
$ ssh-keygen -
-- option --
-B -- show the bubblebabble digest of key
-C -- provide new comment
-D -- download key stored in smartcard reader
-N -- provide new passphrase
-P -- provide old passphrase
-U -- upload key to smartcard reader
-b -- specify number of bits in key
-c -- change comment in private and public key files
-e -- export key to SECSH file format
-f -- key file
-i -- import key to OpenSSH format
-l -- show fingerprint of key file
-p -- change passphrase of private key file
-q -- silence ssh-keygen
-t -- specify the type of the key to create
-y -- get public key from private key
So wondering if there is a way of having both options enabled so that I can do something like:
ssh-keyg
TAB that will give me:
$ ssh-keygen
Then I can do
$ ssh-keygen -
TAB
That would print the option menu and been available to do:
$ ssh-keygen -lf ~/.ss
TAB
And have list of options what could work so at the end I would get something like:
$ ssh-keygen -lf ~/.ssh/id_rsa_user.pub
For now I just add to my ~/.zshrc
this:
compdef _files ssh-keygen
compdef _files adb
compdef _files mysql
...
But I have to do that for avery command I want to use the _files completion, therefore I would like to know if there is a way to always use _files
or failover to it.
Any ideas?
Could it be possible to make it behave like csh
in where pressing Ctrl+d shows files options?
Update:
I notice that if I the last argument is an -f
the autocomplete works:
ssh-keygen -l -f ~/.ssh
TAB
But for custom scripts, commands what function, widget alias could help do force the _files
completion.?
The solution was to update to zsh
this is how I did it:
# check the zsh info
brew info zsh
# install zsh
brew install zsh
# add shell path
sudo vim /etc/shells
# add the following line into the very end of the file(/etc/shells)
/usr/local/bin/zsh
# change default shell
chsh -s /usr/local/bin/zsh
I had issues completing git-flow
this was fixed by reinstalling with --without-completions
:
$ brew install git --without-completions