Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Robert Spencer
awit-zsh-superawesome
Commits
90f8b0c7
Commit
90f8b0c7
authored
Jan 02, 2019
by
Robert Spencer
Browse files
Add awit-ssh host name completion
parent
2bc704f4
Changes
5
Hide whitespace changes
Inline
Side-by-side
contrib/awit-ssh-completion/51-completion-awit-ssh.zsh
0 → 100644
View file @
90f8b0c7
# compsys initialization
autoload
-U
compinit
compinit
# Get an array of known SSH host names after deleting:
# - Everything after the first column of host names or IPs
# - Square brackets and attached port numbers
# - IP addresses
# - Encrypted host names
hosts
=(
`
sed
-e
's/[, ].*//g'
-e
's/\[\([^]]*\)\].*/\1/'
-e
'/^[0-9]\+/d'
-e
'/^|1|/d'
$HOME
/.ssh/known_hosts
`
)
zstyle
':completion:*:hosts'
hosts
$hosts
contrib/awit-ssh-completion/INSTALL
0 → 100755
View file @
90f8b0c7
#!/bin/zsh
die
()
{
echo
"
$1
"
exit
1
}
grep
-q
'^|1|'
~/.ssh/known_hosts
&&
die
"ERROR: ~/.ssh/known_hosts is hashed. Aborting!
Please see this contributions README.md for more information."
if
[
!
-e
~/.zsh/completion/_awit-ssh
]
;
then
# Install
ln
-s
~/.zsh/contrib/awit-ssh-completion/_awit-ssh ~/.zsh/completion/
echo
"Installed ~/.zsh/completion/_awit-ssh"
else
# Uninstall
rm
-f
~/.zsh/completion/_awit-ssh
echo
"Uninstalled ~/.zsh/completion/_awit-ssh"
fi
if
[
!
-e
~/.zsh/zshrc.d/51-completion-awit-ssh.zsh
]
;
then
# Install
ln
-s
~/.zsh/contrib/awit-ssh-completion/51-completion-awit-ssh.zsh ~/.zsh/zshrc.d/
echo
"Installed ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh"
else
# Uninstall
rm
-f
~/.zsh/zshrc.d/51-completion-awit-ssh.zsh
echo
"Uninstalled ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh"
fi
contrib/awit-ssh-completion/README.md
0 → 100644
View file @
90f8b0c7
# awit-ssh Completion
If you want to use awit-ssh completion with zsh you first need to clean up your ~/.ssh/known_hosts file if it is hashed.
Run the follow and if you see any number other than zero, your ~/.ssh/known_hosts file is hashed
grep -c '^|1|' ~/.ssh/known_hosts
Since you need the file unencrypted make a backup of ~/.ssh/known_hosts and then add the following lines to the top of ~/.ssh/config
Host *
HashKnownHosts no
Then delete the hashed lines
sed -i '/^|1|/d' ~/.ssh/known_hosts
Going forward host names will be added in plain text. You'll be prompted to re-add the deleted hosts names as you log in to each server again.
contrib/awit-ssh-completion/_awit-ssh
0 → 100644
View file @
90f8b0c7
#compdef awit-ssh
local curcontext="$curcontext" state line expl ret=1
local -a _comp_priv_prefix
_arguments -C \
'(-?)--help[display help information]' \
'--version[display version information]' \
'--forward-agent[forward the ssh-agent socket]' \
'--knock[knock on HOST:PORT to gain access]' \
'--rsync[use rsync to rsync data from remote server to DEST]' \
'--libvirt-vnc[connect to remote VNC server HOST:PORT]' \
'1:remote host name:->userhost' \
'*:::args:_normal' && ret=0
case $state in
userhost)
if compset -P '*@'; then
_wanted hosts expl 'remote host name' _ssh_hosts && ret=0
elif compset -S '@*'; then
_wanted users expl 'login name' _combination -s '[:@]' my-accounts users-hosts users -S '' && ret=0
else
_alternative \
'hosts:remote host name:_ssh_hosts' \
'users:login name:_combination -s "[:@]" my-accounts users-hosts users -qS@' && ret=0
fi
;;
esac
return ret
zshrc.d/50-completions.zsh
View file @
90f8b0c7
...
...
@@ -31,3 +31,6 @@ zstyle ':completion:*' verbose true
#zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
#zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# Add custom completion scripts
fpath
=(
~/.zsh/completion
$fpath
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment