local/bin/vboxmenu

   1 #!/bin/bash
   2 
   3 source ~/.theme/colors.sh
   4 
   5 while read i; do
   6     vboxmanage startvm "$i"
   7 done < <(
   8     vboxmanage list vms | cut -d '"' -f 2 | icon -x os |
   9     dmenu -i -p "$(icon vbox)" -sb $cyan1 | cut -d ' ' -f 3-
  10 )
  11 
  12 port=2222
  13 
  14 sleep 1 &&
  15 vboxmanage list runningvms |
  16 while IFS=\" read _ name id; do
  17     name=${name,,}
  18     name=${name// /-}
  19 
  20     echo "Host vbox-$name"
  21     echo "HostName localhost"
  22     echo "Port $port"
  23 
  24     vboxmanage controlvm $id natpf1 delete SSH
  25     vboxmanage controlvm $id natpf1 SSH,tcp,,$port,,22
  26 
  27     (( port++ ))
  28 done > ~/.ssh/vbox &
  29