1

I've found how to open a folder in explorer from sublime text 2, how can I open the folder with an arbitrary program, like Powershell?

I'm not looking for Powershell commands, I'm looking for keyboard shortcuts/functions etc to open a fold in a sublime text instance in powershell.

3
  • possible duplicate of Is it possible to open an explorer window from powershell Commented Feb 24, 2015 at 14:13
  • @Kev Wrong way round. I don't want to open Sublime from Powershell, I want to open Powershell from sublime. Is my edit any clearer? Commented Feb 24, 2015 at 14:16
  • 1
    Gotcha, thanks for posting this question, I learned something new today as well when answering it :) Commented Feb 24, 2015 at 15:05

1 Answer 1

2

For this type of thing you're now into the realm of having to write your own Sublime Text plugin which involves dabbling in some Python.

In a nutshell, you'd decide on which key mappings you want to use to open a PowerShell window (and ideally it'd open that window with PowerShell set to use the path of where your currently edited file resides), for example:

{
  "keys": ["shift+f12"],
  "command": "open_powershell_window"
}

You'd then map this to the desired behaviour (open a PowerShell window) in your plugin:

import sublime, sublime_plugin
# maps to open_powershell_window by converting to lower case and word-
# splitting using underscores
class OpenPowerShellWindowCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        # magic to open and run powershell

However, fortunately there's a plugin called Sublime Terminal which does this for us (and for other shells, depending on your OS). It'll either open a terminal window with the path set to your project folder, or your currently edited file.

You can install this using Package Control, just do Install Package and search for "Terminal" (look for the wbond.net url in the description to make sure you get the right one, it's at v1.4.0 just now).

You can find the source code here:

https://github.com/wbond/sublime_terminal

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.