2

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.

1 Answer 1

1

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.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.