Permalink
Browse files

Export Get-SshPath [-File <file>]

Pretty sure GH4W has logic similar to this...might as well share.
File defaults to id_rsa.
  • Loading branch information...
1 parent bcf1a4d commit 0bfaeee65b355539d7c2d6f13ca01dbbfb5dbe7b @dahlbyk committed Mar 30, 2013
Showing with 5 additions and 9 deletions.
  1. +4 −9 GitUtils.ps1
  2. +1 −0 posh-git.psm1
View
@@ -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
@@ -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) {
View
@@ -32,6 +32,7 @@ Export-ModuleMember `
'Start-SshAgent',
'Stop-SshAgent',
'Add-SshKey',
+ 'Get-SshPath',
'Update-AllBranches',
'tgit')

0 comments on commit 0bfaeee

Please sign in to comment.