Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table Switcher Bundle #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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>[email protected]</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>