Tips on using Shell windows

Set up your bash prompt to show current path

It is convenient set up your bash prompt in your .profile to display the current directory - making it appear in the Status bar rectangle. You may do this by adding the following line to ~/.profile :

PS1="\$PWD"": "

One convenient way of doing this is activating your Worksheet, typing

 ~/.profile
placing the cursor anywhere in the typed text and pressing Command-D (Open selection). The .profile file will open and you may edit it. After saving and closing it you may either quit/restart Eddie or execute:
. ~/.profile
in the Worksheet to activate the change


Getting rid of shell command output.

Typically, you will keep the Worksheet window clear of any temporary command spew and only keep the actual commands (with arguments, etc.) you wish to re-execute again in the future. To quickly get rid of output from say a compile, you may use the Undo feature - the entire shell output will get deleted. This is usually faster than selecting all this output and deleting it.

To select all the output an execution of a shell command produced, use Undo and Redo - the output will get deleted, re-inserted and selected.


Fixing compile errors.

When fixing syntax errors during a compile using gcc, place the cursor anywhere in the file path name and press Command-D.

~/src/Eddie/shell/filelist/FileList.cpp:1123: parse error before `&'
The file will open. If the error line also contains a line number as in our example, the line will get selected

With clang, (unsurprisingly, since it's just about the world's best compiler), things get even better:

./shell/filelist/FileList.cpp:1123:3: error: unknown type name 'atuo'; did you mean 'atto'?
                atuo match = find(fObservers.begin(), fObservers.end(), entry);
                ^~~~
                atto
The error output includes both the line and the column where the error occurred, placing the cursor anywhere on the line and hitting Command-D will place the cursor right on the miss-typed "auto".


Using grep from the Worksheet.

When using grep from the Worksheet, using the -n option will help opening the resulting files and selecting the corresponding line:

grep -n AddString */*/*.[ch]*
filelistwindow/FileListMisc.cpp:472: addMessage.AddString("group_name", name);
filelist/FileFinder.cpp:169: recentHeaderList->AddString(path.Path());
Here again, you may use Command-D to open the result instantly with the matching line selected.


Entering a newline, Tab.

Tab and Return keys have a special function in shell windows - they invoke tab completion and execute a selection respectively. To enter a Tab in a Shell/Worksheet window, press Option-Tab. To enter a newline, press Control-Return. Note that as with any other keyboard shortcut these are configurable in the UserStartup file, you may for instance remap Execute to the traditional MPW-like Command-Return if you prefer.


Switching a text window into a shell window.

You may turn any window into a shell window quickly by clicking the empty shell icon rectangle in the button bar (rectangle next to the dirty/read only icon). This may be useful if you want to use a shell command in a document but don't want to switch to the worksheet. After you are done with the shell command, switch back to text editing only mode by clicking the shell icon again.


Saving a Shell window.

If you save a Shell window and re-open it in Eddie, it will remember that it was a Shell document and automatically open as such, restoring the directory it was last in. This way you can save different shell windows with batches of commands for different operations you may be doing now and then (for instance commands for doing a merge of a branch in your source control system). Since you use these infrequently, instead of keeping these in the Worksheet, you can instead save them in their own custom shell. When you reopen this shell, it will be all set up for you to start selecting and executing these commands.


Adding Eddie specific setting to your ~/.profile

You might want to make your Eddie shell behave slightly different than a shell in a Terminal window. To do this, you may add Eddie-specific commands into the .eddieShellProfile or .eddieWorksheetProfile. Also, you may add Eddie- specific commands directly to the ~/.profile file. You may for instance prefer to only have a customized prompt when running Eddie. To do that, you can check the $EDDIE environment variable in ~/.profile:

if [$EDDIE"*" = "*"]; then
	# add Terminal-only setup commands here
	# this part gets executed when Eddie is not running (you are running
	# the shell from Terminal)
	# set up Eddie for Perforce, use full path (may break if you move the app)
	export EDITOR='/usr/bin/tellEddie -w' 
else
	# add Eddie specific setup commands here
	# pwd displaying prompt
	PS1="\$PWD"": "
	# set up Eddie for Perforce using the exported EDDIE_HOME variable - this
	# setup does not depend on the location of the Eddie folder
	export EDITOR='$EDDIE_HOME/tellEddie -w'
fi

Note that the bash variable $PROMPT_COMMAND is used by Eddie for capturing the shell prompt and cannot be changed by the user. $PROMPT_COMMAND is typically used in Terminal to change the title of a Terminal window when a directory changes or other setup. Hopefully you will not miss this feature in Eddie. If you do set up $PROMPT_COMMAND in ~/.profile, you need to place in the non-Eddie part of the if statement in the example above.


More Eddie specific shell variables

Eddie exports exports a variable $TARGET. This variable returns the pathname of the document opened in the Target window. A Target window is the one behind your current Shell or Worksheet window.

Eddie also exports two variables, $_TS and $TS_. These represent the selection in the Target window. The first can be used to read the selection, the second to write into the selection. This lets you issue handy commands like:

cat < $_TS
# to print the selection from your TARGET window into the Worksheet
date > $TS_
# to paste the date/time into your TARGET window
sort < $_TS > $TS_
# to sort selected lines in the TARGET window (great for sorting #includes, etc.)	

See a full list of Eddie-specific shell environment variables for more.