diff --git a/contributed/Table-Switcher.spBundle/command.plist b/contributed/Table-Switcher.spBundle/command.plist new file mode 100644 index 0000000..0e0e732 --- /dev/null +++ b/contributed/Table-Switcher.spBundle/command.plist @@ -0,0 +1,69 @@ + + + + +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 +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 + +