Copyright (c) 2012-2016 Hyperion Entertainment and contributors.

AmigaOS Manual: AmigaDOS Understanding the Shell

From AmigaOS Documentation Wiki
Jump to: navigation, search

An AmigaDOS Shell is a special window on the Workbench screen that accepts text input, allowing you to communicate with AmigaDOS. The Shell is a type of Command Line Interface or CLI. This chapter describes the following:

About the Shell

You can communicate directly with AmigaDOS through a Shell console window, a text-only interface that accepts input entered from the keyboard. The Shell window looks and acts like a Workbench window with some exceptions:

  • Icons dragged into the Shell window do not initiate a file move or copy operation; rather any icon dragged into the Shell window will cause the Shell to auto-type the icon's name and full path into the command prompt
  • The mouse has somewhat limited use; it can be used for copy and paste operations, except within the ED and MEmacs text editors, or for selecting autocompleted commands from a pop-up menu if enabled in the Shell preferences
  • Scroll gadgets work as you would expect, except that the length of Shell history captured may be limited by user preference
  • The AmigaDOS Shell window uses a non-proportional font by default, normally the System Default Text font, e.g. DejaVu Sans Mono, specified by the Font Preferences editor.
  • Any Workbench background patterns set in WBPattern do not appear in Shell windows

Like Workbench, several independent Shell windows can be open at the same time. While commands entered in one Shell are being executed, you can enter and execute different commands in another Shell window. You can also combine Shell windows into a single window, with each Shell session accessible via tabs. Figure 2-1 illustrates a Shell window opened on the Workbench screen:

Shell Window with Tabs

Opening Shell Windows

Shell windows can be opened in one of several ways:

  • Click on the Shell icon in the Workbench System drawer
  • Click on the Shell icon in your AmiDock (if enabled)
  • Use the NEWSHELL command described in Chapter 6
  • Select 'New shell' from any already open Shell session
  • Select 'Shell Here' from the 'New' submenu in any Workbench contextual pop-up menu

When a Shell window is opened:

  • The window is highlighted, indicating that it is the current window
  • A prompt appears, such as 1.SYS: >
  • To the right of the prompt is a cursor, the default being a small highlighted rectangle

Like Workbench, only the currently selected Shell can receive input. To enter information in a different Shell, click in its window (or select its tab) to make it the current Shell session.

Closing Shell windows

Use one of the following four ways to close a Shell window:

  • Select the close gadget
  • Select 'Close' from the Project menu
  • Enter the ENDCLI command
  • Press Ctrl+\

We recommend closing Shell windows when you are finished with them. Any open window uses memory.

All non-detached programs that run from a Shell must be finished before you can close the window. You can tell that a program is still active if pressing Return does not produce a Shell prompt in the window. Although you can still enter commands into such a window, AmigaDOS does not respond to the commands until the running program is exited.

Using the Shell

Enter AmigaDOS commands at the Shell's text prompt. Include with the command any necessary information, such as file names or command options. Press Return at the end of each command line to execute the command. The Shell prompt reappears when the command is finished executing.

To see command output that has scrolled out of the Shell window, use the scroller gadgets to scroll up or down; you can also enlarge the window by selecting the Shell zoom gadget or using the sizing gadget. The Shell window will keep a full scrollback history of as many lines as you specify using the Console prefs tool. Figure 2-2 illustrates a Shell window before and after using the zoom gadget to display the entire output of an INFO command.

Current Output
Revealing Previous Output with the Scroller Gadget

Command Line Editing and Control

To simplify entering and editing command line text, the AmigaDOS Shell provides the following editing key and key combination options:

left arrow Moves cursor one character to the left.
right arrow Moves cursor one character to the right.
Shift+left arrow Moves cursor to the beginning of the line.
Shift+right arrow Moves cursor to the end of the line.
Backspace Deletes the character to the left of the cursor.
Del Deletes the character highlighted by the cursor.
Ctrl+H Deletes the last character (same as Backspace).
Ctrl+M Processes the command line (same as Return).
Ctrl+J Adds a line feed.
Ctrl+W Deletes the word to the left of the cursor.
Ctrl+X Deletes the current line.
Ctrl+K Deletes everything from the cursor forward to the end of the line.
Ctrl+Y Replaces the characters deleted with Ctrl+K.
Ctrl+U Deletes everything from the cursor backward to the start of the line.

In addition, the Shell supports the following keys and key combinations:

Space bar (or any printable character) Suspends output (stops scrolling).
Backspace Resumes output (continues scrolling).
Ctrl+C Sends a BREAK command to the current process (halts the process).
Ctrl+D Sends at BREAK command to the current script (halts the script).
Ctrl+F Activates and brings Workbench program windows to the front.
Ctrl+S Suspends output.
Ctrl+Q Resumes output if it was suspended with Ctrl+S.
Ctrl+\ /O is redirected to another device with * restores normal |/O.

The Shell allows you to enter a command or other information while listing output. However, this stops the output until you press the Return key. The new command executes after the output is finished listing.

If you enter a new command or text and then choose to delete it, the original output resumes scrolling as soon as the last character is erased.

Using the Command History

The Shell uses a 2 KB command line buffer to retain command lines, which provides a command history. Using this history you can recall previously entered command lines, edit them, and re-execute them. This lets you easily repeat a command or enter several similar commands. Figure 2-3 illustrates a series of commands stored in the command history buffer.

Command History Buffer

The exact number of lines retained in the command line buffer varies depending on the length of the lines actually stored. When the buffer is full, the oldest lines are removed. You can access lines in the buffer with the up and down arrow keys:

up arrow Moves backward in the history buffer (earlier lines).
down arrow Moves forward in the history buffer (later lines).

For example, you can copy several .info files from one directory to another by enteringthe full command line with the complete path only once and then recalling the lines as many times as necessary, changing only the file name.

You can also search for the most recent occurrence of a specific command by entering the command line, or the beginning of it, and pressing Shift+up arrow (or Ctrl+R). For example, if you enter DIR and press Shift+up arrow, you are returned to the last command entered to perform a DIR of any directory. Pressing Shift+down arrow goes to the bottom of the command history buffer, leaving the cursor on a blank line.

Copying and Pasting

You can copy and paste information from one console window, such as a Shell or ED window, to the same or another window. This done by selecting commands in the Edit menu, just like in most Amiga tools. Figure 2-4 illustrates copying and pasting from the Shell window to a Notepad window.

Use the mouse to highlight the area of text to be copied and pasted. Highlight the text to be copied by moving the pointer to the beginning of the text area, holding down the selection button, and dragging the mouse pointer to the end of the desired text. Release the selection button and press Right Amiga+C or select Copy from the Edit menu. The highlighted area is copied into the Clipboard and the area is unhighlighted. The text you copied can be repeatedly pasted into any application window that supports reading text from the Clipboard, such as the Shell, Notepad, and MultiEdit.

To position the cursor where you want to paste the text, move the mouse pointer to that location and click. Press right Amiga+V to paste the text.

If a block of text is pasted into a Shell window, the Shell attempts to execute each line of the text as a command. This can have unpredictable results if the block of text has embedded returns and is not an AmigaDOS script.

Working with the Shell

The following are tips for speeding your work with the Shell.

Use command history and command line editing
It sometimes takes several attempts using the same command before getting it right, especially when you are first learning how to use AmigaDOS. Use the arrow keys to recall a previous command and change only the part of the line that causes the problem to eliminate the need to retype the entire line.
Use aliases
Defining short aliases for commands you use often is another time-saver. It also eliminates the need to remember a long and/or complex series of options. For complete instructions, see the ALIAS command in Chapter 6.
Omit unnecessary keywords
For clarity, AmigaDOS command names and keywords throughout this book are often shown although they are optional. When you learn a command's format, however, you seldom need to include optional keywords.
Do not use capital letters
Command names, keywords, and assigned directories are shown in all upper case letters throughout this manual even though AmigaDOS is case-indifferent. This is done to distinguish the keywords from the file names and other information on the example command line. There is no need to use capitalization, except in commands that create a file or directory whose name you want to appear capitalized.
Use implied CD
This allows you to leave out the CD command, saving three keystrokes. Enter the only directory name, path, colon, or slashes at the prompt to change directories. For more information about changing directories, see the CD command in Chapter 6.