Conversation
src/Utils.ps1
Outdated
|
|
||
| function Get-PromptConnectionInfo { | ||
| if (Test-Path Env:SSH_CONNECTION) { | ||
| if ($sshUserName -and $sshUserName -ne [System.Environment]::UserName) { |
There was a problem hiding this comment.
They made a late change in that PowerShell PR due to user names on Linux being case-sensitive. I think you want -cne here. Also, I thought we were using soft-tabs of 4 spaces? :-) I'll test this tomorrow when I get into work and have access to a system with sshd set to use PowerShell.
There was a problem hiding this comment.
Also, I thought we were using soft-tabs of 4 spaces? :-)
I have no idea what you're talking about.
I think you want
-cnehere.
Fixed. Though I'm tempted to punish anyone who actually hits that scenario. 🙄
What's different here compared with PowerShell/PowerShell#7191? |
|
I think it is because that method in the PR is getting a |
|
Taking a closer look at @rkeithhill does |
|
That code gets used from a PS remoting session. It does not get used when you SSH into a Windows system where the default shell is set to PowerShell. |
|
$Host.Runspace is a LocalRunspace as well. |
{0} = hostname
{1} = username
I knew I was missing something. That's the ELI5 I needed. Added code to always include username ( |
src/PoshGitTypes.ps1
Outdated
| [PoshGitTextSpan]$DefaultPromptSuffix = '$(">" * ($nestedPromptLevel + 1)) ' | ||
|
|
||
| [bool]$DefaultPromptAbbreviateHomeDirectory = $true | ||
| [string]$DefaultPromptConnectionFormat = '[{1}@{0}]: ' |
There was a problem hiding this comment.
I wonder if instead of this setting that isn't perhaps obviously connected to Get-PromptConnectionInfo, we should just have that command take a format string as parameter. We could make that parameter optional (i.e. default it to '[{1}@{0}]: ' . I'd use it explicitly for $DefaultPromptPrefix so folks see they can tweak the format e.g.:
[PoshGitTextSpan]$DefaultPromptPrefix = '$(Get-PromptConnectionInfo -Format "[{1}@{0}]: ")'
Although at this point maybe we switch the format placeholders to [{0}@{1}]: ?
There was a problem hiding this comment.
Good idea! Thoughts on -Format vs ScriptBlock?
[PoshGitTextSpan]$DefaultPromptPrefix = '$(Get-PromptConnectionInfo {param($Hostname, $Username) "[$Username@$Hostname]: "})' Similarly, should we ditch DefaultPromptAbbreviateHomeDirectory?
[PoshGitTextSpan]$DefaultPromptPath = '$(Get-PromptPath -AbbreviateHome)'There was a problem hiding this comment.
I think -Format is better and we should definitely provide a default. The only reason I would specify the -Format … parameter in that setting is purely pedagogical.
Re DefaultPromptAbbreviateHomeDirectory, sounds good to me. We should note that in the CHANGELOG as a potentially breaking change though.
There was a problem hiding this comment.
Eh, DefaultPromptAbbreviateHomeDirectory has been established since v0.7.0, doesn't seem worth breaking everyone now.
I'll replace the new setting with -Format.

Procrastination!
Closes #591 by roughly imitating PowerShell/PowerShell#7191 (show
[user@host]if user seems to not match, otherwise[host]). I don't use PS remoting, so I'll need some help verifying this works as expected.Rather than place the logic inline, I figure exporting
Get-PromptConnectionInfoaffords flexibility to make this configurable (e.g.$GitPromptSettings.DefaultPromptConnectionShowUserName = 'always|never|different'or$GitPromptSettings.DefaultPromptConnectionFormatWithUserName).