1

Currently I am trying to make it so I can open up files from PowerShell directly in Sublime Text 3.

I am using this command: Set-Alias subl 'C:\Program Files\Sublime Text 2\sublime_text.exe'

This works for me initially when I type in "subl filename", but whenever I close out of PowerShell and try it again, it will not work unless I re-type the Set-Alias command. Is there any way to permanently make this possible, so I can always type in subl filename ?

Kohlbrr
  • 3,861
  • 1
  • 21
  • 24

1 Answers1

1

Try running Get-Help about_Profiles

As a quick overview:

PowerShell will load the .ps1 file located at the $Profile path into the session when it starts. Adding Set-Alias subl 'C:\Program Files\Sublime Text 2\sublime_text.exe' to that file will set that alias every time a new PowerShell session is opened.

Kohlbrr
  • 3,861
  • 1
  • 21
  • 24
  • I followed those instructions, but when I open powershell now, It gives me the error: File C:\Users\Me\Documents\WindowsPowerShell\Microsoft.Powershell_profile.ps1 cannotbe loaded because running scripts is disabled on this system. – Vineet Rastogi Oct 27 '14 at 14:50
  • Try running `Get-Help about_Execution_Policies` – Kohlbrr Oct 27 '14 at 14:54
  • http://technet.microsoft.com/library/hh847748.aspx Im using this website, and am confused which policies to set, and what they should be set to – Vineet Rastogi Oct 27 '14 at 14:56
  • Great, i fixed it thank you very much! I just set it to unrestricted, and i am not getting that error, and the powershell profile is loading perfectly – Vineet Rastogi Oct 27 '14 at 15:00
  • 3
    Vineet: `Unrestricted`, just as `Bypass` are things you shouldn't really set unless you know what you're doing. `RemoteSigned` is a reasonably safe choice. – Joey Oct 27 '14 at 15:18