From 39e9dca613f1792af7ff15c0d3df9cc6a05a6472 Mon Sep 17 00:00:00 2001 From: Nick Tyler Date: Sun, 22 Feb 2015 14:52:23 -0800 Subject: [PATCH 1/2] Table Switcher Bundle - This bundle selects a table in the currently connected database, based on the input provided in STDIN. If the provided string matches any database tables, selects the first one. Used in conjunction with the "filter tables" command provided in Sequel Pro to easily switch to a typed-in table. --- .../Table-Switcher.spBundle/command.plist | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 contributed/Table-Switcher.spBundle/command.plist diff --git a/contributed/Table-Switcher.spBundle/command.plist b/contributed/Table-Switcher.spBundle/command.plist new file mode 100644 index 0000000..9878fdb --- /dev/null +++ b/contributed/Table-Switcher.spBundle/command.plist @@ -0,0 +1,70 @@ + + + + + author + Nick Tyler + command + # 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 <<< "$string" + +TABLE_ARRAY=($SP_ALL_TABLES); + +IFS=$OIFS + +# Searches an array for a string +containsElement () { + local e + for e in "${@:2}"; do [[ "$e" == *"$1"* ]] && 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 + + + contact + avpx@tbthneqvna.pbz + description + Enter a table name or a part of a table name, and this bundle will select the first matching table in the current database. + input + entirecontent + input_fallback + entirecontent + internalKeyEquivalent + + characters + + + keyCode + 36 + modifierFlags + 1048576 + + keyEquivalent + @ + + name + Table Switcher + output + replacecontent + scope + inputfield + tooltip + Switches to the currently filtered table, if one exists. + uuid + AA3566E7-96E4-4576-8D8C-E465A17264E9 + + From 4428e300dca3a63ea77e3cafff33bbb076288c77 Mon Sep 17 00:00:00 2001 From: Nick Tyler Date: Sun, 22 Feb 2015 14:56:09 -0800 Subject: [PATCH 2/2] Update command.plist indentation --- .../Table-Switcher.spBundle/command.plist | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/contributed/Table-Switcher.spBundle/command.plist b/contributed/Table-Switcher.spBundle/command.plist index 9878fdb..0e0e732 100644 --- a/contributed/Table-Switcher.spBundle/command.plist +++ b/contributed/Table-Switcher.spBundle/command.plist @@ -2,10 +2,10 @@ - author - Nick Tyler - command - # check for empty STDIN +author +Nick Tyler +command +# check for empty STDIN SEARCHED_TABLE=$(cat) if [ -z "$SEARCHED_TABLE" ]; then exit @@ -35,36 +35,35 @@ else fi - contact - avpx@tbthneqvna.pbz - description - Enter a table name or a part of a table name, and this bundle will select the first matching table in the current database. - input - entirecontent - input_fallback - entirecontent - internalKeyEquivalent - - characters - - - keyCode - 36 - modifierFlags - 1048576 - - keyEquivalent - @ +contact +nick@goguardian.com +description +Enter a table name or a part of a table name, and this bundle will select the first matching table in the current database. +input +entirecontent +input_fallback +entirecontent +internalKeyEquivalent + +characters + +keyCode +36 +modifierFlags +1048576 + +keyEquivalent +@ - name - Table Switcher - output - replacecontent - scope - inputfield - tooltip - Switches to the currently filtered table, if one exists. - uuid - AA3566E7-96E4-4576-8D8C-E465A17264E9 +name +Table Switcher +output +replacecontent +scope +inputfield +tooltip +Switches to the currently filtered table, if one exists. +uuid +AA3566E7-96E4-4576-8D8C-E465A17264E9