Files
ChocolateyPackages/SublimeText2.PowershellAlias/tools/ChocolateyInstall.ps1
Iristyle 4482d900d2 feat(SublimeText2.PowershellAlias) - new pkg
- refactored out of existing SublimeText2.app
2013-04-03 23:42:06 -04:00

22 lines
753 B
PowerShell

try {
$package = 'SublimeText2.PowershellAlias'
$sublDefined = Test-Path function:subl
$profileExists = Test-Path $PROFILE
$sublInProfile = $profileExists -and (((Get-Content $PROFILE) -match '^function\s+subl\s+').Count -gt 0)
# add subl alias to powershell profile
if (!$sublDefined -and !$sublInProfile)
{
New-Item (Split-Path $PROFILE) -Type Directory -ErrorAction SilentlyContinue
'function subl { &"${Env:ProgramFiles}\Sublime Text 2\sublime_text.exe" $args }' |
Out-File -FilePath $PROFILE -Append -Encoding UTF8
Write-Host 'Added subl alias to Powershell profile to launch Sublime Text 2!'
}
Write-ChocolateySuccess $package
} catch {
Write-ChocolateyFailure $package "$($_.Exception.Message)"
throw
}