Skip to content

Instantly share code, notes, and snippets.

@DavidPx
Last active February 13, 2024 04:14
Show Gist options
  • Save DavidPx/fbf8c55009c09621084b267d8c325c70 to your computer and use it in GitHub Desktop.
Save DavidPx/fbf8c55009c09621084b267d8c325c70 to your computer and use it in GitHub Desktop.
CopyQ Commands

These are CopyQ commands I use for copying data out of spreadsheets and into SQL windows.

single-quoted-list.ini is good for creating an in clause from a single column of values.

values-grid.ini is good for creating the values section of an insert statement.

Installing these is quite easy:

  1. Copy the script
  2. Within Copyq hit F6 to bring up the Command editor
  3. Now click the Paste Commands button
[Command]
Command="
copyq:
var text = str(data(mimeText));
var updated = text.split('\\n').map(x => `'${x}'`).join(',\\n');
copy(mimeText, updated);
paste();
"
HideWindow=true
Icon=\xf00b
InMenu=true
Input=text/plain
Match=\\n
Name=Single &Quoted List
[Command]
Command="
copyq:
var text = str(data(mimeText));
var updated
= text
.split('\\n')
// split line content by tab
.map(line => '('+ line.split('\\t').map(x => `'${x}'`).join(',') + ')')
.join(',\\n');
copy(mimeText, updated);
paste();
"
HideWindow=true
Icon=\xf00a
InMenu=true
Input=text/plain
Match=\\t
Name=&Values List
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment