How to use the command 'prompt' (with examples)

How to use the command 'prompt' (with examples)

The ‘prompt’ command is used to change the default DOS style prompt in a command window. The prompt is the text that appears in the command window, indicating that the system is ready to receive commands. By using the ‘prompt’ command, users can customize the prompt to their liking, adding specific text, date, or time to the prompt.

Use case 1: Reset the prompt to the default setting

Code:

prompt

Motivation: This use case is useful when you have customized your prompt and want to revert it back to the default setting. It allows you to remove any customizations and start fresh with the default prompt.

Explanation:

  • The ‘prompt’ command without any arguments sets the prompt to the default setting.
  • There is no need to provide any additional arguments.

Example OUTPUT:

C:\>

Use case 2: Set a specific prompt

Code:

prompt prompt

Motivation: This use case is helpful when you want to set a specific prompt that remains constant throughout your command session. It allows you to customize the prompt with your preferred text.

Explanation:

  • The ‘prompt’ command followed by a text argument sets the prompt to the specified text.
  • The argument “prompt” can be replaced with any desired text.

Example OUTPUT:

prompt>

Use case 3: Change the prompt to show the current date first

Code:

prompt $D $P$G

Motivation: This use case is useful when you want to include the current date in your prompt. It allows you to have a quick reference to the date in every command window.

Explanation:

  • The ‘prompt’ command followed by “$D” sets the prompt to display the current date.
  • The “$P$G” represents the default prompt, which includes the current path.

Example OUTPUT:

04/28/2022 C:\>

Use case 4: Change the prompt to show the current time first

Code:

prompt $T $P$G

Motivation: Including the current time in the prompt can be helpful when you need to keep track of time while executing commands. It allows you to easily see the time in every command window.

Explanation:

  • The ‘prompt’ command followed by “$T” sets the prompt to display the current time.
  • The “$P$G” represents the default prompt, which includes the current path.

Example OUTPUT:

20:51:35.19 C:\>

Use case 5: Change the prompt by adding specific text first

Code:

prompt text $P$G

Motivation: This use case is beneficial when you want to add specific text to the prompt, providing additional context to your command window. It allows you to personalize the prompt with a custom message.

Explanation:

  • The ‘prompt’ command followed by a specific text argument sets the prompt to display the provided text.
  • The argument “text” can be replaced with any desired text.

Example OUTPUT:

text C:\>

Conclusion:

The ‘prompt’ command provides flexibility in customizing the command prompt according to your requirements. Whether you want to reset it to the default setting, set a specific prompt, or add date/time information, the ‘prompt’ command empowers users to personalize their command window experience.

Related Posts

Using azcopy (with examples)

Using azcopy (with examples)

1: Log in to an Azure Tenant azcopy login Motivation: The azopy login command allows you to log in to your Azure tenant, enabling you to access your Azure storage accounts.

Read More
How to use the command 'btrbk' (with examples)

How to use the command 'btrbk' (with examples)

The ‘btrbk’ command is a tool that allows users to create snapshots and remote backups of btrfs subvolumes.

Read More
How to use the command git fsck (with examples)

How to use the command git fsck (with examples)

Git fsck is a command used to verify the validity and connectivity of nodes in a Git repository index.

Read More