This is a suggestion that would bring PowerShell more into line with Bash. For instance, if I ssh from my Windows 10 OpenSSH enabled system to a RHEL7 box, this is the prompt I get from Bash:
PS C:\> ssh [email protected]
[email protected]'s password:
Last login: Thu Jun 21 09:51:35 2018 from stacy1.acme.com
Kickstarted on 2016-02-26
[[email protected]@es-kalbuild-rh ~]$
This system has PowerShell Core 6.0.1 installed on it and if I open a PSSession to it, I get the hostname in the default prompt but not the username/logname. FWIW I never log into this system as myself so it is very useful to see what user I'm logged in as.
> Enter-PSSession -HostName es-kalbuild-rh.acme.com -UserName mctcbld
[email protected]'s password:
[es-kalbuild-rh.acme.com]: PS /home/mctcbld>
The default prompt I'd like to see is:
[mctcbld@es-kalbuild-rh]: PS /home/mctcbld>
# or maybe even
[[email protected]@es-kalbuild-rh]: PS ~>
I don't need to see the DNS suffix - just the hostname.
Finally, the docs I see for configuring powershell as a subsystem of sshd, say to use -NoProfile but then how could you configure/customize this prompt for the SSH transport?
@PaulHigin Could please comment the Issue?
Including the current user in the prompt seems like a personal choice. PowerShell remoting automatically prepends "[computerName]: " to the current prompt to indicate the target machine name, but does not include the current user name.
But you can easily include the user name by changing the prompt function in your remote session. Something like:
function prompt { "[$(whoami)]: PS $($executioncontext.sessionstate.Path.CurrentLocation)$('>' * ($nestedPromptLevel+1)) "
But we don't yet support configured endpoints for SSH based remoting so you would have to manually run a script file to change the prompt for each session. Once we have configured endpoints then you could simply configure the prompt with a "startup" script.
Don't you think most Linux folks would expect to see the username as well? Every Linux system I've ssh'd into shows me the username in the prompt.
What would be cool is if the remote session would display [<username>@<hostname>]: if the remote username is different than the client side username. And if they're the same, just display [<hostname>]: like it does now. :-)
Sure, it would be easy to do this by default. Just update the remoting prompt code.
@PaulHigin can you point to where in the source that prompt code exists?
EnterPSSessionCommand.SetRunspacePrompt() (PushRunspaceCommand.cs)
@PaulHigin there must be some other location for the default prompt that shows the [hostname] as modifying SetRunspacePrompt() doubles it:
[hostname]: [user@hostname]: PS /home/user>
Nevermind, found it.