0

我需要使用以下方法获取 ssh 密钥的指纹:

$ ssh-keygen -lf ~/.ssh/id_rsa_user.pub

键入后:ssh-keygen -lf ~/.ss TAB它没有提供任何选项。

我必须做:

$ compdef _files ssh-keygen

之后,我可以使用文件路径自动完成,但命令自动完成停止工作,所以如果我输入,ssh-keygen - Tab我不会再看到这个输出:

$ 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

所以想知道是否有一种方法可以启用这两个选项,以便我可以执行以下操作:

ssh-keyg TAB这会给我:

$ ssh-keygen

那我可以做

$ ssh-keygen - TAB

这将打印选项菜单并可以执行以下操作:

$ ssh-keygen -lf ~/.ss TAB

并列出可以工作的选项列表,所以最后我会得到类似的东西:

$ ssh-keygen -lf ~/.ssh/id_rsa_user.pub

现在我只是添加到我的~/.zshrc这个:

compdef _files ssh-keygen
compdef _files adb
compdef _files mysql
...

但是我必须为要使用 _files 完成的 avery 命令执行此操作,因此我想知道是否有办法始终使用_files或故障转移到它。

有任何想法吗?

有没有可能让它表现得像cshCtrl+d显示文件选项的地方一样?

更新:

我注意到如果我最后一个参数是-f自动完成工作:

ssh-keygen -l -f ~/.sshTAB

但是对于自定义脚本,命令什么功能,小部件别名可以帮助强制_files完成。?

4

1 回答 1

0

解决方案是更新到zsh这就是我的做法:

# 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

git-flow通过重新安装解决了这个问题--without-completions

$ brew install git --without-completions
于 2016-04-19T08:54:27.633 回答