1

I make a lot of presentations that involve many screenshots, and I want an easier way to organize them by project. I'm trying to write a simple function that changes the location where screenshots are saved to the current working directory.

I've written a function in and saved it to ~/.my_custom_commands.sh.

That file currently looks like this:

#!/bin/bash
# changes location of screenshot to current directory
function shoothere() {
    defaults write com.apple.screencapture location '. '
    killall SystemUIServer
    echo 'foo'
    }

When I navigate to the directory where I want to save my screenshots and run the function, it does print foo but screenshots do not appear anywhere.

I've also tried replacing '. ' with $1 and running it as $ shoothere ., at which point I get an error Rep argument is not a dictionary. Defaults have not been changed. Googling this error message has gotten me precisely nowhere.

I'm on a Mac running Mojave 10.14.4.

0

This slightly different syntax appears to work for me; it's probably that . isn't correctly handled by the service MacOS has running in the background:

~/foo $ defaults write com.apple.screencapture location "$(pwd)"
~/foo $ defaults read com.apple.screencapture
{
    "last-messagetrace-stamp" = "576625649.15493";
    location = "/Users/[redacted]/foo";
}

To reset it back to default, you can use this:

$ defaults delete com.apple.screencapture location

killall SystemUIServer is not necessary at all, as soon as I ran the defaults write command, I was able to observe newly-captured screenshots appearing in the correct directory.

  • 1
    yes! thank you so much. works perfectly now. – condenastee Apr 12 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.