Skip to content

Instantly share code, notes, and snippets.

@namoscato
Forked from jakob-stoeck/Copy as textile
Last active January 19, 2022 04:49
Show Gist options
  • Select an option

  • Save namoscato/8b158853f984b124d90e48c7888c3bfa to your computer and use it in GitHub Desktop.

Select an option

Save namoscato/8b158853f984b124d90e48c7888c3bfa to your computer and use it in GitHub Desktop.
Copies Sequel Pro results as a GitHub and Jira Flavored Markdown table.
#!/usr/bin/php
<?php
$in = fopen('php://stdin', 'r');
$result = array();
$first = true;
while ($line = fgetcsv($in, 0, "\t")) {
$result[] = sprintf('|%s|', implode('|', $line));
if ($first) {
$result[] = sprintf('|%s|', implode('|', array_fill(0, count($line), '---')));
$first = false;
}
}
fclose($in);
shell_exec(sprintf(
'echo %s | __CF_USER_TEXT_ENCODING=%s:0x8000100:0x8000100 pbcopy',
escapeshellarg(implode("\n", $result)),
posix_getuid()
));
#!/usr/bin/php
<?php
$in = fopen('php://stdin', 'r');
$result = array();
$first = true;
while ($line = fgetcsv($in, 0, "\t")) {
$delimiter = sprintf('|%s', $first ? '|' : '');
$result[] = sprintf(
'%s%s%s',
$delimiter,
implode($delimiter, $line),
$delimiter
);
$first = false;
}
fclose($in);
shell_exec(sprintf(
'echo %s | __CF_USER_TEXT_ENCODING=%s:0x8000100:0x8000100 pbcopy',
escapeshellarg(implode("\n", $result)),
posix_getuid()
));
@namoscato
Copy link
Author

namoscato commented Jan 5, 2018

Usage

  1. Download, unzip, and add bundle command:

    curl -L https://www.dropbox.com/s/6su0086478cl328/copy-as-markdown-sequel-pro-bundles.tar.gz?dl=1 | tar -xzf - -C ~/Library/Application\ Support/Sequel\ Pro/Bundles
    
  2. Select some results.

  3. Bundles > Data Table > Copy > Copy as Markdown:
    screen shot 2018-05-25 at 5 14 59 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment