Skip to content

Instantly share code, notes, and snippets.

@RobertAudi
Last active June 30, 2022 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertAudi/237cde20284a215bfee495ae1841afba to your computer and use it in GitHub Desktop.
Save RobertAudi/237cde20284a215bfee495ae1841afba to your computer and use it in GitHub Desktop.
Parallels CLI helpers
#!/usr/bin/env zsh
if ! type prlctl &> /dev/null ; then
print -u 2 -- "command not found: prlctl"
print -u 2 -- "Parallels might not be installed"
return 1
fi
if ! type fzf &> /dev/null ; then
print -u 2 -- "command not found: fzf"
return 1
fi
local vmid
vmid="$(prlctl list --all | fzf --header-lines=1 | cut -d\ -f1 | sed 's/[{}]//g')"
if [[ -z "$vmid" ]] ; then
print -u 2 -- "VM not found"
return 1
fi
vmstatus="$(prlctl status $vmid | cut -d\ -f4)"
if [[ -z "$vmstatus" ]] ; then
print -u 2 -- "VM status not found"
return 1
fi
if [[ "$vmstatus" == "running" ]]; then
print -u 2 -- "VM already running"
return 1
fi
if [[ "$vmstatus" == "stopped" ]]; then
prlctl start $vmid
elif [[ "$vmstatus" == "suspended" ]]; then
prlctl resume $vmid
fi
#!/usr/bin/env zsh
if ! type prlctl &> /dev/null ; then
print -u 2 -- "command not found: prlctl"
print -u 2 -- "Parallels might not be installed"
return 1
fi
if ! type fzf &> /dev/null ; then
print -u 2 -- "command not found: fzf"
return 1
fi
local vms
local vmid
vms="$(prlctl list --all)"
if [[ "$1" == "all" ]]; then
builtin print -l "$vms"
else
vmid="$(builtin print -l "$vms" | fzf --header-lines=1 | cut -d\ -f1 | sed 's/[{}]//g')"
if [[ -z "$vmid" ]] ; then
builtin print -l "$vms"
else
prlctl status $vmid | cut -d\ -f4
fi
fi
#!/usr/bin/env zsh
if ! type prlctl &> /dev/null ; then
print -u 2 -- "command not found: prlctl"
print -u 2 -- "Parallels might not be installed"
return 1
fi
if ! type fzf &> /dev/null ; then
print -u 2 -- "command not found: fzf"
return 1
fi
local vmid
vmid="$(prlctl list --all | fzf --header-lines=1 | cut -d\ -f1 | sed 's/[{}]//g')"
if [[ -z "$vmid" ]] ; then
print -u 2 -- "VM not found"
return 1
fi
vmstatus="$(prlctl status $vmid | cut -d\ -f4)"
if [[ -z "$vmstatus" ]] ; then
print -u 2 -- "VM status not found"
return 1
fi
if [[ "$vmstatus" == "stopped" ]]; then
print -u 2 -- "VM already stopped"
return 1
elif [[ "$vmstatus" != "running" ]]; then
print -u 2 -- "VM not running"
return 1
fi
prlctl stop $vmid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment