Skip to content

Commit

Permalink
Export Get-SshPath [-File <file>]
Browse files Browse the repository at this point in the history
Pretty sure GH4W has logic similar to this...might as well share.
File defaults to id_rsa.
  • Loading branch information
dahlbyk committed Mar 30, 2013
1 parent bcf1a4d commit 0bfaeee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 4 additions & 9 deletions GitUtils.ps1
Expand Up @@ -260,15 +260,10 @@ function Start-SshAgent([switch]$Quiet) {
Add-SshKey
}

#get the default ssh keyfile
function Get-SshFile()
function Get-SshPath($File = 'id_rsa')
{
if ($Env:HOME) {
Resolve-Path (Join-Path (Resolve-Path $Env:HOME) ".ssh\id_rsa") -ErrorAction SilentlyContinue 2> $null
}
else {
Resolve-Path ~/.ssh/id_rsa -ErrorAction SilentlyContinue 2> $null
}
$home = Resolve-Path (Invoke-NullCoalescing $Env:HOME ~)
Resolve-Path (Join-Path $home '.ssh\$File') -ErrorAction SilentlyContinue 2> $null
}

# Add a key to the SSH agent
Expand All @@ -277,7 +272,7 @@ function Add-SshKey() {
if (!$sshAdd) { Write-Warning 'Could not find ssh-add'; return }

if ($args.Count -eq 0) {
$sshPath = Get-SshFile
$sshPath = Get-SshPath
if ($sshPath) { & $sshAdd $sshPath }
} else {
foreach ($value in $args) {
Expand Down
1 change: 1 addition & 0 deletions posh-git.psm1
Expand Up @@ -32,6 +32,7 @@ Export-ModuleMember `
'Start-SshAgent',
'Stop-SshAgent',
'Add-SshKey',
'Get-SshPath',
'Update-AllBranches',
'tgit')

Expand Down

0 comments on commit 0bfaeee

Please sign in to comment.