Skip to content

Instantly share code, notes, and snippets.

@eager
Created March 20, 2014 21:04
Show Gist options
  • Save eager/9673780 to your computer and use it in GitHub Desktop.
Save eager/9673780 to your computer and use it in GitHub Desktop.
Sequel Pro Bundle scripts
# Bundle Scope: Data Table
# Menu Label: Copy as GFM
# Menu Category: Copy
# Input: Selected Rows (TSV) AND exclude BLOB
# Tooltip: Copies the selected rows excluding any BLOB data GitHub-Flavored-Markdown table-formatted into the pasteboard
cat | perl -e '
# read first line to get the column names (header)
$firstLine = <>;
# bail if nothing could read
if(!defined($firstLine)) {
exit 0;
}
# store the column names
chomp($firstLine);
print "| ";
my @columns = $firstLine =~ /[^\t]+/g;
$firstLine =~ s/\t/ | /g;
print "$firstLine";
print " |\n";
print "|";
foreach my $column (@columns) {
$column =~ s/.*/---/;
print " $column |";
}
print "\n";
# read row data of each selected row
$rowData=<>;
while($rowData) {
print "| ";
chomp($rowData);
$rowData =~ s/\t/ | /g;
print "$rowData";
print " |\n";
# get next row
$rowData=<>;
}
' | __CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbcopy
# Bundle Scope: Data Table
# Menu Label: Copy as YouTrack
# Menu Category: Copy
# Input: Selected Rows (TSV) AND exclude BLOB
# Tooltip: Copies the selected rows excluding any BLOB data YouTrack table-formatted into the pasteboard
cat | perl -e '
# read first line to get the column names (header)
$firstLine = <>;
# bail if nothing could read
if(!defined($firstLine)) {
exit 0;
}
# store the column names
chomp($firstLine);
print "|| ";
$firstLine =~ s/\t/ || /g;
print "$firstLine";
print " ||\n";
# read row data of each selected row
$rowData=<>;
while($rowData) {
print "| ";
chomp($rowData);
$rowData =~ s/\t/ | /g;
print "$rowData";
print " |\n";
# get next row
$rowData=<>;
}
' | __CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment