Skip to content

Instantly share code, notes, and snippets.

@sankalp-khare
Created March 27, 2021 04:04
Show Gist options
  • Save sankalp-khare/da46a83b922fa9c264d41cff332f55f8 to your computer and use it in GitHub Desktop.
Save sankalp-khare/da46a83b922fa9c264d41cff332f55f8 to your computer and use it in GitHub Desktop.
set screenshots directory to ~/screenshots
#!/bin/bash
# exit on error from any of the subsequent commands
set -e
# ref: https://intoli.com/blog/exit-on-errors-in-bash-scripts/
# create the location
mkdir ~/screenshots
# set it
defaults write com.apple.screencapture location ~/screenshots
# reload settings
killall SystemUIServer
# setup some colours for the message later
# compatible with bash 3.2 which is the osx default: https://stackoverflow.com/a/37115900/1527814
RED="\033[01;31m"
GREEN="\033[01;32m"
PURPLE="\033[01;35m"
CYAN="\033[01;36m"
ENDCOLOR="\033[00m"
# ref: https://dev.to/ifenna__/adding-colors-to-bash-scripts-48g4
# print epic message"
echo -e "${GREEN}This is complete! find your screenshots in a folder called ${PURPLE}screenshots${GREEN} in your home directory.${ENDCOLOR}"
echo -e "${CYAN}contact ${RED}sankalp${CYAN} if there are issues${ENDCOLOR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment