Add @insidegui's devicectl script
This commit is contained in:
parent
debd6fae66
commit
3b644718cc
2 changed files with 67 additions and 0 deletions
60
zsh/devicectl.sh
Normal file
60
zsh/devicectl.sh
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Add to your zsh profile
|
||||||
|
|
||||||
|
function devicepid() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: devicepid <device-name> <search>"
|
||||||
|
echo "Example: devicepid 'iPhone 15 Pro Max' SpringBoard"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
echo "Usage: devicepid <device-name> <search>"
|
||||||
|
echo "Example: devicepid 'iPhone 15 Pro Max' SpringBoard"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
xcrun devicectl device info processes --device "$1" | grep "$2" | awk '{ print $1; }'
|
||||||
|
}
|
||||||
|
|
||||||
|
func devicekill() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: devicekill <device-name> <process-name>"
|
||||||
|
echo "Example: devicekill 'iPhone 15 Pro Max' SpringBoard"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
echo "Usage: devicekill <device-name> <process-name>"
|
||||||
|
echo "Example: devicekill 'iPhone 15 Pro Max' SpringBoard"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TARGETPID=$(devicepid "$1" "$2")
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Couldn't find PID for $2"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Found PID for $2: $TARGETPID"
|
||||||
|
|
||||||
|
xcrun devicectl device process signal --pid $TARGETPID --signal SIGHUP --device "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
func respring() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: respring <device-name>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
devicekill "$1" "SpringBoard"
|
||||||
|
}
|
||||||
|
|
||||||
|
func devicereboot() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: devicereboot <device-name>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
xcrun devicectl device reboot --device "$1"
|
||||||
|
}
|
||||||
7
zshrc
7
zshrc
|
|
@ -313,3 +313,10 @@ fi
|
||||||
|
|
||||||
autoload -Uz compinit
|
autoload -Uz compinit
|
||||||
compinit
|
compinit
|
||||||
|
|
||||||
|
### devicectl
|
||||||
|
# ==========
|
||||||
|
# Gui Rambo's iOS device control functions
|
||||||
|
# https://gist.github.com/insidegui/b570ec998b9e2aeb730f4e142f0593d1
|
||||||
|
|
||||||
|
source $ZDOTDIR/devicectl.sh
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue