# run something recursively over all directories.
# usage: recursive [COMMAND]
recursive()
{
local IFS=$'\n'
local current="${PWD}"
local dirs=$(find -type d)
local total=$(find -type d | wc -l) # TODO: don't call find twice. won't work with "echo ${dirs}".
local count=0
for dir in ${dirs}; do
# increment counter.
((count++))
# cd into the next dir.
cd "${current}"
cd "${dir}"
# echo status.
echo -e "${color_bblue}[${count}/${total}] ${dir}${color_default}"
# run command.
$*
done
# return back on complete.
}
recursive1() # TODO: create generic function.
local dirs=$(find -mindepth 1 -maxdepth 1 -type d)
local total=$(find -mindepth 1 -maxdepth 1 -type d | wc -l) # TODO: don't call find twice. won't work with "echo ${dirs}".
# autocomplete.
complete -F _autocomplete_nested recursive recursive1