-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAlias-NotepadPlusPlus.ps1
More file actions
30 lines (28 loc) · 1.29 KB
/
Alias-NotepadPlusPlus.ps1
File metadata and controls
30 lines (28 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<#
Creates an alias for NotepadPlusPlus.
Or BBEdit on MacOS. (Install BBEdit CLI, /usr/local/bin/bbedit)
Or on anything else...
#>
# "C:\Program Files\Notepad++\notepad++.exe"
# PowerShell Core
if ( ($PSVersionTable.PSVersion.Major -eq 5) -or ($IsWindows) ) { # Windows PowerShell 5 only runs on Windows.
if ( Test-Path -Path $(Join-Path -Path $env:ProgramFiles -ChildPath 'Notepad++\notepad++.exe') ) {
new-item alias:npp -value "$(Join-Path -Path $env:ProgramFiles -ChildPath 'Notepad++\notepad++.exe')"
} elseif ( Test-Path -Path $(Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'Notepad++\notepad++.exe') ) {
new-item alias:npp -value "$(Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'Notepad++\notepad++.exe')"
} else {
new-item alias:npp -value "$env:SYSTEMROOT\System32\notepad.exe"
}
} else {
if ($IsMacOS) {
if ( Test-Path -Path "/usr/local/bin/bbedit" ) {
new-item alias:npp -value "/usr/local/bin/bbedit"
} else {
# Write-Host "BBEdit Command Line Tools not installed. See https://www.barebones.com/products/bbedit/benefitscommand.html"
new-item alias:npp -value "/usr/bin/nano"
}
} elseif ($IsLinux) {
new-item alias:npp -value "/usr/bin/nano"
}
}
Write-Host ""