Random : Add random_file.
This commit is contained in:
parent
187e8a48cf
commit
38a5791624
10
.config/bash/module/Random.sh
Normal file
10
.config/bash/module/Random.sh
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Picks a random file or directory.
|
||||||
|
function random_file() {
|
||||||
|
local IFS=$'\n'
|
||||||
|
local dirs=($(ls))
|
||||||
|
local total=${#dirs[@]}
|
||||||
|
((total--))
|
||||||
|
local index=$(shuf -i 0-${total} -n 1)
|
||||||
|
|
||||||
|
echo ${dirs[$index]}
|
||||||
|
}
|
Reference in a new issue