about summary refs log tree commit diff stats
path: root/bash/functions.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/functions.bash')
-rw-r--r--bash/functions.bash33
1 files changed, 30 insertions, 3 deletions
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...]
48mkcd() { 48mkcd() {
49 if [ $# -lt 1 ]; then 49 if [ $# -lt 1 ]; then
50 command cd 50 command cd
51 return 51 return "$?"
52 fi
53 if [ "x$1" = x- ]; then
54 command cd -
55 return "$?"
52 fi 56 fi
53 if ! [ -d "$1" ]; then 57 if ! [ -d "$1" ]; then
54 read -p "$1 doesn't exist. Create (Y/n)? " yn 58 read -p "$1 doesn't exist. Create (y/N)? " yn
55 case "$yn" in 59 case "$yn" in
56 n* | N*) return 1 ;; 60 n* | N*) return 1 ;;
57 *) mkdir -p "$1" ;; 61 y* | Y*) mkdir -p "$1" ;;
62 *) return 1 ;;
58 esac 63 esac
59 fi 64 fi
60 command cd "$1" 65 command cd "$1"
61} 66}
62alias cd='mkcd ' 67alias cd='mkcd '
68
69# from tomasino
70# alias julian='echo "x = $(date +%s); scale=5; x / 86400 + 2440587.5" | bc'
71julian() {
72 echo "x = $(date ${1:+-d "$*"} +%s); scale=5; x / 86400 + 2440587.5" | bc
73}
74
75# find files for pipelines
76f() {
77 find "${1:-$PWD}" -depth |
78 while read -r file; do
79 printf '%q\n' "$file"
80 done
81}
82
83words() {
84 grep "$1" /usr/share/dict/words
85}
86
87dict() {
88 curl "dict://dict.org/d:$1" | less
89}