diff options
author | Case Duckworth | 2022-09-13 18:06:16 -0500 |
---|---|---|
committer | Case Duckworth | 2022-09-13 18:06:16 -0500 |
commit | d2dad3460399150447f8ede875a469cdf7cd5f31 (patch) | |
tree | 0e4d6775270ac06c3920daea9c3a6ae1a04f361c /bash/functions.bash | |
parent | bleh (diff) | |
download | etc-d2dad3460399150447f8ede875a469cdf7cd5f31.tar.gz etc-d2dad3460399150447f8ede875a469cdf7cd5f31.zip |
meh.
Diffstat (limited to 'bash/functions.bash')
-rw-r--r-- | bash/functions.bash | 33 |
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...] | |||
48 | mkcd() { | 48 | mkcd() { |
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 | } |
62 | alias cd='mkcd ' | 67 | alias cd='mkcd ' |
68 | |||
69 | # from tomasino | ||
70 | # alias julian='echo "x = $(date +%s); scale=5; x / 86400 + 2440587.5" | bc' | ||
71 | julian() { | ||
72 | echo "x = $(date ${1:+-d "$*"} +%s); scale=5; x / 86400 + 2440587.5" | bc | ||
73 | } | ||
74 | |||
75 | # find files for pipelines | ||
76 | f() { | ||
77 | find "${1:-$PWD}" -depth | | ||
78 | while read -r file; do | ||
79 | printf '%q\n' "$file" | ||
80 | done | ||
81 | } | ||
82 | |||
83 | words() { | ||
84 | grep "$1" /usr/share/dict/words | ||
85 | } | ||
86 | |||
87 | dict() { | ||
88 | curl "dict://dict.org/d:$1" | less | ||
89 | } | ||