-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Auto-complete xxh host name from ssh config #82
Comments
The auto-complete is depend on the shell and OS you use. But some shells like xonsh can get the completions from bash as well. In Ubuntu 20.04 I just added the same completion as ssh to bash and it works in xonsh the same way:
After relogin:
The best way to solve it is to understand how your shell and OS works with auto-complete, get the ssh default auto-complete and post here the solution for xxh. As I did for Ubuntu. |
My current setup is Mac OS & zsh shell - any idea how I can add custom completion of hosts for xxh locally? |
Also, can you guide me on how I can contribute this auto-completion as something that works out-of-the-box automatically upon installing xxh? |
Sorry I'm not the user of zsh and MacOS.
Good question. I have no answer now. |
This could be easily achieved by adding the following config: #compdef xxh
_xxh() {
service=ssh _ssh $@
}
_xxh Put this file to somewhere your environment autoloads, which you can check |
@chitoku-k for what OS and shell type your solution? |
@anki-code This solution only works for Zsh as it has built-in support for SSH completion (probably for any OS, at least it works in macOS and Linux). |
@chitoku-k If you can write the complete script to install xxh autocomplete for zsh it will be great! Something like this on bash or zsh: #!/bin/bash
mkdir -p ~/.config/xxh/
echo ' ... compef xxh ... ' > ~/.config/xxh/autocomplete-zsh
echo 'source ~/.config/xxh/autocomplete-zsh' >> ~/.zshrc
echo 'Please restart zsh' And place it to the repo to |
@anki-code For homebrew, it has built-in support for installing package-specific completion script described in Homebrew Shell Completion, which is quite handy if we can enable it in installation steps. I can somehow contribute to this. |
@athityakumar @chitoku-k Are you using argcomplete or alternatives? One of the way is to add it to xxh. |
@anki-code I am not quite familiar with that. Presumably we got to integrate with the existing completion for ssh command at least. |
If you want hosts completion from ssh config file when using fish add this to your ~/.config/fish/config.fish file: read -alz -d \n contents <~/.ssh/config
set hosts (string replace -rfi '^\s*Host\s+(\S.*?)\s*$' '$1' -- $contents | string split " " | string match -rv '[\*\?]' | string join ' ')
complete -c xxh -f -a $hosts this is a simplified version of what fish completions for ssh. you can see the source here |
xxh has been awesome so far with it's core functionality - but I need to type in the exact host names from ssh config as of now. Is it possible to auto-complete this with TAB-key support?
🏅 Solutions:
➡️ Bash and Xonsh on Ubuntu - #82 (comment)
➡️ Zsh - #82 (comment)
➡️ Fish - #82 (comment)
For community:
⬇️ Please click the 👍 reaction instead of leaving a
+1
or 👍 commentThe text was updated successfully, but these errors were encountered: