1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-14 09:19:02 -08:00
rc/sh/randir

20 lines
369 B
Text
Raw Normal View History

#!/usr/bin/env sh
2021-07-29 00:37:35 -07:00
# YES_ZSH
# YES_BASH
# YES_DASH
2021-09-23 06:48:05 -07:00
# YES_ASH
# works with busybox.
2021-07-29 00:37:35 -07:00
2021-07-30 17:57:08 -07:00
randir() { ### @-
### display a random directory in the current working directory.
###
### ```
### $ randir
### ./sh
### ```
find -maxdepth 1 -type d \( -path '/root' -prune -o -print \) | tail -n+2 | shuf | head -n1
2021-07-29 00:37:35 -07:00
}
[ -n "${preload+-}" ] || randir "$@"