Links
HowTo
Get computer name
scutil --get ComputerName
Make finder browse to a folder
From https://github.com/zeekay/dot-zsh/blob/master/plugins/osx/lib/fdc
#!/bin/sh if [ -n "$1" ]; then if [ "${1%%/*}" = "" ]; then thePath="$1" else thePath=`pwd`"/$1" fi else thePath=`pwd` fi osascript<<END set myPath to ( POSIX file "$thePath" as alias ) try tell application "Finder" to set the (folder of the front window) to myPath on error -- no open folder windows tell application "Finder" to open myPath end try END
Get POSIX path of Finder window location
From https://github.com/zeekay/dot-zsh/blob/master/plugins/osx/lib/posd
#!/bin/sh thePath="$( osascript<<END try tell application "Finder" to set the source_folder to (folder of the front window) as alias on error -- no open folder windows set the source_folder to path to desktop folder as alias end try set thePath to (POSIX path of the source_folder as string) set result to thePath END )" #thePath="$( echo "$thePath" | /usr/bin/sed 's/ /\\ /g' )" if [ -n "${thePath%/*}" ]; then if [ -d "$thePath" ]; then echo "${thePath%/}" else echo "${thePath%/*}" fi else echo "/" fi