Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F117455750
local_definition.tmCommand
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jun 13, 19:25
Size
2 KB
Mime Type
text/xml
Expires
Sun, Jun 15, 19:25 (2 d)
Engine
blob
Format
Raw Data
Handle
26742690
Attached To
rPHU libphutil
local_definition.tmCommand
View Options
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env php
<?php
if (getenv('TM_SELECTED_TEXT')) {
$word = getenv('TM_SELECTED_TEXT');
} else {
$word = getenv('TM_CURRENT_WORD');
}
$file = getenv('TM_FILEPATH');
if (!is_dir($file)) {
$file = dirname($file);
}
$file = escapeshellarg($file);
$ref = null;
$err = 0;
$root = exec("(cd {$file} && /usr/bin/env git rev-parse --show-cdup)", $ref, $err);
if ($err) {
echo "File is not in a git working copy.\n";
exit($err);
}
$word = preg_quote($word, $delim = NULL);
$patterns = array(
"((abstract|final) +)*class +{$word}( |$)",
"interface +{$word}( |$)",
"function +&?{$word}( |\(|$)",
" *const +{$word}( |=|$)",
"@provides {$word}( |$)",
);
foreach ($patterns as $k => $pattern) {
$patterns[$k] = '-e '.escapeshellarg($pattern);
}
$patterns = implode(' --or ', $patterns);
$err = 0;
$cmd = "(cd {$root} && /usr/bin/env git grep --no-index -n -z -I -E {$patterns} | head -n1)";
$output = exec($cmd, $ref, $err);
$output = trim($output);
if (!$output) {
$untracked = exec("(cd {$root} && /usr/bin/env git ls-files --others --exclude-standard)");
if ($untracked) {
echo "No results found, but you have untracked files which 'git grep' does not search.\n";
} else {
echo "No results found.\n";
}
exit(0);
}
list($local, $line) = explode("\0", $output);
$target = $root.'/'.$local;
exec('/usr/bin/env mate '.escapeshellarg($target).' -l '.escapeshellarg($line));
</string>
<key>fallbackInput</key>
<string>word</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>@
</string>
<key>name</key>
<string>Open Definition (PHP, Local Git)</string>
<key>output</key>
<string>showAsTooltip</string>
<key>scope</key>
<string>source.php</string>
<key>uuid</key>
<string>0D267B50-2E9C-4B48-9D0C-0FB8E9807552</string>
</dict>
</plist>
Event Timeline
Log In to Comment