sunlei / zsh-ssh Goto Github PK
View Code? Open in Web Editor NEWBetter host completion for ssh in Zsh.
License: MIT License
Better host completion for ssh in Zsh.
License: MIT License
@sunlei I found an edge case where autocompletion doesn't work if there is an Include path with wildcards but no matches are found.
My use case is that I have another python tool to create / delete VMs and when created, an ssh_config file is generated per project in the tool's directory, so something like:
Include ~/tools/overlord/projects/*/ssh_configs/*
However, if I have no current projects then I get errors when I try to autocomplete because no matches are found for the above wildcard.
I think I found a fix which is to include the following in _parse_config_file by adding the following:
# disable no match errors for Include with wildcard statements that don't have matches
unsetopt nomatch
This temporarily disables the error message from the attempt at glob expansion and proceeds to auto-complete based on the rest of the SSH config.
I thought it's too trivial to submit a PR so I'm just mentioning it here. On older versions of this plugin (not sure which ones), this wasn't a problem.
Originally posted by @s3nn in #11 (comment)
Hi and thanks for your very nice zsh
plugin.
I had issues insalling it on my 2021 Macbook Pro (M1 Max, Ventura 13.6.2)
After install, Auto complete failed with this error message
❯ ssh _parse_config_file:6: failed to load module `zsh/pcre': dlopen(/usr/lib/zsh/5.9/zsh/pcre.so, 0x0009): tried: '/usr/lib/zsh/5.9/zsh/pcre.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/zsh/5.9/zsh/pcre.so' (no such file), '/usr/lib/zsh/5.9/zsh/pcre.so' (no such file, not in dyld cache)
_parse_config_file:6: -pcre-match not available for regex
ssh
Thanks to some google I was able to find a similar issue / fix: zthxxx/jovial#12
Long story short: System installed zsh
(/bin/zsh
) does not include pcre
I was able to fix by using zsh
from brew
. You need to do the following commands
brew reinstall zsh
brew reinstall pcre pcre2
sudo chsh -s `/opt/homebrew/bin/zsh` $USER
(launch new terminal and you should be good)
i using autocomplete plugin and when i try press space after ssh command i have this error:
fzf-complete-ssh:24: command not found: fzf
Hi,
It would be nice to include all the ssh known_hosts in the listing like the bash completion is doing :-)
Cheers
Hi,
I noticed that sed
on MacOS doesn't have the flag -s
.
This causes https://github.com/sunlei/zsh-ssh/blob/master/zsh-ssh.zsh#L24 (include files) not to work.
It works when installing gsed
and
GNU "sed" has been installed as "gsed".
If you need to use it as "sed", you can add a "gnubin" directory
to your PATH from your bashrc like:
PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
which will use gnu sed.
Is it possible to have the plugin evaluate ssh host definitions defined in the config.d subdirectory.
[~/.ssh/config file]
include config.d/*
[~/.ssh/config.d file listing]
include1
include2
...
Hello,
thanks for the plugin works great with SSH, but lately I found myself having to use quiet a lot of SCP and it would be great to have the same autocomplete for SCP.
The issue I see is, that the hostname can be in two places
Using nix and home-manager to manage the SSH config file at ~/.ssh/config
, which is a symbolic link to a path on a seperate mountpoint, generates a config which does not add a new line between hosts, this seems to break the completion. No widget appears, using a minimal "ssh/config" and "zshrc" andinstalling zsh-ssh
manually.
macOS 10.12 ARM
zsh 5.9
Broken `~/.ssh/config
Host test
Port 22
User test
HostName 10.10.10.1
IdentityFile /some/path
Host test1
Port 22
User test1
HostName 10.10.10.2
IdentityFile /some/other/path
Host *
ForwardAgent no
Compression no
ServerAliveInterval 0
ServerAliveCountMax 3
HashKnownHosts no
UserKnownHostsFile
ControlMaster no
ControlPath
ControlPersist no
Working ~/.ssh/config
Host test
Port 22
User test
HostName 10.10.10.1
IdentityFile /some/path
Host test1
Port 22
User test1
HostName 10.10.10.2
IdentityFile /some/other/path
Host *
ForwardAgent no
Compression no
ServerAliveInterval 0
ServerAliveCountMax 3
HashKnownHosts no
UserKnownHostsFile
ControlMaster no
ControlPath
ControlPersist no
Hello,
First of all, thanks for this plugin.
I've noticed that nested includes aren't supported yet. This is almost a duplicate of this issue: #9 .
To reuse toddeye's example, here is what my config looks like:
[~/.ssh/config file]
include config.d/*
[~/.ssh/config.d file listing]
include1
include2
[~/.ssh/config.d/include1]
include ~/.ssh/config.d/another-directory/*
Isn't a major issue, as copying the include line into an other config file is an easy workaround.
Best regards,
fzf-complete-ssh:zle:49: widgets can only be called when ZLE is active
I am getting this error all the time and am not able to fix it so far.
All other plugins and widgets work so it might be a small bug in my edge case?
zsh 5.9 (x86_64-pc-linux-gnu)
Commit 2581ff1 brokes autocompletion (at least for included files).
Here is my patch to fix that issue:
---
zsh-ssh.zsh | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/zsh-ssh.zsh b/zsh-ssh.zsh
index 342d84d..9a63df8 100644
--- a/zsh-ssh.zsh
+++ b/zsh-ssh.zsh
@@ -8,17 +8,18 @@
_ssh-host-list() {
local ssh_config host_list
- ssh_config=$(command awk '
+
+ ssh_config=$(command awk -v PREFIX=$HOME/.ssh/ '
{
- if (NF == 2 && tolower($1) == "include")
- {
- cmd = "sed -s '\''$G'\'' " $2 " 2> /dev/null"
- # print cmd
- while ( (cmd | getline line) > 0 ) {
- print line
- }
- close($2)
+ if (NF == 2 && tolower($1) == "include") {
+ file = PREFIX $2
+ cmd = "sed -s '\''$G'\'' " file " "
+ # print cmd
+ while ( (cmd | getline line) > 0 ) {
+ print line
}
+ close(file)
+ }
else {
print
}
--
2.40.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.