sudo mkdir -p /usr/local/bin &>/dev/null ; sudo curl -fsSL -o /usr/local/bin/getframe "https://gist.githubusercontent.com/snown/a818afd18c9e2087731bdf7ce0a85195/raw/getframe.sh" && sudo chmod a+x /usr/local/bin/getframe
getframe install-folder-action
#!/usr/bin/env bash | |
function bashful { | |
( | |
local bashful_path="$(find /tmp/ -name "jmcantrell-bashful-*" -print -quit 2>/dev/null)" | |
if [[ -z ${bashful_path:+x} ]]; then | |
curl -fsSL https://github.com/jmcantrell/bashful/tarball/master | tar xz -C /tmp/ | |
bashful_path="$(find /tmp/ -name "jmcantrell-bashful-*" -print -quit 2>/dev/null)" | |
fi | |
if [[ -z ${bashful_path:+x} ]]; then |
extension NSColor { | |
convenience init?(hexString: String) { | |
var hexString: String = hexString.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) | |
if hexString.hasPrefix("#") { | |
let startIndex = hexString.index(hexString.startIndex, offsetBy: 1) | |
hexString = String(hexString[startIndex...]) | |
} | |
if hexString.count == 3 || hexString.count == 4 { | |
hexString = hexString.reduce(into: "") { (paddedHex, hexCharacter) in |
#!/usr/bin/env bash | |
function here_printf { | |
local format=${1:-"%b\n"} | |
local text | |
read -r -d '' text | |
printf "${format}" "${text}" | |
} |
#!/usr/bin/env bash | |
function bashful { | |
( | |
local bashful_path="$(find /tmp/ -name "jmcantrell-bashful-*" -print -quit 2>/dev/null)" | |
if [[ -z ${bashful_path:+x} ]]; then | |
curl -fsSL https://github.com/jmcantrell/bashful/tarball/master | tar xz -C /tmp/ | |
bashful_path="$(find /tmp/ -name "jmcantrell-bashful-*" -print -quit 2>/dev/null)" | |
fi | |
if [[ -z ${bashful_path:+x} ]]; then |
# Return a random number between two limits | |
#------------------------------------------------------------------------------- | |
function random { | |
#default to numbers between 1-10 | |
local _min="${1:-1}" | |
local _max="${2:-10}" | |
local diff=$((${_max}-${_min}+1)) | |
echo -n "$(($((${RANDOM}%${diff}))+${_min}))" | |
} |
get_script_path () { | |
printf '%s' "$(realpath "${BASH_SOURCE[0]}")" | |
} |
function uniqueElements { | |
local input_array=( "$@" ) | |
local IFS=$'\n' | |
local RESULT=( $(printf '%s\n' ${input_array[@]} | awk '!seen[$0]++') ) | |
# Uncomment if you want the result to come back in a format that can easily be passed to `declare -a` | |
#echo $(declare -p RESULT | sed "s/^[^(]*// ; s/'$//") | |
echo "${RESULT[@]}" | |
} |
#!/usr/bin/env bash | |
# Only supports one die, and the most basic notation right now | |
# would like to complete support for dice notation as specified here: | |
# https://en.wikipedia.org/wiki/Dice_notation | |
_basename() { #portable basename | |
[ -z "${1}" ] && return 1 || _basename__name="${1%%/}" | |
[ -z "${2}" ] || _basename__suffix="${2}" | |
case "${_basename__name}" in | |
/*|*/*) _basename__name="$(expr "${_basename__name}" : '.*/\([^/]*\)')" ;; |
#!/usr/bin/env bash | |
scriptSudo() { | |
local SUDO_IS_ACTIVE | |
SUDO_IS_ACTIVE=$(sudo -n uptime 2>&1|grep "load"|wc -l) | |
if [[ ${SUDO_IS_ACTIVE} -le 0 ]]; then | |
# Ask for the administrator password upfront | |
sudo -v | |
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished |