1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 07:29:04 -08:00
rc/sh/randir

17 lines
359 B
Text
Raw Normal View History

#!/usr/bin/env sh
# compat: +ash +bash +dash +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
### ```
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 "$@"