Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the "username@host" from powershell prompt?

I am using Windows Terminal(Preview) with shells like 1.PowerShell, 2.WSL in my Windows 10 machine. I installed the latest version of oh-my-posh and posh-git to customize the terminal. My current theme is Agnoster which gives a colorful custom prompt. But I want to get rid of the "username@host" from my prompt.

Eg:

Current => username@host D:\folder-name>

Needed => D:\folder-name>

I tried few things with $GitPromptSettings variable and also in GitPrompt.ps1 file which is inside the posh-git folder but with no use.

Also, since i have oh-my-posh and posh-git, does both have prompt customization properties or it is only from posh-git?

Any help is appreciated.

like image 474
Saravana Kumar M Avatar asked Mar 05 '20 11:03

Saravana Kumar M


2 Answers

remove the segment which type is session from ~\Documents\WindowsPowerShell\Modules\oh-my-posh\3.101.23\themes\<themename>.omp.json

like image 72
cocoa2135 Avatar answered Oct 13 '22 06:10

cocoa2135


You have to set $DefaultUser before importing modules.

Example:

$global:DefaultUser = [System.Environment]::UserName
Import-Module posh-git 
Import-Module oh-my-posh
Set-Theme Paradox
like image 7
SatoshiFukumori Avatar answered Oct 13 '22 06:10

SatoshiFukumori