I want to display the name of my computer in CMD next to the directory I'm in, like how it is in the MacOS terminal or in the Ubuntu Terminal.

  • 2
    not sure exactly what you want but set PROMPT=%COMPUTERNAME%-$P$G might get you going. Dec 3, 2020 at 1:08

1 Answer 1


For Command Line:

As HelpingHand posted, you can use set PROMPT=%COMPUTERNAME%-$P$G in the command prompt terminal to set it temporarily.

To make it permanent, you need to create a new string value registry key in HKEY_CURRENT_USER\Software\Microsoft\Command Processor named autorun and set the value of that key as PROMPT=%COMPUTERNAME%-$P$G.

The quickest way to create the key is from a Powershell prompt:

New-ItemProperty -name Autorun -Path 'HKCU:\SOFTWARE\Microsoft\Command Processor\' -PropertyType String -Value 'PROMPT=%COMPUTERNAME%-$P$G' -Force

For Powershell:

Powershell is similar to Linux shells, in which you create a profile.ps1 file that contains the commands you want to run. Where you create this file depends on who you want the profile to be viewed by, and the Powershell host you want to view that prompt in. (The Powershell terminal or the ISE). For the profile to apply to you in all hosts, it needs to be in $Home\Documents\PowerShell\Profile.ps1.

The profile.ps1 file should contain:

function Prompt
 $env:COMPUTERNAME + "\" + (Get-Location) + "> "

  • You shouldn’t need an elevated PS prompt to set the user’s own registry keys.
    – Greg W
    Dec 3, 2020 at 3:02
  • Ah, I expected that editing the registry at ALL would require elevated prompts.
    – Davidw
    Dec 3, 2020 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.