From e6c35b7b14ba815b82a7377f16b06801d68700ce Mon Sep 17 00:00:00 2001
From: Case Duckworth
Date: Fri, 29 Jul 2022 17:04:24 -0500
Subject: bleh

---
 bash/aliases.bash   |  6 ++++
 bash/functions.bash | 81 ++++++++++++++++++++++++++++++++---------------------
 2 files changed, 55 insertions(+), 32 deletions(-)

(limited to 'bash')

diff --git a/bash/aliases.bash b/bash/aliases.bash
index 7875574..7b5ed55 100644
--- a/bash/aliases.bash
+++ b/bash/aliases.bash
@@ -27,3 +27,9 @@ alias rebash='source ~/.bash_profile'
 
 # Debugging
 alias emacs_goddamnit='pushd ~/.emacs.d;emacs --debug-init;popd'
+
+# other
+alias radio=radish
+if ! command -v fd >/dev/null 2>&1; then
+    alias fd=fdfind
+fi
diff --git a/bash/functions.bash b/bash/functions.bash
index 98872f2..c5bcddb 100644
--- a/bash/functions.bash
+++ b/bash/functions.bash
@@ -1,45 +1,62 @@
 # Functions
 
 memq() { # memq ITEM ARRAY
-    ## Test whether an ITEM is a member of ARRAY.
-    ## Pass ARRAY as ${ARRAY[@]}.
-    local e needle="$1"; shift
-    for e; do
-        [[ "$e" == "$needle" ]] && {
-            return 0
-        }
-    done
-    return 1
+	## Test whether an ITEM is a member of ARRAY.
+	## Pass ARRAY as ${ARRAY[@]}.
+	local e needle="$1"
+	shift
+	for e; do
+		[[ "$e" == "$needle" ]] && {
+			return 0
+		}
+	done
+	return 1
 }
 
 rebashrc() { # rebashrc
-    ## Reload ~/.bashrc
-    printf "Loading ~/.bashrc..." >&2
-    if source "$HOME/.bashrc"; then
-        echo "OK." >&2
-    else
-        echo "ERROR!" >&2
-    fi
+	## Reload ~/.bashrc
+	printf "Loading ~/.bashrc..." >&2
+	if source "$HOME/.bashrc"; then
+		echo "OK." >&2
+	else
+		echo "ERROR!" >&2
+	fi
 }
 
 first_which() { # first_which COMMAND...
-    ## Return the fully-qualified path of the first COMMAND found in $PATH.
-    while :; do
-        command -v "$1" && break
-        [ -z "$1" ] && return 1
-        shift
-    done
+	## Return the fully-qualified path of the first COMMAND found in $PATH.
+	while :; do
+		command -v "$1" && break
+		[ -z "$1" ] && return 1
+		shift
+	done
 }
 
 please() { # please [COMMAND...]
-    # if run without arguments, run the last command with 'sudo' (aka sudo !!)
-    # if run WITH arguments, alias as sudo
-    history -d -1
-    if [ -z "$1" ]; then
-        #set --	$(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q')
-        set -- $(fc -lnr | sed 1q)
-    fi
-    echo >&2 sudo "$@"
-    history -s sudo "$@"
-    "${DEBUG:-false}" || sudo "$@"
+	# if run without arguments, run the last command with 'sudo' (aka sudo !!)
+	# if run WITH arguments, alias as sudo
+	history -d -1
+	if [ -z "$1" ]; then
+		#set --	$(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q')
+		set -- $(fc -lnr | sed 1q)
+	fi
+	echo >&2 sudo "$@"
+	history -s sudo "$@"
+	"${DEBUG:-false}" || sudo "$@"
 }
+
+mkcd() {
+	if [ $# -lt 1 ]; then
+		command cd
+		return
+	fi
+	if ! [ -d "$1" ]; then
+		read -p "$1 doesn't exist.  Create (Y/n)? " yn
+		case "$yn" in
+		n* | N*) return 1 ;;
+		*) mkdir -p "$1" ;;
+		esac
+	fi
+	command cd "$1"
+}
+alias cd='mkcd '
-- 
cgit 1.4.1-21-gabe81