You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
herewith a bash script in order to lookup for a function definition inside a project folder.
Using this script you can directly jump to a function!
Regards,
Feek
#!/bin/bash
[[ -f"${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] &&."${TM_SUPPORT_PATH}/lib/bash_init.sh"
function_name="$TM_CURRENT_WORD"
project_dir="$TM_PROJECT_DIRECTORY"# find php-related files in project directory, result is a string
files_string=`find "$project_dir" -type f | egrep '\.(module|inc|php|engine|install)$'`# place multi-line sting in a array, works for file names with spaces!
files_array=()
whileread -r line;do
files_array+=("$line")
done<<<"$files_string"## Lookup for a function declaration inside the file content.# multi space allowed in function declaration# <file> <function>#functionlookup_function {
local line=`nl -b a "$1"| grep 'function\\s\+'"$2"'\\s*('| awk '{print $1}'`if [[ "$line"-gt 0 ]];then
mate "$1" -l "$line"exit 0
fi
}
# Iterate the array with files, works for files with spaces!for(( i=0; i <${#files_array[*]}; i++));do
file="${files_array[${i}]}"
lookup_function "$file""$function_name"done# Nothing foundecho'NOTE: Function '${function_name}' was not found within the current project directory.'
The text was updated successfully, but these errors were encountered:
Hi,
herewith a bash script in order to lookup for a function definition inside a project folder.
Using this script you can directly jump to a function!
Regards,
Feek
The text was updated successfully, but these errors were encountered: