-
-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance prompt function to show username/hostname in SSH connection #591
Comments
How is prompt handled for other PowerShell remoting situations? |
If I use WinRM as a transport instead of SSH, I get:
That's pretty much the only other remoting scenario I can think off. Note: it is subtle but the parameter |
If the default behavior is to put the remote host before |
OK, back from vacation … that's a great thought but when you are ssh'd into a remote system where PowerShell has been configured as the default shell, the |
As I've been using Windows 10 OpenSSH's sshd service and connecting to my Windows 10 system using ssh, I've been missing seeing the
[username@hostname]
info the PowerShell prompt on the remote system that I'm used to seeing when I ssh into a Linux box.We could rectify that by adding the following to our prompt function (somewhere before the prompt suffix):
"$(if (Test-Path Env:\SSH_CONNECTION) {" [$([System.Environment]::UserName)@$([System.Environment]::MachineName)]"})"
A few notes, you get the remote system's PowerShell prompt when you A) ssh into the remote system with OpenSSH sshd running and configured with this subsystem:
And no, I'm not quite sure why we get the posh-git prompt when the above specifies
-NoProfile
. Anyway, I've modified my posh-git prompt to this:So that when I ssh into this system, I see this prompt:
Note that when you use PS Remoting over SSH, PowerShell controls the prompt. In that case, you currently get just the hostname in the prompt:
But that is changing - see PowerShell/PowerShell#7156 & PowerShell/PowerShell#7191
So, should we consider covering this scenario with our prompt function or just add an example of how to customize the posh-git prompt if you want this feature?
The text was updated successfully, but these errors were encountered: