Last active
June 30, 2022 09:04
-
-
Save RobertAudi/237cde20284a215bfee495ae1841afba to your computer and use it in GitHub Desktop.
Parallels CLI helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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