Skip to content

Instantly share code, notes, and snippets.

@francois-dibulo
Last active February 1, 2017 14:23
Show Gist options
  • Save francois-dibulo/1aa078d21ef93c419c1c910f91a1060d to your computer and use it in GitHub Desktop.
Save francois-dibulo/1aa078d21ef93c419c1c910f91a1060d to your computer and use it in GitHub Desktop.
Open Project in AirConsole Simulator - Sublime Plugin
[
{
"caption": "AirConsole",
"mnemonic": "A",
"id": "OpenAirConsole",
"children":
[
{
"caption": "Open simulator",
"command": "open_air_console"
}
]
}
]
# A script actually for myself to open my current folder in
# the AirConsole Simulator from Sublime Text 3
#
# If you want to use it:
# 1. Copy this file into the "Sublime Text 3/Packages/User" folder
# 2. Adapt the HOST var (Better to use local ip address like 192.168.0.26:8080)
# 3. Adapt the WORKING_DIR_PATH var (E.g. "/Users/username/workspace/games/" -> 'workspace/games/')
import sublime
import sublime_plugin
import webbrowser
from os.path import expanduser
class OpenAirConsoleCommand(sublime_plugin.TextCommand):
def run(self, edit):
# CHANGE 'HOST' to your local IP address:
HOST = "http://localhost:8080"
# CHANGE 'WORKING_DIR_PATH' to your working root dir (where your host points to)
WORKING_DIR_PATH = "/workspace"
BASE_URL = "http://www.airconsole.com/simulator/#debug:"
folders = self.view.window().folders()
root_dir = folders[0]
home_dir = expanduser("~")
if root_dir:
root_path = home_dir + WORKING_DIR_PATH
project_path = root_dir.replace(root_path, "") + "/"
url = BASE_URL + HOST + project_path
print("Open: " + url)
webbrowser.open(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment