### Using shell windows

A window can be set to shell mode using the Settings menu. Also, you may toggle a window between being a regular document and being a shell by clicking the shell rectangle in the status bar:

In shell mode shell commands can be executed just as in a terminal shell. You may for instance type ls and hit return. Unlike a terminal shell one can store the commands in the document and reuse them because a shell window in Eddie saves and allows editing same as a regular document window. This gives the user a convenient alternative to having a shell history - common shell commands or interresting shell command output can be saved in the shell document for next time. There is an actual bash shell running in each shell window. You can use make, cd, ls, grep, etc. You may set shell variables, aliases and other shell state. In addition Eddie defines some builtin shell commands. Editing still works the way it does in other document windows.

#### Executing commands in a Shell window

To execute a shell command, you type the command in and hit return:

You will get something like:

If you select a part of a line and hit return, only the selected part will get executed:

In our example the output of ls gets inserted right after the executed command:

Note that only the selected ls part of the command got executed, the grep part was ignored. Also note that unlike in a normal edit, when executing a selection in the shell window, the executed selection does not get deleted first.

To get rid of temporary shell output and keep it from poluting your shell window, you may use Undo.

#### Special shell window shortcuts

Return | executes a selection or an entire line as a shell script
Ctrl-Return | acts as Return in a normal window - it just inserts a new line. This is useful when you do not wan't to execute the line you just typed in
Ctrl-C | sends a break signal to the shell, stopping makes, etc.
Tab | completes a path; repeated use will bring up a popup panel with suggested completions
Ctrl-Tab | inserts a tab character

As with most other keyboard shortcuts, all of the above can be remapped. You may for instance prefer the more MPW-like mapping of Enter to act as na execute command and Return to just insert a newline. You may do this by customizing your UserStartup file with the SetKey commands.

#### Shell prompts

Shell prompts appear in the status rectangle in the button bar. If the shell is executing, a prompt will be light blue - in the following example the shell window is busy executing a sleep command:

As with a terminal shell, you can customize the prompt format by adding a corresponding entry to the ~/.profile file. You may for instance add the following line:

    PS1="\$PWD"" :"

Note that the shell does not support terminal escape sequences. It is therefore not possible to run tools like vi and more. Hopefully the editor text editing capabilities will offset for this deficiency. Telnet, more and other shell tools requiring terminal escape sequences won't work either.

#### Shell tool prompts

Some shell tools prompt the user for input. For instance FTP when invoked will present the user with it's own interface of prompts. Eddie has a tough time handling prompts like this. Unlike bash prompts, distinguishing these prompts from normal output and handling them appropriately is much harder since the prompts may have any form. Eddie still recognizes prompts like this - as tenative prompts, using a self-correcting heuristic. It displays them in red in the status bar, allowing the user to answer with appropriate input. In our example FTP is prompting for user name and the user can go ahead and type it in:

In some cases Eddie will get confused for a few seconds and mark some output as a tenative prompt momentarily, displaying it in red in the status bar. It will correct itself once it finds out that it is not an actual prompt - it will include the prompt text in the Worksheet output.

Note that simply writing out the prompts into the Worksheet would not work - any input text you would type would get appended to the prompt itself and sent back as your reply to the shell tool, very likely with an undesired result.

#### Pathname Tab completion

Eddie Shell windows support tab completion. You can type in one or two characters of a path and hit Tab, Eddie will fill in the remainder of a path, unless there are several completions that can match the characters you already typed in. You may combine typing a character or two and hitting Tab repeatedly, just like in the Bash shell. When there are multiple or no possible completions, Eddie beeps.

If you hit Tab again, Eddie will suggest possible completions in a temporary panel. The panel will disappear once you click the mouse or type another key. Like Bash, Eddie will complete shell variables and use them when expanding pathnames. Unlike Bash, Eddie will leave the variable in it's original symbolic form, the completion mechanism evaluates it though to suggest a completion.
Note that Eddie currently does not complete everything in your current $PATH, just absolute paths and paths relative to your current directory.