Previous Next Chapter

Occasional Tasks

Tasks in this section are used les often, but almost every user needs to do these things at some time. These examples assume a certain amount of familiarity with AmigaDOS and the Shell.

Creating Aliases To Reduce Keystrokes

The aliases listed below can help speed your Shell work by reducing the number of keystrokes required for common commands.

To enable these as global aliases, edit S:Shell-startup as described previously for User-startup, adding these lines:

ALIAS c0 CD DF0:
ALIAS cs CD SYS:
ALIAS css CD S:
ALIAS d0 DIR DF0:
ALIAS dr DIR RAM:
ALIAS qdir DIR ~ (#?.info)
ALIAS 1s LIST
ALIAS cp COPY
ALIAS cc COPY [] CLONE
ALIAS del DELETE
ALIAS ren RENAME
ALIAS ns NEWSHELL
ALIAS es ENDSHELL
ALIAS pf printfiles
ALIAS fmt0 FORMAT DRIVE DF0: NAME [] FFS NOICONS DIRCACHE
ALIAS edus RUN ED S:User-startup
ALIAS edsh RUN ED S:Shell-startup
ALIAS ednew RUN ED RAM:newfile
ALIAS chip ECHO "There are `avail chip` bytes of Chip memory free."

Modify the alias names as desired. Use these as models for your own aliases.

Customizing NEWSHELL

You can control the Shell window with the WINDOW argument of the NEWSHELL command. It allows you to specify custom sizes, positions, and features for the Shell window. Following are two examples of different window specifications.

To open a convenient Shell window on your Workbench screen, enter the following command in a Shell or as a line in User-startup:

NEWSHELL CON://400/100/Ashell/CLOSE/
ALT0/12/640/388

This creates a small Shell window titled AShell that leaves the left side of the Workbench window clear so that disk icons are not obscured. It has a close gadget and, on a High-Res Interlace screen, it expands to fill the entire screen for the screen title bar when you select its zoom gadget.

To open a Shell window on a public screen, such as telecommunication program's terminal screen, use a window specification with the SCREEN option:

CON:0/20//???/CLOSE/SCREENTerm

This creates a Shell window called ??? that is near the top of the screen and is as wide and short as possible. The window opens on a public screen named Term, if that screen is available. It it is not, the Shell opens on the Workbench screen.

Modifying the Prompt

The Shell prompt is easily modified using the PROMPT command. You can add any fixed text to the prompt string and include, reorder, or leave out the substitution operators that display the process number, current directory, and return code. Placing escape sequences in the prompt string lets you make the prompt stand out visually from the command line and command output. You can also embed a command in the prompt with the back apostrophe feature.

Figure 8-2 illustrates two ways of modifying the prompt. The first uses escape sequences to produce a boldface, color 2 (white) prompt; see Appendix D for a listing of escape sequences. The second shifts the usual position of the substitution operators, embeds a DATE command using the back apostrophe, and changes the final character to a dollar sign ($).

Figure 8-2. Sample Uses of PROMPT Command

Creating a Custom Ram Disk Icon

To have a custom icon for the Ram Disk, you need to place a COPY statement in User-startup. First, create the icon in IconEdit. Make sure it is a Disk type icon, then save it on your boot disk as DEVS:Ramdisk.info.

Note:

This example uses the DEVS: directory, but it does not matter where you store this icon. It is not visible, even in Show All Files mode, because Disk icons are visible only in the Workbench window.

To make your custom Ram Disk icon appear in the Workbench window, enter this line in the S:User-startup file, save the changed file, and reboot:

COPY DEVS:Ramdisk.info TO RAM:disk.info

If you also want to rename Ram Disk, include a RELABEL statement in User-startup after the COPY statement, such as:

RELABEL RAM:ramname

Deleting Files with Icons

To delete a file that has an icon and the file's.info file with a single command:

  1. Create and save the following script as S:Delinf:

.KEY file/A

DELETE <file> <file>.info QUIET

  1. Enter EXECUTE Delinf with the name of the file as its argument.

Testing Commands

It is sometimes necessary to test the results of certain commands before using them on actual files. This is particularly true when using complex pattern matching with potentially destructive commands, such as DELETE, or escape sequences, with which it can be difficult to predict the outcome. There are various ways of testing commands that are quick and safe.

To test a potentially destructive pattern matching command:

  1. Enter a non-destructive command such as LIST containing the pattern. For example,

LIST ~ (#?.info|#?.c| [0-9]#?)

  1. Check the output to see whether the intended files were matched.
  2. Modify the pattern if necessary and repeat the command until the command lists only the desired files.
  3. Enter the intended command, using the same pattern.

To test the effects of escape sequences:

  1. Enter an ECHO command containing the escape sequences and an example word. For example,

ECHO "*E[1mBOLD*E[Om"

  1. Check to see whether the output is as intended.
  2. Modify the escape sequences if necessary and repeat the command until the desired result appears.
  3. Use the escape sequences in the intended command, such as PROMPT.

To clear the window and reset all escape sequence modes to the defaults, enter:

Esc,c,Return

You must use a lower case c. After the window is cleared and reset, the Shell displays a harmless :Unknown command message on the window's top line.

To create a test file in the Ram Disk, enter:

1> ECHO "This is only a test" TO RAM:foo

This provides a small, expendable file on which to test other commands. It is best to create such files in RAM:, to avoid cluttering your disks with small, useless files. Traditionally, files like this are named "foo" or "bar."

To test commands safely on actual files, copy the files to a directory in the Ram Disk and test with those files:

1> COPY Work:MyFiles/#? TO RAM:Testdir

Top Previous Next Chapter