I'm slowly coming to understand how to do some fun things behind the scenes in Linux. I just finished this shell script which arose from this thread. It's just a handy little script that reads all the
.scm files in a directory and outputs a
menus.txt file that has every appearance of a menu-registry marker ("<Image>...", etc) along with the script file name and the line number in the script where the marker appears. So when you run the script you get something like this;
10pct_edge_guides.scm 42 "<Image>/Image/Guides"
10pct_grid_guides.scm 77 "<Image>/Image/Guides"
1_inch_guides.scm 68 "<Image>/Image/Guides"
1_motif_pattern.scm 251 "<Image>/File/Create/Patterns/1 Motif Pattern ..."
20centfox.scm 3 "<Image>/Script-Fu/20 Cent Fox Text"
Not necessarily the most useful tool in the world. But it does offer a convenient reference. It's essentially like having the plug-in browser available at a glance.
I'm sure the code is sub-optimal. But it does function well enough. I don't know how much editing it might need to work on other OSes. It uses
grep, awk, and printf to find, parse, and print the data.
Here it is. Maybe those who know more than I do can tidy it up, port it, or enhance it somehow.
# This script uses grep to locate all the lines in a directory of
# GIMP scripts which contain menu path markers ("<Image>..." etc).
# The -nHo flags cause grep to output the line number of the marker,
# the file name, and the complete string it matched.
# The raw grep output is cluttered and difficult to read.
# So I sent it to printf via awk to be organized in tidy columns.
# While this script was specifically designed to search for menu
# paths in GIMP script files it may have other uses.
# Note that this script does not distinguish between menu registers
# and other strings that contain "<*****". So you will get multiple entries
# for some scripts. The line numbers make it easy to navigate a text
# editor to see what's going on.
# Also, at the moment this script is limited to working on the directory
# in which it is called. It wouldn't be difficult to change the code to search
# for all scm files on your system. I didn't see a need to do so since
# most of us keep our scripts in one place.
IFS=$'\n'; for f in *scm; do grep -nHo '"<[A-Z].*"' $f | awk -F: '{ printf "%-52s %-7u %-30s\n", $1, $2, $3 }' >> menus.txt; done
The code window puts a line break in the actual script code. I'm not sure how to edit the window properly to show the code in a functional way. So just know that it was written as a one-liner.
*EDIT*
Trying to fix some formatting issues caused by the code window. Not sure if it's just my browser. But I don't want to create problems for people who want to copy the code.
_________________
Just a short while ago I was a complete idiot when it comes to GIMP. Today, after many hours of practice, reading, and watching tutorials, I am proud to say I am an incomplete idiot.