From d2dad3460399150447f8ede875a469cdf7cd5f31 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 13 Sep 2022 18:06:16 -0500 Subject: meh. --- bash/functions.bash | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'bash/functions.bash') diff --git a/bash/functions.bash b/bash/functions.bash index c5bcddb..64e8001 100644 --- a/bash/functions.bash +++ b/bash/functions.bash @@ -48,15 +48,42 @@ please() { # please [COMMAND...] mkcd() { if [ $# -lt 1 ]; then command cd - return + return "$?" + fi + if [ "x$1" = x- ]; then + command cd - + return "$?" fi if ! [ -d "$1" ]; then - read -p "$1 doesn't exist. Create (Y/n)? " yn + read -p "$1 doesn't exist. Create (y/N)? " yn case "$yn" in n* | N*) return 1 ;; - *) mkdir -p "$1" ;; + y* | Y*) mkdir -p "$1" ;; + *) return 1 ;; esac fi command cd "$1" } alias cd='mkcd ' + +# from tomasino +# alias julian='echo "x = $(date +%s); scale=5; x / 86400 + 2440587.5" | bc' +julian() { + echo "x = $(date ${1:+-d "$*"} +%s); scale=5; x / 86400 + 2440587.5" | bc +} + +# find files for pipelines +f() { + find "${1:-$PWD}" -depth | + while read -r file; do + printf '%q\n' "$file" + done +} + +words() { + grep "$1" /usr/share/dict/words +} + +dict() { + curl "dict://dict.org/d:$1" | less +} -- cgit 1.4.1-21-gabe81