Skip to content

Instantly share code, notes, and snippets.

@ZevEisenberg
Created July 22, 2017 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZevEisenberg/8ff5c878b07489fa9e87dc840eced348 to your computer and use it in GitHub Desktop.
Save ZevEisenberg/8ff5c878b07489fa9e87dc840eced348 to your computer and use it in GitHub Desktop.
Functions to copy versions of Xcode, browsers, and macOS
function copySafariVersion
{
local safariVersion=$(defaults read /Applications/Safari.app/Contents/Info CFBundleShortVersionString)
local safariBuild=$(defaults read /Applications/Safari.app/Contents/Info CFBundleVersion)
local macOSVersion=$(sw_vers -productVersion)
local macOSBuild=$(sw_vers -buildVersion)
local fullString="Safari ${safariVersion} (${safariBuild}) on macOS ${macOSVersion} (${macOSBuild})"
echo "Copied \"$fullString\""
echo -n $fullString | pbcopy
}
function copyChromeVersion
{
local chromeVersion=$(defaults read /Applications/Google\ Chrome.app/Contents/Info CFBundleShortVersionString)
local chromeBuild=$(defaults read /Applications/Google\ Chrome.app/Contents/Info CFBundleVersion)
local macOSVersion=$(sw_vers -productVersion)
local macOSBuild=$(sw_vers -buildVersion)
local fullString="Chrome ${chromeVersion} (${chromeBuild}) on macOS ${macOSVersion} (${macOSBuild})"
echo "Copied \"$fullString\""
echo -n $fullString | pbcopy
}
function copyXcodeVersion
{
local xcodePath=`xcode-select -p | rev | cut -d'/' -f3- | rev`
local xcodeVersion=$(defaults read "${xcodePath}"/Contents/Info CFBundleShortVersionString)
local xcodeBuild=$(defaults read "${xcodePath}"/Contents/Developer/Library/Frameworks/XcodeKit.framework/Versions/A/Resources/version ProductBuildVersion)
local macOSVersion=$(sw_vers -productVersion)
local macOSBuild=$(sw_vers -buildVersion)
local fullString="Xcode ${xcodeVersion} (${xcodeBuild}) on macOS ${macOSVersion} (${macOSBuild})"
echo "Copied \"$fullString\""
echo -n $fullString | pbcopy
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment