Remove ssh.zsh and replace with a preexec.zsh script

This script is configured to intercept the `ssh` command and boot the
associated VM

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Anna Schumaker 2021-12-02 15:49:42 -05:00
parent d059a55b85
commit ab780cd3a8
5 changed files with 17 additions and 24 deletions

View File

@ -1,15 +0,0 @@
#compdef ssh.zsh
function _ssh.zsh() {
_arguments \
':args: _alternative
"hosts:hosts: _ssh_hosts"
"users:users: _ssh.zsh_users -qS@"
"domains:domains:($(virsh list --all --name))"'
}
_ssh.zsh_users () {
_combination -s '[:@]' my-accounts users-hosts users "$@"
}
_ssh.zsh "$@"

View File

@ -13,8 +13,8 @@ deploypkg.zsh $(makepkg --packagelist) $*
pkgname=$(grep ^pkgname PKGBUILD | awk -F= '{print $2}')
for vm in $*; do
title=$(ssh.zsh $vm grub-list.zsh -e | grep $pkgname$)
ssh.zsh $vm "sudo grub-reboot \"$title\""
title=$(ssh $vm grub-list.zsh -e | grep $pkgname$)
ssh $vm "sudo grub-reboot \"$title\""
done
echo
@ -24,5 +24,5 @@ echo
tags=($(python /home/anna/bin/colors/vm.py $*))
for ((i=1; i<=$#; i++)); do
echo "${tags[i]} $fg_bold[default]$(ssh.zsh ${@[i]} uname -rsn)$reset_color"
echo "${tags[i]} $fg_bold[default]$(ssh ${@[i]} uname -rsn)$reset_color"
done

View File

@ -10,9 +10,9 @@ pkg=$(basename $1)
shift
function deploy_package() {
ssh.zsh $1 "mkdir -pv pkg" 2>&1 | sed -e "s/^/$2 /"
ssh $1 "mkdir -pv pkg" 2>&1 | sed -e "s/^/$2 /"
script -q -c "scp $pkg $1:pkg/ 2>&1" 2>&1 | sed -e "s/^/$2 /"
ssh.zsh $1 "sudo pacman --noconfirm -U pkg/$pkg" | python $colors/pacman.py $2
ssh $1 "sudo pacman --noconfirm -U pkg/$pkg" | python $colors/pacman.py $2
}
tags=($(python $colors/vm.py $*))

12
preexec.zsh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/zsh
#
# Be sure to add:
# preexec() { /path/to/script/preexec.zsh $* }
# to your .zshrc
cmd=($(echo "$1" | sed 's/\-\w //g'))
# Boot offline VMs
if [[ $cmd[1] == "ssh" ]]; then
vm.zsh boot $(echo $cmd[2] | sed 's/^\w*@//')
fi

View File

@ -1,4 +0,0 @@
#!/bin/zsh
vm.zsh boot $1
ssh $*