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
# shellcheck shell=ksh | |
# If SH_LIBPATH is not set or null, then we try to build it | |
if [ -z "${SH_LIBPATH+x}" ] || [ "${#SH_LIBPATH}" -eq "0" ]; then | |
for _path in /usr/local/lib/sh "${HOME}"/.local/lib/sh; do | |
[ -d "${_path}" ] && SH_LIBPATH="${SH_LIBPATH}:${_path}" | |
done | |
fi | |
unset -v _path | |
# Remove any leading colons from the construction process and export | |
SH_LIBPATH="${SH_LIBPATH#:}" |
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
software::fetch() { | |
local local_target remote_target | |
remote_target="${1:?No target specified}" | |
remote_target="$(curl "${remote_target}" -s -L -I -o /dev/null -w '%{url_effective}')" | |
local_target="${remote_target##*/}" | |
printf -- '%s\n' "Attempting to fetch ${remote_target}..." | |
curl "${remote_target}" > "${local_dir}"/"${local_target}" || return 1 | |
} |
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
# A function to prompt/read an interactive y/n response | |
# Stops reading after one character, meaning only 'y' or 'Y' will return 0 | |
# _anything_ else will return 1 | |
confirm() { | |
read -rn 1 -p "${*:-Continue} [Y/N]? " | |
printf -- '%s\n' "" | |
case "${REPLY}" in | |
([yY]) return 0 ;; | |
(*) return 1 ;; | |
esac |
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
# A function to update the PATH variable | |
# shellcheck disable=SC2120 | |
set_env_path() { | |
local path dir newPath | |
# If we have any args, feed them into ~/.pathrc | |
if (( "${#}" > 0 )); then | |
# shellcheck disable=SC2048 | |
for path in ${*}; do | |
if [[ -d "${path}" ]]; then |
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
brew::is_installed() { | |
local failcount | |
failcount=0 | |
if ! command -v brew >/dev/null 2>&1; then | |
printf -- '%s\n' "This script requires brew on a mac. This wasn't found..." >&2 | |
exit 1 | |
fi | |
for brew_pkg in ${*:?Package unspecified}; do | |
if brew list | grep -w "${brew_pkg}" >/dev/null 2>&1; then | |
printf -- '%s\n' "${brew_pkg} appears to be installed" |
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
#!/bin/bash | |
# check_idle_console - report on root capable interfaces with long sessions | |
# Purpose: | |
# This script tries to ensure that people don't leave ilo's logged in as root | |
# Author: Rawiri Blundell | |
# Copyright: See provided LICENCE file | |
############################################################################### | |
# Source the config mapping library | |
# Provides variables "${thisHost}", "${thisJob}" and | |
# positional parameters as "${arg1}" "${arg2}" etc. |
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
#!/bin/bash | |
# check_user_lastseen - report on users who have not logged in for a while | |
# Purpose: | |
# This script tries to find idle accounts and any orphaned homedirs | |
# Currently is Linux biased but capacity for portability is there | |
# Author: Rawiri Blundell | |
# Copyright: See provided LICENCE file | |
############################################################################### | |
# Source the config mapping library | |
# Provides variables "${thisHost}", "${thisJob}" and |
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
#!/bin/bash | |
# Script to set a per workspace desktop background in Cinnamon. | |
# Save as ~/bin/workspace_backgrounds_switcher.sh or | |
# ~/.local/bin/workspace_backgrounds_switcher.sh and make executable | |
# Add an entry in startup applications to launch the script on start-up. | |
# Set path to background images | |
background_path=/usr/share/backgrounds/linuxmint/ | |
# Select a random background from the aforementioned path |
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
ipv4::validate_addr() { | |
# Disable SC2086 for 'set -- ${*%/*}' as we require this to be word split | |
# shellcheck disable=SC2086 | |
( | |
IFS=.; set -f; set -- ${*//\"/}; set -- ${*%/*} | |
local octet; local count=0; local errcount=0 | |
if (( "${#}" == 4 )); then | |
for octet in "${@}"; do | |
(( ++count )) | |
case "${octet}" in |
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
# Regular Expression MANual page contents search | |
# Maybe I should have called this 'manscape' | |
reman() { | |
local width=$(( "${COLUMNS:-$(tput cols)}" - 10 )) | |
(( width > "${MANWIDTH:-$width}" )) && width="${MANWIDTH}" | |
export MANWIDTH="${width}" | |
case "${1}" in | |
(''|-h|--help) | |
printf -- '%s\n' \ |