I am still quite new to Powershell, but I would like to add my favourite editor into an Alias in Powershell.
I edited the profile.ps1
in C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
which will run automatically when PowerShells starts.
I tried enter New-Alias np notepad.exe
which works perfectly everytime I launch PowerShell.
However, I would like to use Sublime Text 3
as my editor. I followed the instructions in this SO page: How can I write a PowerShell alias with arguments in the middle?
The command line I need for Sublime Text
is "C:\Program Files\Sublime Text 3\sublime_text.exe" -n [FirstArg]
Which I come out something like this: function sublime { 'C:\Program Files\Sublime Text 3\sublime_text.exe' -n $args }
It does not work and I got the error like this:
At C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1:5 char:72
+ ... lime { 'C:\Program Files\Sublime Text 3\sublime_text.exe' -n $args }
+ ~~
Unexpected token '-n' in expression or statement.
At C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1:5 char:75
+ ... lime { 'C:\Program Files\Sublime Text 3\sublime_text.exe' -n $args }
+ ~~~~~
Unexpected token '$args' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
Any helps would be appreciated. Thanks!