Skip to content

Instantly share code, notes, and snippets.

@romanfurman6
Last active May 20, 2020 11:58
Show Gist options
  • Save romanfurman6/b08f85c3f16c27929f3caa2f491af360 to your computer and use it in GitHub Desktop.
Save romanfurman6/b08f85c3f16c27929f3caa2f491af360 to your computer and use it in GitHub Desktop.
# Functions for recording a video or taking a screenshot from the currently booted simulator and saving it in the Screenshots folder.
# Installation: put it in your .zshrc or .bashrc
# Usage: "$ simrec" or "$ simscr" in terminal
function simrec() {
currentDate=$(date "+%Y-%m-%d at %H.%M.%S")
screenshotsPath="$HOME/Screenshots"
fileName="Screen Recording ${currentDate}.mp4"
fullPath="${screenshotsPath}/${fileName}"
echo "Recording Video in ${fullPath}"
echo "You can stop recording by Ctrl+C"
xcrun simctl io booted recordVideo --code=h264 --force ${fullPath}
}
function simscr() {
currentDate=$(date "+%Y-%m-%d at %H.%M.%S")
screenshotsPath="$HOME/Screenshots"
fileName="Screenshot ${currentDate}.png"
fullPath="${screenshotsPath}/${fileName}"
xcrun simctl io booted screenshot --type=png ${fullPath}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment