Skip to content

Instantly share code, notes, and snippets.

@larryx64
Created June 25, 2017 17:27
Show Gist options
  • Save larryx64/a95acfa62d2f8b86c419959881ce7a7c to your computer and use it in GitHub Desktop.
Save larryx64/a95acfa62d2f8b86c419959881ce7a7c to your computer and use it in GitHub Desktop.
Helper class to launch Sublime
<?php
class Sublime
{
/**
* Sublime shell command
*/
const COMMAND = 'subl';
/**
* Launch sublime and open file
*
* @param string $file
* @return void
*/
public static function openFile($file)
{
exec(self::COMMAND .' '. $file);
}
/**
* Get Sublime file url (clickable URL from the browser)
*
* @param string $file
* @return string
*/
public static function fileUrl($file)
{
return self::COMMAND . '://open?url=file://' . $file;
}
}
@larryx64
Copy link
Author

Just make sure subl is in your $PATH. Although if you follow this tutorial, the command sould be sublime

http://olivierlacan.com/posts/launch-sublime-text-3-from-the-command-line/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment