Created
August 22, 2021 00:27
-
-
Save allancalix/a021a717a3d19fef251b958eb9643c33 to your computer and use it in GitHub Desktop.
This file contains 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 bash | |
# By default, Mac saves screenshots to the user's desktop. This simple script | |
# sets the directory screenshots are saved to turns off the screenshot | |
# confirmation popup. This script only works on MacOS. | |
# | |
# Example: | |
# ./set-screenshot-dir.sh $HOME/Screenshots | |
set -e | |
TARGET="$1" | |
if [[ -z "$TARGET" ]]; then | |
echo "Must provide desired screenshot output directory." | |
exit 0 | |
fi | |
if [[ ! -d "$TARGET" ]]; then | |
echo "Creating output directory ${TARGET}" | |
mkdir -p "$TARGET" | |
fi | |
# Overrides location to store screenshot from desktop to provided directory. | |
defaults write com.apple.screencapture location "$TARGET" | |
# Skips the screenshot preview popup step. | |
defaults write com.apple.screencapture show-thumbnail -bool FALSE | |
# Restart UI server to take effect immediately. | |
killall SystemUIServer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can run directly from gist using: