Last active
December 24, 2020 05:16
-
-
Save snown/e1245bc00ea813dbf338c8b39ed288f3 to your computer and use it in GitHub Desktop.
One Off Shell Script Dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
echo "Couldn't find bashful" | |
exit 1 | |
fi | |
pushd "${bashful_path}"/bin/ >/dev/null | |
source "${bashful_path}/bin/bashful" | |
popd >/dev/null | |
"$@" | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function _json { | |
if ! command -v json_parse &>/dev/null; then | |
curl -fsSL -o "/usr/local/bin/json_parse" "https://raw.githubusercontent.com/bpkg/bpkg/master/lib/json/JSON.sh" | |
chmod a+x /usr/local/bin/json_parse | |
fi | |
json_parse "$@" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function _pansi { | |
if ! command -v pansi &>/dev/null; then | |
local tmp_pansi="$(test ! -z ${GLOBAL_CACHE_DIR:+x} && echo "${GLOBAL_CACHE_DIR}/pansi" || echo "$(mktemp -u -t pansi.XXX)")" | |
if [[ ! -f "${tmp_pansi}" ]]; then | |
curl -fsSL --create-dirs -o "${tmp_pansi}" "https://raw.githubusercontent.com/snown/pansi/master/pansi" | |
fi | |
source "${tmp_pansi}" | |
fi | |
pansi "$@" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function sudo { | |
local _sudo="$(type -P sudo)" | |
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 | |
while true; do "${_sudo}" -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & | |
fi | |
"${_sudo}" "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment