Sagasu

Sagasu is a GNOME tool to find strings in a set of files. The user specifies the search directory and the set of files to be searched. Double-clicking on a search result launches a user command that can for example load the file in an editor at the appropriate line. The search can optionally ignore CVS directories.

Two optional command-line arguments can be given: the first is the initial search string and the second is the directory whose files will be searched. If only one argument is given, it is taken as the search string. No search is actually started, but the appropriate fields are initialized. Any subsequent arguments are ignored.

Example: sagasu printf /usr/include

The Dialog

Fields

The Search string field is where you type the string to be searched. This string can be a Perl regular expression. You can start the search by clicking the Search button or by pressing the Enter key in any text field.

The File patterns field is where you specify a blank-separated list of patterns that define the set of files to be searched. The Defaults button at the right of this field sets it to its default value, which is *.c *.cc *.C *.cpp *.cxx *.h. To search all makefiles in a project, you could specify a pattern like Makefile* so as to include all Makefile.in and Makefile.am files.

The Search directory field is the directory whose files will be searched. The Browse... button shows a file selection dialog. You can also type the directory name manually. The ~user notation is supported. A ~ alone refers to the current user's home directory.

In the Editor command field, the term %f can be used to represent the filename found in the double-clicked line. The term %n can be used to represent the line number. For example, to start the vi editor in a GNOME terminal, use this editor command:

gnome-terminal -e "vi +%n '%f'"

This happens to be the default command. The Default button at the right of the field sets it back to the default command.

Search options

There are check boxes that allow you to determine:

There is also a numeric field where you can specify the depth of subdirectories into which the search is allowed to recurse. If you specify zero, only files in the search directory will be searched, and not the files that are in subdirectories.

Result Tabs

The application opens with a single, empty result tab. The text buffer under a tab is where the search results are displayed. You can create new result tabs by using the New Tab command in the File menu. You can also do that with the Ctl+N key sequence.

Each tab has a number and an 'x' icon. This icon can be clicked to close the tab. You cannot close a tab if it is the only one.

During and after a search, the number of matching lines and the number of matching files are displayed below the text buffer.

You can double-click on a line in a result tab to execute the "editor command." The default editor command starts the vi text editor in a GNOME terminal. vi accepts an optional argument of the form +N where N is a line number at which to position the cursor initially.

At the bottom of the Sagasu window is a text field where you can enter text to be searched inside the currently selected result tab. Click the "Find in results" button to start the search. At the right of this button, Sagasu will show either at what percentage of the result text the string was found, or that the string was not found. This search is always case-insensitive.

Saved Configuration

The search parameters and the main window's size are saved in a GNOME configuration file (~/.gnome/sagasu) when the Search button is clicked and when the application exits. Those parameters comprise the text fields and the check buttons, but not the set of open result tabs.

Interrupting the Search

When a search has started, the Search button becomes a Stop button. You can click this button to interrupt the search.

Command-Line Options

--help
display a help page and exit
--version
display version information and exit

License

This program is free software; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty.

Author

See the Sagasu Home Page.

Bugs

History

Sagasu is a Japanese word that means "to search." Because of a lack of talent, I have a lot of trouble finding program names that are not already taken, especially if they are based on English, French or Latin. Exploring Japanese words proved to be a fruitful alternative.