Skip to content

Instantly share code, notes, and snippets.

@scriptingosx
scriptingosx / ActiveDirectory_Generic.mobileconfig
Created January 28, 2015 17:33
Active Directory Configuration Profile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>ADAllowMultiDomainAuth</key>
<true/>
<key>ADAllowMultiDomainAuthFlag</key>
@scriptingosx
scriptingosx / Build Package and Notarize
Last active February 27, 2023 18:09
Use this as a Archive Post-action in Xcode for command line tool projects. More details in this post: https://scriptingosx.com/?p=1588
# Developer ID Installer cert name
sign_cert="Developer ID Installer: Name (ABCD123456)"
# profile name used with `notarytool --store-credentials`
credential_profile="notary-example.com"
# data from build settings
pkg_name="$PRODUCT_NAME"
identifier="$PRODUCT_BUNDLE_IDENTIFIER"
version="$MARKETING_VERSION"
@scriptingosx
scriptingosx / setdesktop.sh
Last active January 31, 2023 15:02
Sample script to set the desktop with desktoppr
#!/bin/sh
##
## sets the desktop using `desktoppr`
##
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# set the path to the desktop image file here
picturepath="/Library/Desktop Pictures/BoringBlueDesktop.png"
@scriptingosx
scriptingosx / bashdisplay.sh
Last active December 10, 2022 15:51
bash functions using osascript to use some user interaction on macOS
#!/bin/bash
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
consoleUser() {
echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }'
}
displaydialog() { # $1: message
message=${1:-"Message"}
@scriptingosx
scriptingosx / userpictures.sh
Created October 23, 2018 07:24
sample script that loops through all users and sets a different user picture.
#!/bin/bash
# create an array from all images in the User Pictures subfolders
IFS=$'\n' read -rd '' -a pictures <<< "$(find '/Library/User Pictures/Fun' -name *.tif -print )"
# loop through all users
picIndex=0
@scriptingosx
scriptingosx / Save Tabs to Notes.applescript
Created January 5, 2016 09:11
Save Safari Tabs to Notes
property defaultAccountName : "iCloud"
property defaultFolderName : "Saved Safari Windows"
global html
global processedURLs
on appendLineWithDoc(theDoc)
tell application "Safari"
tell theDoc
try
@scriptingosx
scriptingosx / bash_prompt.sh
Last active June 23, 2022 19:13
Sample code for dynamic bash prompt that shows exit codes.
# PROMPT
# default macOS prompt is: \h:\W \u\$
# assemble the prompt string PS1
# inspired from: https://stackoverflow.com/a/16715681
function __build_prompt {
local EXIT="$?" # store current exit code
# define some colors
@scriptingosx
scriptingosx / modelinfo.py
Created November 8, 2017 14:50
Get the localized "Marketing Name" for a Mac
#!/usr/bin/python
import sys
import plistlib
import subprocess
from Cocoa import NSBundle
if (len(sys.argv) == 2):
model = sys.argv[1]
else:
@scriptingosx
scriptingosx / .bash_profile
Created April 25, 2017 08:17
Sample Environment Variables in bash_profile/bashrc. (See http://scriptingosx.com/2017/04/on-bash-environment-variables/ for details)
# ENVIRONMENT VARIABLES
# add my ~/bin dir to path
PATH=${PATH}:~/bin
export PATH
# simple prompt
# default macOS prompt is: \h:\W \u\$
export PS1="\W \$ "
@scriptingosx
scriptingosx / pwdf
Created February 8, 2017 09:27
pwdf - prints the path to the frontmost Finder window
#!/usr/bin/osascript
on run arguments
tell application "Finder"
-- no argument: get frontmost window or desktop
if (count of arguments) is 0 then
if (count of windows) is 0 then
set dir to (desktop as alias)
else
set dir to ((target of Finder window 1) as alias)