[Toc][Index]

PROMPT - Change the command-line prompt

 
 Purpose:    Change the command-line prompt. 
             
 Format:     PROMPT [text ] 
             
             text :  Text to be used as the new command-line prompt. 
 
 Usage 
 You can change and customize the command-line prompt at any time.  The 
 prompt can include normal text, and system information such as the 
 current drive and directory, the time and date, and the amount of memory 
 available.  You can create an informal "Hello, Bob!" prompt or an 
 official-looking prompt full of impressive information.  The prompt text 
 can contain special commands in the form $?, where ? is one of the 
 characters listed below: 
        b     The vertical bar character [|]. 
        c     The open parenthesis [(]. 
        d     Current date, in the format:  Fri 2-12-97 (the month, day, 
              and year are formatted according to your current country 
              settings). 
        D     Current date, in the format:  Fri  Dec 12, 1997. 
        e     The ASCII ESC character (decimal 27). 
        f     The close parenthesis [)]. 
        g     The > character. 
        h     Backspace over the previous character. 
        i     Display the OS/2 prompt header line, which reminds you of 
              how to return to the OS/2 desktop, or get help. 
        l     The < character. 
        m     Time in hours and minutes using 24-hour format:  16:07 
        M     Time in hours and minutes using the default country format 
              and retaining "a" or "p", e.g. 4:07p. 
        n     Current drive letter. 
        p     Current directory (lower case). 
        P     Current directory (upper case on FAT drives; directory names 
              shown in mixed case as stored on the disk on HPFS drives). 
        q     The = character. 
        r     The numeric exit code of the last external command. 
        s     The space character. 
        t     Current 24-hour time, in the format hh:mm:ss. 
        T     Current 12-hour time, in the format hh:mm:ss[a|p]. 
        v     Operating system version number, in the format 3.10. 
        xd:   Current directory on drive d:, in lower case, including the 
              drive letter (uses the actual case of the directory name as 
              stored on the disk for HPFS drives). 
        Xd:   Current directory on drive d:, in upper case, including the 
              drive letter. 
        z     Current shell nesting level; the primary command processor 
              is shell 0. 
        +     Display one + character for each directory on the PUSHD 
              directory stack. 
        $     The $ character. 
        _     CR/LF (go to beginning of a new line). 
 
 For example, to set the prompt to the current date and time, with a ">" 
 at the end: 

 
         [c:\] prompt $D $t $g
         Fri  Jun 6, 1997 10:29:19 >
 
 
 To set the prompt to the current date and time, followed by the current 
 drive and directory in upper case on the next line, with a ">" at the 
 end: 

 
         [c:\] prompt $d $t$_$P$g
         Fri  Dec 2, 1994 10:29:19
         [c:\]
 
 
 The CMD.EXE prompt can be set in CONFIG.SYS (see below), and the prompt 
 for any command processor can be set in 4START, or in any batch file that 
 runs when CMD.EXE starts. 
 The CMD.EXE default prompt is [$n] (drive name in square brackets) on 
 floppy drives, and [$p] (current drive and directory in square brackets) 
 on all other drives.  When OS/2 is installed, it inserts a SET PROMPT 
 statement in CONFIG.SYS to set the prompt to $i[$p].  This prompt will override 
 the CMD.EXE defaults.  The $i adds a header line to the default prompt to 
 remind you of certain OS/2 keystrokes.  You must delete this statement if 
 you want to use the default CMD.EXE prompt. 
 If you enter PROMPT with no arguments, the prompt will be reset to its 
 default value.  The PROMPT command sets the environment variable PROMPT, 
 so to view the current prompt setting use the command: 

 
         [c:\] set prompt
 
 
 (If the prompt is not set at all, the PROMPT environment variable will 
 not be used, in which case the SET command above will give a "Not in 
 environment" error.) 
 Along with literal text, special characters, and ANSI sequences you can 
 include the text of any environment variable, internal variable, or 
 variable function in a prompt.  For example, if you want to include the 
 size of the largest free memory block in the command prompt, plus the 
 current drive and directory, you could use this command: 

 
         [c:\] prompt (%%@dosmem[K]K) $p$g
         (601K) [c:\data]
 
 
 Notice that the @DOSMEM function is shown with two leading percent signs 
 [%].  If you used only one percent sign, the @DOSMEM function would be 
 expanded once when the PROMPT command was executed, instead of every time 
 the prompt is displayed.  As a result, the amount of memory would never 
 change from the value it had when you entered the PROMPT command.  You 
 can also use back quotes to delay expanding the variable function until 
 the prompt is displayed: 

 
         [c:\] prompt `(%@dosmem[K]K) $p$g`
 
 
 You can use this feature along with the @EXEC variable function to create 
 a complex prompt which not only displays information but executes 
 commands.  For example, to execute an alias which checks battery status 
 each time the prompt is displayed (enter the alias on one line): 

 
         [c:\] alias cbatt `if %_apmlife lt 30 beep 440 4 880 4 440
          4 880 4`
         [c:\] prompt `%@exec[@cbatt]$p$g`
 
 
 You can include ANSI escape sequences in the PROMPT text.  See ANSI Codes 
 for complete details on ANSI commands.  This example uses ANSI sequences 
 to set a prompt that displays the shell level, date, time and path in 
 color on the top line of the screen (enter the command as one line): 

 
         [c:\] prompt $e[s$e[1;1f$e[41;1;37m$e[K[$z] $d
               Time: $t$h$h$h  Path: $p$e[u$e[0;32m$n$g
 
 
 A few older batch files use the PROMPT command to transmit ANSI.SYS 
 control sequences to the screen (for example, to redefine function keys). 
  This technique will not work with CMD.EXE, because it doesn't display a 
 prompt within batch files; hence, the characters in the PROMPT string are 
 never sent to ANSI.SYS.  To send ANSI sequences in CMD.EXE, use the ECHO 
 command, substituting an escape character followed by an e for $e in the 
 PROMPT string. 
 You may find it helpful to define a different prompt in secondary shells, 
 perhaps including $z in the prompt to display the shell level.  To do so, 
 place a PROMPT command in your 4START file and use IF or IFF statements 
 to set the appropriate prompt for different shells. 

Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs