Skip to content

Instantly share code, notes, and snippets.

@splace
Last active December 11, 2019 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save splace/4d186d2ed8642d39a5ab5ca090f2b6ba to your computer and use it in GitHub Desktop.
Save splace/4d186d2ed8642d39a5ab5ca090f2b6ba to your computer and use it in GitHub Desktop.
gedit tool to search go-lang package files for text and produce clickable links to the files/lines found.
#!/bin/sh
# [Gedit Tool]
# Name=find
# Languages=go
# Input=nothing
# Output=output-panel
# Applicability=all
# Save-files=nothing
# Shortcut=<Primary><Shift>f
# search selected (text) in all go files in CWD
# use zenity query when no selection
if [ -z "$GEDIT_SELECTED_TEXT" ]; then
GEDIT_SELECTED_TEXT=`zenity --entry --title="Find in files" --text="Find:" --entry-text "XXX"` || exit 1
fi
# with all (non-test) go files in current dir;
for filename in *.go
do
case $filename in *_test.go) continue;; esac
awk "/$GEDIT_SELECTED_TEXT/{ print FILENAME\":\"NR\":\", \$0 }" $filename
done;
# with test files.
for filename in *_test.go
do
awk "/$GEDIT_SELECTED_TEXT/{ print FILENAME\":\"NR\":\", \$0 }" $filename
done;
@splace
Copy link
Author

splace commented Dec 11, 2019

file format, the meta data comments, are for gedit 3+
but cut/paste into 'manage external tools' for all versions.
and/or change "GEDIT" to "PLUMA" for Pluma.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment