In an older post we talked about how we can customize the new Windows Terminal and make it look beautiful. If you went through the post your terminal pretty much looks like this:
Generally I'm happy with this, but I'm not happy with the prompt: "rajivpopat@localhost" part. It annoys me and I was to change or customize that.
With dos prompt was easy to change. You used PROMPT $P$G to show the path followed by the greater than sign. Which means you could just use the PROMPT followed by anything and your prompt would change to that.
With power-shell things are a little more complicated if you want to change the prompt. In Power Shell this is done using the prompt function. You can read more about it here.
In our case we are just using oh-my-posh so our power-shell profile looks like this:
In the above profile we are using the Agnoster theme so to change the prompt we hop into the Angoster Profile script file which, if you have followed my previous post, can be found at: C:\ Users\ [your_user_name]\Documents \ WindowsPowerShell\ Modules\ oh-my-posh\ 2.0.332\ Themes\ Agnoster.psm1 (without the spaces).
These are the lines controlling the prompt I see on screen:
I want to change my prompt to show a static text instead of user name and the computer name. So I change: $prompt += Write-Prompt -Object "$user@$computer " to $prompt += Write-Prompt -Object "thousandtyone " and my lo and behold my console looks like:
I can obviously configure it to whatever I want. For example, I could print the time or use any combination of PowerShell functions to show anything I wanted on my screen.
For someone like me who blogs from different machines and different users names and takes screenshots being able to change the prompt and make it something constant which is same as my blog name helps.
The same file also lets you control color options and also provides how the git symbols and colors show up in the command line. If you've followed my previous post and were wondering how to you can control and fine tune the prompt this post should help.