pgcli
pgcli copied to clipboard
Implement \copy (...) TO PROGRAM '...'
Hello.
Excellent project! So far, pgcli replaced the old psql
except for this one feature.
psql
allows you to use the \copy
command to pipe a query into a shell command, which might be useful to copy the results of a query to the system clipboard (using pbcopy on a Mac, though there are similar utilities for GNU/Linux and Windows). Therefore, if I do something like:
\copy (SELECT name, age FROM Users) TO PROGRAM 'pbcopy' DELIMITER e'\t' CSV HEADER
It copies the result of the query to the clipboard and then I can easily paste it into a spreadsheet application.
I would like to be able to do something like this on pgcli
as well.
How difficult would it be to implement this?
In psql
we can also do \g | pbcopy
which would basically copy the results from last query to clipboard. I really miss this in pgcli.
Any updates? wonder how people export query result to clipboard or external editors like vscode
Clipboard should be an optional solution because you could use this tool to export large volume of data which should not be stored in clipboard.
Export to disk like currently with \o filename
except in structured format e.g. CSV, JSONL etc. would amazing to have!
+1 to this, some kind of "copy last results" feature would be great. the point about large data size is reasonable but IMO this is a developer tool and you should give ppl the flexibility to choose that when it's appropriate.
This is especially frustrating due to pgcli's default behavior of truncating the later columns of wide table outputs. That's a nice feature for when you're browsing interactively, but makes it hard to retrieve that info to clipboard, since the later columns get truncated.
+1 copy results to clipboard select id from table
any chance on this ?