Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tylerneylon
Last active May 4, 2016 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerneylon/2ff951d82a33223f4de836d3a4c4108d to your computer and use it in GitHub Desktop.
Save tylerneylon/2ff951d82a33223f4de836d3a4c4108d to your computer and use it in GitHub Desktop.
Bash function to simplify usage of mac os x s
ssfile ()
{
f="$(ls -1tr $HOME/Desktop/Screen*.png | tail -1)";
g=$(echo $f | tr ' ' _);
mv "$f" "$g";
echo $g
}
@tylerneylon
Copy link
Author

Usage:

  1. Take a Mac OS X screenshot, such as via the ⌘⇧4 shortcut.
  2. Use ssfile from bash in any directory. Examples:
$ open `ssfile`
$ mv `ssfile` my_image.png
$ convert `ssfile` -resize 640x my_jpg.jpg  # Assuming you have ImageMagick installed.

The script replaces all spaces in the screenshot's filename for easier use from bash. This change is idempotent, meaning that repeated use of ssfile continues to refer to the most recent screenshot until you move or rename the file to something that no longer matches Screen*.png in your desktop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment