#!/bin/bash
# https://www.commandlinefu.com/commands/view/20399/define-a-bash-function-to-interactively-pick-a-subdirectory-to-cd-into
#                       /usr/local/bin/cdb
# https://crystalfaeries.net/posix/bin/cdb
# celeste:crystalfaery CDB Sat, 08 Apr 2017 18:21:15 UTC

if [ $# -eq 0 ]
then
	search="`pwd`"	# default to CWD
else
	search="${1}"
fi
# echo "SEARCH: ${search}"
select dir in $( find ${search} -type d \! -name '.??*' )
do
	cd "${dir}" && break || exit $?
done
pwd 1>&2


syntax highlighted by Code2HTML, v. 0.9.1