Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "AmigaOS Manual: AmigaDOS Understanding the Shell"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
(Created page with "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...")
 
Line 113: Line 113:
   
 
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.
 
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.
  +
  +
Figure 2-3. 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:
  +
  +
{| class="wikitable"
  +
| 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 is the only Workbench-style mouse operation performed in Shell windows, except for within the ED and MEmacs text editors. Figure 2-4 illustrates copying and pasting from the Shell window to the ED window.
  +
  +
Figure 2-4. Copy and Paste
  +
  +
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. 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, ED, and MEmacs.
  +
  +
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.
  +
  +
{{Note|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.

Revision as of 17:40, 24 January 2014

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
  • Opening and closing Shell windows
  • Using the Shell

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 these exceptions:

  • Icons cannot be dragged into the Shell window.
  • The mouse can only be used for copy and paste operations, except within the ED and MEmacs text editors.
  • Scroll gadgets do not appear.
  • The AmigaDOS Shell window uses only a non-proportional font, normally the System Default Text font (Topaz or Courier) specified by the Font Preferences editor.
  • Any Workbench background patterns set in WBPattern do not appear in Shell windows.

Figure 2-1 illustrates a Shell window opened on the Workbench screen.

Figure 2-1. Shell Window

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.

Opening Shell Windows

Shell windows can be opened in one of two ways:

  • Click on the Shell icon in the Workbench System drawer.
  • Use the NEWSHELL command described in Chapter 6.

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, a small highlighted rectangle

Like Workbench, only the currently selected window can receive input. To enter information in a different window, click in it to make it the current window. While a Shell window is the current window, no menus are available in the Workbench title bar.

Closing Shell windows

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

  • Select the close gadget
  • Enter the ENDSHELL 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, enlarge the window by selecting the Shell zoom gadget or using the sizing gadget. This reveals as much of the previous contents of the window as fits. Figure 2-2 illustrates a Shell window before and after using the zoom gadget to display the entire output of a LIST command.

Figure 2-2. Revealing Previous Output with the Zoom 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.

Figure 2-3. 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 is the only Workbench-style mouse operation performed in Shell windows, except for within the ED and MEmacs text editors. Figure 2-4 illustrates copying and pasting from the Shell window to the ED window.

Figure 2-4. Copy and Paste

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. 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, ED, and MEmacs.

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.

Note
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.