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.
1 Answer
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) + "> "
}
set PROMPT=%COMPUTERNAME%-$P$G
might get you going.