Skip to content

Instantly share code, notes, and snippets.

@patriciomg
Forked from jakob-stoeck/Copy as textile
Created December 7, 2022 08:59
Show Gist options
  • Save patriciomg/3f329d5875174de96bcc21a6185cba01 to your computer and use it in GitHub Desktop.
Save patriciomg/3f329d5875174de96bcc21a6185cba01 to your computer and use it in GitHub Desktop.
Copies SequelPro results as a textile table to use it in Redmine or other textile-supported systems. To use, just copy it into your SequelPro Bundle Editor.
#!/usr/bin/php
<?php
$in = fopen('php://stdin', 'r');
$result=array();
$format='_.';
while($line=fgetcsv($in, 0, "\t")) {
$result[]='|'.$format.implode('|'.$format, $line).'|';
$format='';
}
fclose($in);
$cmd='echo '.escapeshellarg(implode("\n", $result)).' | __CF_USER_TEXT_ENCODING='.posix_getuid().':0x8000100:0x8000100 pbcopy';
shell_exec($cmd);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment