This environment variable specifies the prompt to be used in the given
environment. It takes precedence over CMDSHL.PROMPT and PROMPT.
For example, you can define two different prompts for two different (possible)
environments:
SET CMDSHL.PROMPT.CMD=$i[$p]$s
SET CMDSHL.PROMPT.EDIT=EDIT:[$p]$s
See the PROMPT section for details on the possible values of
CMDSHL.PROMPT.environment.
ΓòÉΓòÉΓòÉ 1.4.4. PROMPT ΓòÉΓòÉΓòÉ
This environment variable specifies the prompt to be used if no more specific
prompt is defined. If PROMPT is undefined, '[$p]' is assumed.
SET PROMPT=text
The following symbols can be used to define a new prompt. Each symbol must be
preceded by a dollar symbol ($):
$ $ symbol
_ Carriage Return / Line Feed sequence
A & symbol
B | symbol (pipe)
C ( symbol
D Date
E ASCII Code 27 (escape)
F ) symbol
G > symbol
H Backspace
I Help bar
L < symbol
N Default disk unit (e.g. A:)
P Current directory (e.g. E:\OS2)
Q = symbol
R Return code
S Space
T Time
V Version number
All other symbols are emitted without changes.
Example
SET PROMPT=$i$e[33m{$r}$e[32;1m[$p]$e[0m$s
ΓòÉΓòÉΓòÉ 1.4.5. HELP.COMMAND ΓòÉΓòÉΓòÉ
If this environment variable is defined, CmdShl will not use its build-in help
messages for internal commands. Instead, it will call the script/application
defined by this variable.
For example, if HELP.COMMAND is defined as:
SET HELP.COMMAND=ECHO Help for
Issuing 'ALIAS /?' will give:
Help for ALIAS /?
(In other words, the command is displayed back to the user.)
The syntax of the call is the following:
call %HELP.COMMAND% <command> <args>
where <command> is the upper-cased full command name (namely, one of ALIAS, CD,
CMDSHL, DEFINE, QUIT or RULE) and <args> the argument(s) given to the command
by the user.
ΓòÉΓòÉΓòÉ 1.4.6. HELP.SWITCHES ΓòÉΓòÉΓòÉ
If this environment variable is defined, it is used as the default value for
the helpSwitches environment variable. If HELP.SWITCHES is not defined, the
default value for helpSwitches is '/?'.
See the helpSwitches definition in CmdShl internal variables for more details.
ΓòÉΓòÉΓòÉ 1.5. Editing Keys ΓòÉΓòÉΓòÉ
By default, CmdShl uses CMD.EXE editing commands, as well as some EPM keys,
that is:
Alt+C
Copies the marked text.
Alt+D
Deletes the current mark.
Alt+M
Moves the current mark.
Alt+U
Removes the current mark.
Alt+W
Marks the word at the current cursor position using a character
mark.
Alt+Z
Character-marks the current character.
Backspace
Deletes the character to the left of the cursor.
Ctrl+E
Ctrl+End
Erases from the current cursor position to the end of the line.
Ctrl+Home
Erases from the beginning of the line to the current cursor
position.
Ctrl+K
Duplicates the element preceding the cursor. (A space is added
between the elements, and completion state is preserved.)
Ctrl+Left arrow
Moves the cursor to the beginning of the word.
Ctrl+Right arrow
Moves the cursor to the beginning of the next word.
Ctrl+X
Expands the element preceding the cursor.
Del
Deletes the character at the current cursor position.
Down arrow
Recalls the next entry in the command history list.
End
Moves the cursor to the end of the line.
Esc
Erases the command line.
F1
Finds the previous entry in the command history list matching the
beginning of the line (from the beginning to the current cursor
position).
Home
Moves the cursor to the beginning of the line.
Ins
Switches between insert and replace modes.
Left arrow
Moves the cursor one position to the left.
Right arrow
Moves the cursor one position to the right.
Shift+Tab
Replaces the element preceding the cursor with the previous matching
item.
Space
Insert a space and check the validity of the element preceding the
cursor if it is a command.
Tab
Replaces the element preceding the cursor with the next matching
item.
Up arrow
Recalls the previous entry in the command history list.
But you can redefine almost all keys to suit your needs. As an example, the
default PROFILE.SHL file provides the following additional editing keys:
( -- insert () and move cursor inside
F3 -- close the current session
F8 -- insert current date
Shift+F7 -- show all matching file names
F2, F5, F7 -- save, load and rename
-- history list
Ctrl+R -- search command in history
Ctrl+F -- search next match in history
Ctrl+Down arrow -- save current screen
Ctrl+Up arrow -- restore last screen
ΓòÉΓòÉΓòÉ 1.5.1. The expand Internal Action ΓòÉΓòÉΓòÉ
The expand internal action is used to expand the element preceding the cursor.
That is:
If the element is in a command position, it is replaced with its complete
filename (with full path) if applicable -- if it's an alias or an
internal command, it remains unchanged. If it's an invalid command, it
is highlighted;
If the element follows an ALIAS internal command, and ends with an equal
sign, the alias value is inserted (if available);
If the element follows a RULE internal command, and ends with an equal
sign, the rule value is inserted (if available);
If the element ends with an equal sign, and if an environment variable of
that name exists, its value is inserted;
Otherwise, if the element contains environment variable names surrounded
by percent sign, these parts are replaced with the environment variables
values.
In the following examples, the cursor is supposed to be the underscore sign.
keyb_fr --> c:\OS2\keyb.com_fr
keyb fr_ --> keyb fr_
alias xrn=_ --> alias xrn=e:\local\yarn ^& yarn.exe ^& cd -
rule RD=_ --> rule RD=%d %d*^|/?
set etc=_ --> set etc=d:\tcpip\etc
type %etc%\connect.log_ --> type d:\tcpip\etc\connect.log_
ΓòÉΓòÉΓòÉ 1.5.2. The tab and backtab Internal Actions ΓòÉΓòÉΓòÉ
The tab and backtab internal actions are used to complete the element preceding
the cursor. That is:
If the element at this position is expected to be an environment
variable, an environment variable name whose name begins with the element
preceding the cursor is searched for;
If the element at this position is expected to be a directory, a
directory name whose name begins with the element preceding the cursor is
searched for -- the element preceding the cursor can contain wildcards;
If the element at this position is expected to be a keyword or a symbol,
nothing occurs;
Otherwise, a file or directory whose name begins with the element
preceding the cursor is searched for -- the element preceding the cursor
can contain wildcards.
When more than one matching item is found, the tab and backtab internal
actions are used to enumerate the possibilities.
The type of the element at cursor position is determined by user-defined
rules. When no such rule exists, a file or directory whose name begins with
the element preceding the cursor is searched for. The following rules are
predefined (they can be redefined at will):
CD %d|%f %f|/?|
CHDIR %d|/?|
DETACH %x
FOR %%%l IN (%*) DO %x
RD %d %d*|/?
RMDIR %d %d*|/?
SET %e=%*|/?|
START "%*" %o %x|"%*" %o|%o %x|%o
See the RULE command for details on rules.
ΓòÉΓòÉΓòÉ 1.5.3. The space Internal Action ΓòÉΓòÉΓòÉ
The space internal action is used to insert (or overstrike) a space and to
check the validity of the command preceding it. That is to say, the command
preceding the cursor is checked if it is in a command (findcontexttype()
returns 'c') or invalid (findcontexttype() returns '0') context, as defined by
rules.
If it is a command context, nothing happens if the command found is valid.
Otherwise, invalidCmd is evaluated. If it is an invalid context, invalidCmd is
evaluated too.
invalidCmd by default flags the offending command in red, but it can be
redefined by the user. See its definition in the Internal Variables section
for details.
ΓòÉΓòÉΓòÉ 1.6. Internal Commands ΓòÉΓòÉΓòÉ
CmdShl adds the following "internal" commands:
ALIAS [LIST|@file|alias=[cmd]]
DEFine key [value]
QUIT
RULE [LIST|@file|rule=[def]]
RX cmd
And it "enhances" the following underlying shell commands:
CD [directory|string1 string2]
ΓòÉΓòÉΓòÉ 1.6.1. ALIAS ΓòÉΓòÉΓòÉ
The ALIAS command is used to view/define/remove aliases. Alias names ARE
case-sensitive. Recursive aliases are not allowed (but an alias can use
another alias). And an alias can use all CmdShl's internal commands.
ALIAS ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇLISTΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇ@fileΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
ΓööΓöÇalias=Γö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
ΓööΓöÇvalueΓöÇΓöÿ
To view all defined aliases, issue the "ALIAS LIST" command.
To save all defined aliases in a file, redirect the previous command
output into a file, as in "ALIAS LIST >mylist".
To load an alias list, use "ALIAS @mylist" (where "mylist" is a file
containing alias definitions).
To remove an existing alias, use an empty definition, as in "ALIAS foo=".
To define a new alias, use "ALIAS alias=def", where "alias" is the alias
name, and "def" its definition (any valid command). In addition, you can
use the "%*" parameter as well as "%n" (where n is the argument number in
range 0..9, 0 being the alias name), which denotes "runtime" parameters.
(If "%n" is immediately followed by '*', it means "arg n and all
remaining args".) Here are some aliases definitions:
ALIAS dir=dir %* ^| less
ALIAS prj=cd \user\alpha\smith\MyProject\Current
ALIAS makeprj=prj ^& nmake
ALIAS calc=rx say %*; RC=0
ALIAS in=cd %1 ^& %2* ^& cd -
Note: An alias can redefine an existing command, as "dir" in the previous
list. The right-hand-side "dir" is the CMD.EXE internal command --
recursive aliases are not allowed, and hence this second "dir" cannot
be an alias, so it must be something else (a CMD.EXE internal command
in this very case).
When defining aliases from the command line, you may have to quote special
symbols (such as '&' and '|') with a '^' in order to prevent unexpected
results. For example, the first (dir), third (makeprj) and last (in) aliases
require an '^' in front of their '&'s when entered from the command line.
When the execution of an alias is interrupted by the user (by the mean of
Ctrl+C or Ctrl+Break), the execution of the alias is interrupted, as is the
execution of the possibly following commands in the current command line.
ΓòÉΓòÉΓòÉ 1.6.2. DEFine ΓòÉΓòÉΓòÉ
The DEFine command is used to [re]define a key. You can either assign to a key
an internal action, an immediate command or a static text. You can also remove
a key definition (the key will then returns its default value).
The CD command now accepts a new parameter, "-", and uses the CDPATH
environment variable. Additionally, both "\" and "/" can be used in
directories specifications and the drive is changed. Partial path substitution
is also allowed.
CD ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γö£ΓöÇΓöÇdirectoryΓöÇΓöÇΓöñ
Γö£ΓöÇstr1ΓöÇΓöÇΓöÇstr2ΓöÇΓöñ
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇ - ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The CDPATH environment variable contains a list of paths. You don't have to
include the current (".") directory in it. It is always looked up first.
For example, if CDPATH is defined as:
SET CDPATH=C:\;C:\OS2;
Issuing the "CD APPS" command will bring you to "C:\OS2\APPS" (if there was no
APPS entry in the then-current directory).
A trailing "/" or "\" is allowed in directories specification.
You can perform path substitution. For example, if you're currently in
C:\project\beta\source and want to switch to C:\project\gamma\source, you can
use "CD BETA GAMMA".
Warning: If you want to switch to a directory named "-", you'll have to
enclose it with double quotes, follow it with "\" or precede it with
".\" as in:
CD "-"
CD -\
CD .\-
ΓòÉΓòÉΓòÉ 1.7. Known Limitations ΓòÉΓòÉΓòÉ
When using CmdShl as a CMD.EXE front-end, interrupting the execution of a
CMD.EXE internal command aborts CmdShl too. Not much can be done
regarding this problem except waiting for a new CMD.EXE with a better
signal handling...
When using CmdShl as a CMD.EXE front-end with OS/2 2.x, your command-line
window may not close upon shutdown. THIS PROBLEM NO LONGER OCCURS WITH
WARP.
Alias names ARE case-sensitive. This is intentional but if you don't
like it that way, please, let me know!
If you want to switch to a directory named "-", you'll have to enclose it
with double quotes or precede it with ".\" or append "\" to it, as in:
CD "-"
CD .\-
CD -\
When "implied" CD is enabled, a directory name takes the precedence over
an executable name with no arguments. That is, if "foo" is a
subdirectory of the current directory and there also exists a "foo.exe"
somewhere along the PATH, issuing the "foo" command will change the
current directory. If you want to call "foo.exe", either use some
arguments, or specify the file's extension, as in:
foo bar
foo.exe
[This behavior is the default, but you can choose to give precedence to
an executable name with no arguments by setting impCD to 2. See the
impCD definition in CmdShl internal variables.]
CmdShl aliases and so-called "internal commands" (i.e., ALIAS, RX, QUIT
and DEFine) can not be used in sub-expressions. That is, in:
for %i in (foo bar) do alias do_%i=baz %i
or
(foo prj & bar prj) >foobar.log
CmdShl's ALIAS command is not called in the first statement, and foo and
bar cannot be aliases.
The & ('and') operator cannot be used in an expression for the RX
command. CmdShl interprets it as a command separator. For example:
RX say foo & bar
can be interpreted either as "RX say foo" followed by a "bar" command, or
as "RX say foo & bar", displaying 1 if foo and bar are both equal to 1
and 0 otherwise. As there's no way to choose between those two valid
interpretations, the first one is retained.
Due to a limitation with the linein() builtin function, lines in a
PROFILE file exceeding 250 characters may cause problem. An easy fix is
to break it in more than one piece:
'a very long line...'
can be entered as:
'a very',
'long line...'
(Note the ending comma at the end of the first line.)
ΓòÉΓòÉΓòÉ 1.8. Related Files ΓòÉΓòÉΓòÉ
df.cmd [drive ...]
This is a UNIX "df" clone. It displays all available (or specified) drives,
with their total, used and free capacity.
pushd.cmd [new dir]
This command pushes the current directory in a "directory stack", and
(optionally) changes to the given disk/directory.
popd.cmd
This command pops the head of the directory stack, and go to this new
directory.
whence.cmd file [path]
This command tries to find a file along a path (PATH by default). If the file
is found, its complete path is displayed.
ΓòÉΓòÉΓòÉ 1.9. National Language Support ΓòÉΓòÉΓòÉ
There's just six language-dependent messages which are not automatically
adjusted: it's the alias command help string (aliasHelp), the CmdShl help
string (cmdHelp), the define command help string (defHelp), the quit command
help string (quitHelp), the rule command help string (ruleHelp) and the
additional CD help string (cdHelp). It's at the beginning of the file, and you
can translate it. Or, even better, you can define them in your PROFILE.SHL
(see below).
All other language-dependent messages are automatically adjusted by CmdShl
(secondary prompt, top of screen help string, ...).
ΓòÉΓòÉΓòÉ 1.10. Profile Support ΓòÉΓòÉΓòÉ
CmdShl supports profile files. By default, PROFILE.SHL is used, but you can
override it via the /P switch.
If present, the profile file should be somewhere along the DPATH, or you can
alternatively specify its complete path.
A profile file is a plain REXX file. It's called after command line arguments,
but before any user interaction. It's usually used to redefine keys
assignments, displaying or setting some session- dependant data, and so on...
Please refer to PROFILE1.SHL for more explanations.
ΓòÉΓòÉΓòÉ 1.10.1. PROFILE1.SHL ΓòÉΓòÉΓòÉ
This is my current profile file, which you can use as a sample profile file for
CmdShl. [Hint: for better startup performances, you can remove all comments
-- that is, all except the first.]
For a detailed explanation of the features added by this profile file, read the
end of this section.
/* profile.shl - sample bindings 971221 */
/* This profile file demonstrates typical profile usage: */
/* defining key value - a shifted key can use "-" or "_" in its name */
'DEFINE F3 OSNOWAIT EXIT'
/* you can even do complex things: */
'DEFINE ( MC /TEXT ()/cleft'
'DEFINE F8 OSNOWAIT RX line = insert(date(),line,currOfs); currOfs = currOfs+length(date())'
'DEFINE S-F7 osn rx if currTab = 0 then currTab = findcontextcompletion(); if currTab \= 0 then do; say; do i = 1 to tree.0; say tree.i; end; call charout, print(); oline=""; parse value SysCurPos() with origRow origCol .; key="tab"; end'
/* we can even add a new feature: loading/saving commands history */
/* first, we define a file name (and make it public, F7 requires it): */
history = expand('%tmp%\history.shl'); global = global 'history'
/* then, an alias, LOADHIST, which loads the commands history */
'ALIAS LOADHIST=RX drop prevLine.; i = 0; do while lines(history); i = i+1; prevLine.i = linein(history); end; prevLine.0 = i; call stream history, "c", "close"'
/* now, we define three function keys, F2 (save), F5 (load/refresh) */
/* and F7 (name) */
'DEFINE F2 OSNOWAIT RX "@del /f" history; do i = 1 to prevLine.0; call lineout history, prevLine.i; end; call stream history, "c", "close"'