One of the issues I was running into with the current prompt format was the long file path like below. So I wanted to change the format to look more like a unix prompt. I did not find any good examples on how do to this so I thought I would write a quick blog on how do to it. I would also suggest reading the gettingStarted guide that comes install if you have not done powershell before.
Before
After
The first thing that must be created is a profile. I figured out how to create a profile by reading the gettingStarted.rtf document that comes installed with PowerShell. The section “Creating a Profile” provides the following steps.
1. The $profile command shows you were your personal profile should be. But if you navigate to this file path you will not find the folder or file. Another way to check to see if the file is created is buy running test-path $profile.
2. To create a profile you can run the following command.
new-item -path $profile -itemtype file –force
3. The next step that is not covered is setting your execution policy. The policy is set to Restricted by default and must be changed.
set-executionpolicy RemoteSigned
4. Next you can run notepad $profile at the prompt. This will bring up your profile in notepad. This will be a blank doc. All you need to do now is copy the following script into your profile.
function prompt
{
$(get-content env:computername) + "$ "
}
Currently rated 1.0 by 1 people
- Currently 1/5 Stars.
- 1
- 2
- 3
- 4
- 5