jmod - quick jump to a module

This commit is contained in:
Adolfo Perez Alvarez 2022-09-07 11:54:31 +02:00
parent 8e49bcb05d
commit e57032ae8b

26
jmod Normal file
View File

@ -0,0 +1,26 @@
function jmod
{
typeset dir root sel
typeset -a dirs names
typeset -i i=0
(( $# != 1 )) && return 64
root=$(jr && pwd)/modules/apps
set -A dirs $(find $root -maxdepth 2 -mindepth 2 -type d -iregex ".*/[^/]*$1[^/]*" | sort)
(( ${#dirs[@]} == 0 )) && return 1
for dir in ${dirs[@]}
do
names[$i]=${dir##*/}
let i++
done
if (( ${#names[@]} > 1 ))
then
select sel in ${names[@]}
do
print ${sel} && cd ${dirs[(( REPLY - 1 ))]}
break;
done
else
print ${names[0]} && cd ${dirs[0]}
fi
}