Skip to main content
Previous sectionNext section

Using the Terminal Interactively

This chapter describes the basics of how you work with the Terminal in interactive mode.

Entering Commands

To enter a command in the Terminal, simply type an ObjectScript command and its arguments. Or, if you are using a shell, type a command applicable to that shell.

Note that for ObjectScript, you do not need to enter a space before the command (in contrast to when you define routines and methods).

Also note that if you start a line in the Terminal by pressing Tab, the rest of that line is entered into the routine buffer and is not executed. This behavior was defined long ago and was a useful way of creating routines. (Also see the ZINSERT command, which serves the same purpose.) Because customers no longer define routines this way, this documentation does not discuss this feature further.

Scrolling

Whenever active text arrives, the Terminal scrolls the window to the newly arrived text. Use the scroll bar on the right to scroll up or down.

You can also use the keyboard to scroll within the Terminal as follows:

Using the Keyboard to Scroll the Terminal Display
Key Combination Effect
Ctrl+Home Scroll to the top of the buffer.
Ctrl+End Scroll down to the cursor.
Ctrl+Page Up Scroll up by one page.
Ctrl+Page Dn Scroll down by one page.
Ctrl+Line Up Scroll up by one line.
Ctrl+Line Dn Scroll down by one line.

Pausing and Resuming the Terminal Scrolling

To pause the scrolling in Terminal, press Ctrl+S. While scrolling is paused, the Terminal accepts commands and processes them, but it does not write the commands or any output to the screen (and thus appears to be unresponsive).

To resume, press Ctrl+Q.

Repeating Previous Commands

To repeat a previous command, press the up arrow key repeatedly until the terminal displays the desired command. To enter the command, press Enter.

Line Recall

The terminal also supports a more extensive line recall facility, which uses a list of commands stored in the history buffer. It enables you to recall specific previously entered commands. Activate line recall by typing a colon (:) followed by one or more characters that unambiguously abbreviate the command.

You can issue a number of special commands that interact with line recall at the command prompt. These commands and any defined user aliases (see below) can only be used at the command line interface. They are not an extension to ObjectScript and cannot be used in routines and methods.

The :? displays a quick help:

USER>:?
 :<number>    Recall command # <number>
 :alias       Create/display aliases
 :clear       Clear history buffer
 :history     Display command history
 :unalias     Remove aliases
Copy code to clipboard

The :history command produces a numbered list of commands stored in the history buffer. You can use these numbers to recall a particular command, as shown in the following example:

USER>:h[istory]
 1: zn "%SYS"
 2: D ^SYSLOG
 3: w "Hello"," World!"
 4: w $J
 5: :h

$SYS>:3
w "Hello"," World!"
Hello World!
Copy code to clipboard

The :alias command creates shortcuts for ObjectScript commands commonly typed at the terminal prompt. In addition to creating a short synonym for a long command, the alias definition accepts placeholder variables like $1 and $2 that are replaced by the actual arguments when the alias is expanded. The name of an alias is case-insensitive.

For example, one commonly typed line is:

USER>d $system.OBJ.Load("/somepath/myclass.xml","ck") 
Copy code to clipboard

You can abbreviate this command with the following alias:

USER>:alias load Do $system.OBJ.Load($1,$2) 
Copy code to clipboard

To invoke the alias, type:

USER>:load "/somepath/myclass.xml" "ck" 
Copy code to clipboard

or if there are no other commands or aliases starting with 'l' in the command history:

USER>:l "/somepath/myclass.xml" "ck" 
Copy code to clipboard

It would be even simpler to add the quotes to the definition instead of at each invocation:

USER>:alias load Do $system.OBJ.Load("$1","$2")

USER>:l /somepath/myclass.xml ck
Copy code to clipboard

When an argument is not present in the invocation, its placeholder is skipped and doesn't generate any text, so:

USER>:l /somepath/myclass.xml 
Copy code to clipboard

expands to

Do $system.OBJ.Load("/somepath/myclass.xml","")
Copy code to clipboard

You can use this feature to define aliases that support default arguments. For example, you might want to pass "ck" as the second argument to $System.OBJ.Load() when the corresponding argument is not specified in the alias invocation. You can achieve this effect with the following definition:

USER>:alias load Do $system.OBJ.Load("$1",$S("$2"="":"ck",1:"$2")) 
Copy code to clipboard

Invoking :alias with a single argument displays the current definition assigned to that name. Note that both :alias and load are abbreviated.

USER>:a l
  load        Do $System.OBJ.Load("$1","$2")
Copy code to clipboard

Invoking :alias without arguments displays all the defined aliases:

USER>:a
  zv        Write $ZV
  load        Do $System.OBJ.Load("$1","$2") 
Copy code to clipboard

The command :unalias <name> removes the definition associated with that name.

The :clear command deletes all the contents from the recall buffer, but does not delete ~/.iris_history.

On Unix systems, if a file named ~/.iris_init exists, it is read when a terminal session is initiated. Only lines starting with :<command> are processed. All other lines are ignored.

Currently, this file accepts only :alias commands, which enables you to store favorite command abbreviations there.

Example of a ~/.iris_init file:

# Initial aliases
:alias %  zn "%SYS"
:alias load Do $System.OBJ.Load("$1",$S("$2"="":"ck",1:"$2"))
:alias ut Do ##class(%UnitTest.Manager).RunTest("$1")
Copy code to clipboard

Reverse Incremental Search

Reverse incremental search (RIS) is an additional mode of operation of the command line recall facility. You enter this mode by typing Ctrl+R. In order to use RIS mode, there must be commands stored in the recall buffer. If the buffer is empty, the terminal bell rings and nothing else happens. Two backslash characters after the prompt indicate RIS mode:

USER>\\ 
Copy code to clipboard

The search string appears between the two backslashes, and the matching command, if any, appears to the right. As you type characters in the search string, the system scans the command history buffer in the same direction as typing up-arrow, from most recent to least recent. It stops at the first command that contains the string. Press Enter to execute the command.

For example, if the command W $J is in the recall buffer, after typing the '$' key, the terminal might look like this:

USER>\$\ W $J 
Copy code to clipboard

If you want to find the command W $ZV instead, type the following character, Z:

USER>\$Z\ W $ZV 
Copy code to clipboard

On terminals that support ANSI attributes, the matching characters in the recalled command will be displayed with the bold attribute.

You exit the RIS mode when you type:

  • Enter – selects and immediately executes the command.

  • Ctrl+G – cancels RIS mode and goes back to the previous prompt without any command.

  • An editing key, like the left arrow or Ctrl+A – this enters edit mode and allows you to edit the recalled command line.

  • Up or down arrow – selects the previous or next command relative to the one that had been selected by the search.

You continue in the search mode when you type one of the following:

  • A non control character – the character is appended to the search string and the system tries to find the previous command that contains the new string.

  • Ctrl+R – searches for the previous command containing the same search string.

  • DEL or BS – erases the rightmost character of the search string and takes you back to the corresponding command.

Copying and Pasting Text

You can copy and paste text in the Terminal. To do this, you can use the context menu (right-click menu), the Edit menu, or various keyboard shortcuts. The following options are available:

  • Copy copies the selected text to the clipboard.

  • Paste pastes the contents of the clipboard, line by line, to the current position of the cursor (which is the end of the Terminal scrollback buffer). The text becomes visible in the Terminal window unless echoing has been disabled.

  • Copy + Paste copies the selected text to the clipboard and then pastes it, line by line, to the current location of the cursor.

Keyboard Shortcuts

You can use the following keyboard shortcuts:

Shortcuts for Copy and Paste
Action Basic Shortcut Windows Shortcut
Copy Ctrl+Ins Ctrl+C
Paste Shift+Ins Ctrl+V
Copy and paste   Ctrl+Shift+V

The shortcuts listed in the “Basic Shortcut” column are always enabled.

The shortcuts listed in the “Windows Shortcut” column are enabled only if you set the Windows edit accelerators option to Yes; for information on this setting, see the section “User Settings,” in the chapter “Controlling the Appearance and Behavior of the Terminal.”

Notes about Copying and Pasting

  • As noted above, if you set the Windows edit accelerators option to Yes, Ctrl+C copies the selected text to the Windows clipboard. To interrupt the Terminal, you must instead press Ctrl+Shift+C

  • If the host has a mouse request outstanding and you wish to do a local cut and paste, press Ctrl while selecting the region; that mouse action is not reported to the host.

  • If the copied text includes a line boundary, it is saved on the clipboard as a carriage return and a line feed. If you do not want to paste line feeds, see “User Settings.”

  • The Terminal can often paste data faster than a host can accept it. See “User Settings” for settings to control the speed of pasting. Also, line feeds can be discarded during a paste command.

Printing

To print from the Terminal, use the following options of the File menu:

  • To select a printer and set it up for use with the Terminal, select File > Printer Setup.

  • To print the contents of the Terminal screen, select File > Print.

  • To print the log file (or any other ASCII file), select File > Print Log. This option lets you select the file to print, and it does no special processing except to try to be reasonable in processing form feed characters. During printing, mouse and keyboard input is locked out of the main window and a cancel dialog box appears. Printing is done in draft mode.

Clearing the Screen

The Edit menu provides two different options to clear the screen:

  • To reset the screen, select Edit > Reset. This option resets the margins, scroll region and other processing on the current page, and causes the Terminal to repaint the window.

  • To reinitialize the screen, select Edit > Erase or press Ctrl+Del. This option reinitializes the Terminal window, erases all session data, and resets the scrollback region to zero.

Logging the Terminal Session

To start logging the Terminal session:

  1. Select File > Logging or select Alt+L.

    The Terminal displays a dialog box to prompt you for the location and name of the log file. The default directory is install-dir/mgr. The default filename is TERMINAL.LOG.

    The total length of the path and file name cannot exceed 126 characters.

  2. Optionally specify a different directory and filename.

  3. Select OK.

    If the log file exists, the Terminal asks if you want to overwrite it and presents three choices:

    • Yes overwrites the file with the new log data

    • No appends any new log data to the file

    • Cancel leaves the file as is (no logging is done)

Later, to stop logging, select File > Logging or select Alt+L. The Terminal displays a dialog box to indicate that the log file is closed; select OK.

The log file contains only the output from a connection (independent of the current wrap mode).

You can also perform logging from a Terminal script, as described later in this book. Note that if you have started logging by using File > Logging, you cannot start a script that also performs logging. If you attempt to do so, the behavior is indeterminate.

Also see the section “Learning Mode” in the chapter “Advanced Topics.”