Customizing the Options File


The $HOME Directory

Before you can edit the options file, you must first locate it by figuring out what your home directory is. If you do not know what you home directory is, type the following at your command prompt.

    
> echo $HOME
    
/home/wesb

In this case, /home/wesb is the home directory. If you haven't already done so, switch into your home directory now.

    
> cd $HOME

The tkWorld Directory

Now that you are home, you can switch into the tkWorld directory. First lets find all the files which begin with .tk so we can figure out what is your tkWorld directory.

> ls -l .tk*

.tkWorld-0.03:

total 11

drwx------   2 wesb   wesb   1024 Jan 31 00:07 .

drwxr-xr-x  37 wesb   wesb   3072 Feb  2 21:38 ..

-rw-------   1 wesb   wesb   2699 Jan 31 00:07 .tkGreprc

-rw-------   1 wesb   wesb   2699 Jan 31 00:07 .tkGreprc.old

-rw-------   1 wesb   wesb    769 Jan 31 00:07 tkGrep.ex

In this example, there is a directory called .tkWorld-0.03 which has 3 files in it. First off, the dot (.) is the first character in the directory name. This means that the directory is hidden from simple directory listings like ls. Consult a Unix/Linux Operating System book for a technical definition of the directory structure and the role of hidden files.

What do the numbers in .tkWorld-0.03 mean? The first one after the dash indicates the current release (distribution), in this case zero since tkWorld is not finished yet. The numbers after the second dot point out how man tools are available in the tkWorld release that you have. The figure below summarizes the numbers.

How did this directory and it's files get created? After launching tkGrep for the first time, it checks if they already exist. Since they do not, the application creates the .tkWorld-0.03 directory, as well as the default application files. In the current example, there are three files in the tkWorld directory.

The first file is the options file which you can customize. The second file, .tkGreprc.old, is a backup of the original options file which can be used to restore tkGrep to it's default behavior. The last file is the example file that the application defaults to using when no filenames are given at runtime (see the first example in String Searches).

The .tkGreprc File

The section below lists a few rules which define the layout of the .tkGreprc file.

Option File Rules

  1. Comments begin with the pound sign (#).
  2. The colon (:) is the option delimiter.
  3. The Label String is on the left of the colon.
  4. The Command Line Option is on the right of the colon.
  5. Options must be on separate lines.

Lets look at an example. The following line is un-commented in the options file

    
Invert Matching:-v

The Invert Matching is the label string and is on the left side of the colon. The -v is a grep command line option and is on the right side of the colon. When tkGrep is run, the above line produces the following Command Center option button.

The default un-commented option lines are listed below.

  1. Extended Regular Expression:-E
  2. Invert Matching:-v
  3. Case Insensitive Search:-i
  4. Print Line Number In File:-n

Customizing the file can be done by removing the comment from (adding a comment to) any option that you want to appear (or not appear) in the interface. Original user options can also be added in the options file too. For example, if you find that you are always using the Extended Regular Expression, Case Insensitive Search, and Print Line Number in File options, you could add your own custom option like

    
My Favorite Option:-Ein

in the .tkGreprc file, while commenting out the other three options. This customization changes the Command Center display the next time the application is run. The figure below illustrates the changes.

Notice that Print Line Number In File appears before My Favorite Option. This brings up the final point that Command Center option buttons are built from left to right in pairs, in the order they are encountered in the .tkGreprc file. In this particular case, the new customization was added at the end of the options file.

Reminder!

To find all the Command Line Options for grep at your site, type man grep at your shell prompt.