Skip to content

Instantly share code, notes, and snippets.

Avatar

Kare Morstol kareman

View GitHub Profile
@beccadax
beccadax / trash.swift
Last active Mar 5, 2021
A trash command as a Swift script.
View trash.swift
#!/usr/bin/xcrun swift
import Dispatch
import Cocoa
dispatch_async(dispatch_get_main_queue()) {
let URLsToRecycle = Array(dropFirst(Process.arguments)).map { NSURL(fileURLWithPath: $0) }
NSWorkspace.sharedWorkspace().recycleURLs(URLsToRecycle) { dict, error in
let recycledURLs = Array(dict.keys) as [NSURL]
@pyrtsa
pyrtsa / version.bash
Last active Aug 7, 2021
Xcode: Set version and build number from Git
View version.bash
#!/bin/bash
# Xcode: Set version and build number from Git
# --------------------------------------------
#
# This script sets the version number `CFBundleShortVersionString` to one of
#
# - `1.2.3` -- for the tagged commit `v1.2.3` or a hyphen-separated prerelease,
# e.g. `v1.2.3-alpha`, `v1.2.3-alpha.2`, `v1.2.3-beta`, `v1.2.3-rc`.
# - `1.2.3-7-gabc1234` -- at commit `abc1234`, 7 commits after `v1.2.3`,
# - `1.2.3-7-gabc1234-dirty` -- when there are uncommitted changes, or