2020-12-29 08:38:07 -08:00
|
|
|
#!/usr/bin/env sh
|
2024-07-23 00:04:57 -07:00
|
|
|
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
|
2021-09-23 06:48:05 -07:00
|
|
|
|
|
|
|
# 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
|
|
|
|
### ```
|
2021-07-29 05:44:12 -07:00
|
|
|
find -maxdepth 1 -type d \( -path '/root' -prune -o -print \) | tail -n+2 | shuf | head -n1
|
2021-07-29 00:37:35 -07:00
|
|
|
}
|
|
|
|
|
2021-08-02 13:48:46 -07:00
|
|
|
[ -n "${preload+-}" ] || randir "$@"
|