Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions contributed/Table-Switcher.spBundle/command.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?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>author</key>
<string>Nick Tyler</string>
<key>command</key>
<string># check for empty STDIN
SEARCHED_TABLE=$(cat)
if [ -z "$SEARCHED_TABLE" ]; then
exit
fi

# Store all tables in array
OIFS=$IFS;
IFS='\t' read -a array &lt;&lt;&lt; "$string"

TABLE_ARRAY=($SP_ALL_TABLES);

IFS=$OIFS

# Searches an array for a string
containsElement () {
local e
for e in "${@:2}"; do [[ "$e" == *"$1"* ]] &amp;&amp; echo $e; done
}

MATCHED_TABLES=($(containsElement "$SEARCHED_TABLE" "${TABLE_ARRAY[@]}"))

# See if one table matches the given string, select it if so
if [ ${#MATCHED_TABLES[@]} -eq 0 ]; then
exit
else
open sequelpro://$SP_PROCESS_ID@passToDoc/SelectTable/${MATCHED_TABLES[0]}
fi

</string>
<key>contact</key>
<string>nick@goguardian.com</string>
<key>description</key>
<string>Enter a table name or a part of a table name, and this bundle will select the first matching table in the current database.</string>
<key>input</key>
<string>entirecontent</string>
<key>input_fallback</key>
<string>entirecontent</string>
<key>internalKeyEquivalent</key>
<dict>
<key>characters</key>
<string></string>
<key>keyCode</key>
<integer>36</integer>
<key>modifierFlags</key>
<integer>1048576</integer>
</dict>
<key>keyEquivalent</key>
<string>@
</string>
<key>name</key>
<string>Table Switcher</string>
<key>output</key>
<string>replacecontent</string>
<key>scope</key>
<string>inputfield</string>
<key>tooltip</key>
<string>Switches to the currently filtered table, if one exists.</string>
<key>uuid</key>
<string>AA3566E7-96E4-4576-8D8C-E465A17264E9</string>
</dict>
</plist>