Skip to content
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

Start-SshAgent only in interactive session #238

Closed
wants to merge 1 commit into from
Closed

Start-SshAgent only in interactive session #238

wants to merge 1 commit into from

Conversation

StefanScherer
Copy link

First of all thanks for posh-git which makes working on Windows much more fun!

I had a problem using posh-git within a Vagrant box. After installing it and powering down the VM the next vagrant up hangs trying to connect through WinRM. I found the issue Parallels/vagrant-parallels#217 with a hint to posh-git.

So I have changed the profile.example.ps1 script to start the SSH agent only if the PowerShell is run as interactive session.

Is it possible to put this in the script as default? Or does this break in other situations?

@lukebakken
Copy link
Contributor

FWIW, I use the following, which also excludes starting ssh-agent from the NuGet console in Visual Studio. Apparently [Environment]::UserInteractive doesn't work correctly.

$nugetModule = Get-Module -Name NuGet
$isInteractiveDesktop = [bool]((Test-Path env:\SESSIONNAME) -And ($env:SESSIONNAME -eq 'Console'))
$isNonInteractive = [bool]([Environment]::GetCommandLineArgs() -Like '*NonInteractive*')
If (($nugetModule -eq $null) -And ($isInteractiveDesktop -eq $true) -And ($isNonInteractive -eq $false))
{
    Import-Module posh-git
    # Set up prompt here
    Start-SshAgent -Quiet
}

@StefanScherer
Copy link
Author

Closing this as I no longer have this problem.

@StefanScherer StefanScherer deleted the start-sshagent-only-interactive branch January 7, 2018 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants