How to change the prompt

Updated: 12/05/2021 by Computer Hope
Windows command line (DOS)

Changing the prompt in a command line can give you additional helpful information while navigating through a session.

Microsoft DOS users

To change the prompt in MS-DOS, you must utilize the prompt command followed by special codes used with the prompt command. Below are some commonly used prompts.

prompt $p$g

Changes the prompt to the standard used prompt in MS-DOS listing the drive with the current path, similar to what is seen below.

prompt $t $d$_$p$g

Change the prompt to list the time and date above the standard prompt, similar to what is seen below.
13:38:49.78 Mon 02/17/2003

To make these changes permanent, edit the autoexec.bat and add the prompt line you used at the prompt.

Unix and Linux users

Changing the prompt in Unix and Linux varies depending on what shell you are using.

If you are using the C Shell, type:

set prompt="`hostname`>"

Displays the hostname in the prompt, similar to the below prompt:

set prompt="`pwd`>"

Displays the working directory with the prompt:

set prompt="`hostname`(`pwd`)>"

Displays the hostname with the working directory:

set prompt=\[`id -nu`@`hostname -s`\]\#\

Displays the user who is logged in with the hostname, similar to the below prompt:

To make the prompt permanent in the C Shell, edit the .cshrc file and add the same line you used at the prompt.