Created
August 15, 2013 20:09
-
-
Save cfg/6244347 to your computer and use it in GitHub Desktop.
Save as /usr/local/bin/handler-subl and use with https://gist.github.com/cfg/6244326
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env php -q | |
| <?php | |
| $subl = '/usr/local/bin/subl'; | |
| if( empty($argv[1]) ) | |
| exit(1); | |
| $parts = parse_url( $argv[1] ); | |
| $scheme = $parts['scheme']; | |
| $action = $parts['host']; | |
| $query = $parts['query']; | |
| $file = false; | |
| $line = false; | |
| parse_str( $query ); | |
| if( empty($file) ) | |
| exit(1); | |
| if( !empty($line) && intval($line) ) | |
| $file = $file . ':' . intval($line); | |
| $cmd = escapeshellcmd($subl) . ' ' . escapeshellarg( $file ); | |
| exec( $cmd, $output, $retval ); | |
| exit($retval); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment