Skip to content

Instantly share code, notes, and snippets.

tell application "Terminal"
set openWindows to every window
set openTabs to {}
repeat with i from 1 to number of items in openWindows
set this_item to item i of openWindows
set openTabs to openTabs & every tab of this_item
end repeat
repeat with i from 1 to number of items in openTabs
set this_item to item i of openTabs
do script "source ~/.zshrc" in this_item
#!/usr/bin/env/nush
(load "ScriptingBridge") ; Load the ScriptingBridge framework
(set finder (SBApplication applicationWithBundleIdentifier: "com.apple.Finder")) ; Reference to shared instance
(puts (((finder disks) 0) name)) ; Name of the first disk in the Finder
@statonjr
statonjr / copy-path.nu
Created December 2, 2010 04:59
Nu script to copy the path of the selected item in the Finder to the Clipboard.
#!/usr/local/bin/nush
(load "ScriptingBridge") ;; Access the Finder
(function path ()
(((((SBApplication applicationWithBundleIdentifier:"com.apple.Finder") selection) get) objectAtIndex:0) URL))
(function stripURL (path)
(path substringFromIndex:16))
(system ("echo " stringByAppendingString:((stripURL (path)) stringByAppendingString:" | pbcopy")))
@statonjr
statonjr / say.nu
Created December 5, 2010 06:35
Nu function that wraps NSSpeechSynthesizer to act like AppleScript say function
#!/usr/local/bin/nush
(function say (something *voice)
(if (*voice)
(set s ((NSSpeechSynthesizer alloc) initWithVoice:("com.apple.speech.synthesis.voice." stringByAppendingString:(car *voice))))
(else
(set s ((NSSpeechSynthesizer alloc) init))))
(s startSpeakingString:something)
(while (s isSpeaking)
(sleep 1)))
@statonjr
statonjr / utilities.nu
Created December 6, 2010 02:58
Nu functions
#!/usr/local/bin/nush
;; @name utilities.nu
;; @description A set of utilities for Nu
(function ++ (num)
(+ 1 num))
;; (puts (++ 15)) -> 16
@statonjr
statonjr / xcode.nu
Created December 9, 2010 04:56
Simple command line program to launch Xcode
#!/usr/local/bin/nush
(system ("open -b com.apple.Xcode \"" stringByAppendingString: ((((NSProcessInfo processInfo) arguments) objectAtIndex:2) stringByAppendingString:"\"")))
@statonjr
statonjr / gist:738717
Created December 13, 2010 06:21
How to call functions from the command line in Nu
(puts (eval (parse (((NSProcessInfo processInfo) arguments) objectAtIndex:2))))
@statonjr
statonjr / gist:739947
Created December 14, 2010 02:58
Print Mail Messages to PDF then Delete
(*
Prints mail messages to PDF, then deletes the message.
You must first set up your keyboard shortcut as shown here:
http://www.macsparky.com/blog/2008/3/19/keyboard-shortcut-for-save-as-pdf-in-os-x.html
The MIT License
Copyright (c) 2010. Larry Staton Jr.
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullBridge:YES];
// Instantiate the LayoutManager
[LayoutManager sharedManager];
find ~/Library/Application\ Support/TextMate/Bundles -iname "*.tmbundle" | parallel 'cd {};git pull' | osascript -e 'tell application "TextMate" to reload bundles'