Skip to main content

Command History and Aliases

The ObjectScript shell supports an extensive line recall facility, with an option to search previous commands, as well as a facility for defining aliases for commands. These options are not an extension to ObjectScript and cannot be used in routines and methods.

Line Recall Facility

In addition to the up arrow, the ObjectScript shell 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.

To activate line recall, type colon (:) followed by one or more characters that unambiguously identify the command.

You can issue a number of special commands that interact with line recall at the command prompt. First, the :? displays a quick help:

 :<number>    Recall command # <number>
 :alias       Create/display aliases
 :clear       Clear history buffer
 :history     Display command history
 :unalias     Remove aliases

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:

 1: zn "%SYS"
 2: Do ^SYSLOG
 3: write "Hello"," World!"
 4: write $J
 5: :h

write "Hello"," World!"
Hello World!

The :alias command creates shortcuts for ObjectScript commands commonly typed at the prompt, and :unalias <name> removes the definition associated with that name. See Creating Aliases.

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


To define a shortcut for issuing a command, enter the :alias command followed by the alternative name you want to assign to the command (the alias) and then the command you want to assign to that alias. For the rest of the session, you can issue the command by invoking the alias, preceded by the : character.

In the example session which follows, the :alias command issued in the first line allows the user to switch to the USER namespace in the second line by simply entering the string :u:

%SYS>:alias u set $namespace="USER"

It is also possible to pass arguments to a command using an alias. As part of the alias definition, include numbered host variables prefixed by the $ character as placeholders for each argument in the command. Then, invoke the alias followed by the values of the arguments in the order indicated by the host variable numbers.

For example, issuing the following command creates a shortcut (load) to load a file at a location which will be provided as the first argument ($1)with flags specified by the second argument ($2):

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

To use this alias to load a file found at the path /directory/foobar.xml with the c and k flags, you can now simply enter the following:

USER>:load /directory/foobar.xml ck

The placeholder variables in a command can also be part of an ObjectScript expression. For example, the following command uses the $SELECT function to set "ck" as the default second argument when no second argument is provided:

USER>:alias load Do $System.OBJ.Load("$1", $S("$2"="":"ck", 1:"$2"))

To remove an alias definition, enter the command :unalias followed by the alias name. Enter :alias with no arguments to see a list of the aliases defined in the current session.

You can also provide a list of alias definitions which the ObjectScript shell will set automatically at the start of every session. Define these aliases (one per line) in a file named .iris_init in your home directory — specifically the home directory for the current user, within the operating system. (For example, on Windows, this is the C:\Users\ subdirectory which corresponds to the current user.)

FeedbackOpens in a new tab