Skip to content

Instantly share code, notes, and snippets.

@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
Last active June 4, 2017 19:55
Sample bash_profile file for the article: http://wp.me/p69KII-64
# 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 / .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)
@scriptingosx
scriptingosx / ssh-installer.sh
Created October 17, 2016 12:25
ssh-installer tool for macOS to `scp` a package to a remote host and install it
#!/bin/sh
PATH=/usr/bin:/bin:/usr/sbin:/sbin export PATH
# ssh-installer
# copies a pkg with scp and runs installer on target
# usage: ssh-installer [USER@]HOST PKGFILE [other installer options]
TMPPKGDIR="/private/tmp/ssh-installer/"
global html
global processedURLs
on appendLineWithDoc(theDoc)
tell application "Safari"
tell theDoc
try
my appendHTML(" <li>")
my appendHTML("<a href=\"" & URL & "\">")
my appendHTML(name)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugin name="AutoPkg Recipe" id="com.scriptingsosx.autopkg-recipe-definition" version="1.0" xmlns:plisteditpro="http://www.fatcatsoftware.com/plisteditpro">
<extension point="com.apple.xcode.plist.structure-definition" name="AutoPkg Recipe" id="com.scriptingosx.autopkg-recipe-definition">
<definition name="_root_" localizedString="AutoPkg Recipe" class="Dictionary" identifyingKey="Identifier">
<dictionaryKeys>
<key name="Comment" localizedString="Comment" class="String" use="optional"></key>
<key name="Description" localizedString="Description" class="String" use="default"></key>
<key name="Identifier" localizedString="Identifier" class="String" use="required"></key>
<key name="Input" localizedString="Input" class="Input" use="required"></key>
<key name="MinimumVersion" localizedString="MinimumVersion" class="String" use="default"></key>
@scriptingosx
scriptingosx / ard_installcheck.sh
Created January 14, 2016 11:43
Control ARD scripts
#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki export PATH
# this will run as a munki install_check script
# exit status of 0 means install needs to run
# exit status not 0 means no installation necessary
# adapted scripts from here: https://jamfnation.jamfsoftware.com/discussion.html?id=1989
property defaultAccountName : "iCloud"
property defaultFolderName : "Saved iCloud Tabs"
global html
global processedURLs
on appendLineWithURLItem(urlItem)
my appendHTML(" <li>")
my appendHTML("<a href=\"" & |url| of urlItem & "\">")
my appendHTML(|Title| of urlItem)
@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