2

Background

I have a habit of creating new user profiles on my mac that serves different needs (ie recruiting, software development etc). I'm always thinking of ways to make creating a new user less expensive, one is saving all sorts of setting files and saving them in dropbox (ie alfred settings, slate settings, bash_profile, vimrc etc etc).

I also have many settings that I have to issue mac commands for (like this one):

defaults write com.apple.screencapture location ~/Documents/Screenshots   
killall SystemUIServer

How can I save these in a "dot file", and simply have the system read them on load (ie like ~/.bash_profile)?

2 Answers 2

5
  • create a bash script for all the config commands, e.g.

    #!/bin/bash
    
    defaults write com.apple.screencapture location ~/Documents/Screenshots   
    killall SystemUIServer
    
  • store it in /usr/local/bin under whatever name you like

  • run it once for each new account
2
  • this code defaults write com.apple.screencapture location ~/Documents/Screenshots isn't bashscript.. i'm not even sure what language it is.. so that won't work
    – abbood
    Sep 14, 2017 at 7:59
  • For any future users looking, defaults is an included Apple binary, and will work perfectly fine from a bash script. Aug 19, 2019 at 10:27
2

The easiest thing is probably to create an app bundle that executes any number of arbitrary things, then add it to your login items under System Preferences -> Users and Groups -> Login Items.

enter image description here

I'd recommend using AppleScript to do be the middleman. Create a new Applescript to run your task, then go to File -> Export... and choose Application.

enter image description here

Alternatively you can just add it to your ~/.bash_profile if you'd like. There's a possibility this isn't configure to run on startup because macOS; if that's the case, just add it to your ~/.bashrc.

2
  • so can apple script run defaults write com.apple.screencapture location ~/Documents/Screenshots ???
    – abbood
    Sep 14, 2017 at 7:59
  • Sure. do shell script "defaults write com.apple.screencapture location ~/Documents/Screenshots"
    – JMY1000
    Sep 14, 2017 at 15:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .