Open failable opened 5 months ago
You can already merge this task into one by using the following:
${ZED_SELECTED_TEXT:-$(cat "$ZED_FILE")}
instead of $ZED_SELECTED_TEXT
It may not work if you're using fish though.
@osiewicz Hello, thanks for the hint.
I use bash and I try to get it work but can not figure out how to handle the quotes. The below two definition does not work.
This version does not work for selected text or whole file content:
{
"label": "Dpaste",
"command": "echo -e \"${ZED_SELECTED_TEXT:-$(cat \\\"$ZED_FILE\\\")}\" | curl -s -F \"content=<-\" https://dpaste.com/api/v2/ | pbcopy",
"use_new_terminal": false,
"allow_concurrent_runs": false,
"reveal": "always"
}
This version does work for selected text but does not work for whole file content:
{
"label": "Dpaste",
"command": "echo -e \"${ZED_SELECTED_TEXT:-$(cat \"$ZED_FILE\")}\" | curl -s -F \"content=<-\" https://dpaste.com/api/v2/ | pbcopy",
"use_new_terminal": false,
"allow_concurrent_runs": false,
"reveal": "always"
}
What version of Zed are you using? The second definition works for me on both Nightly and latest Stable (0.137.6)
Hello, I'm using Zed Preview 0.138.4. My bad, the second version works for whole file content but does not work for selected text.
Oh, I see. It fails for me as well with that selection.
I think you can change the double quotes to single quotes like so:
echo -e '${ZED_SELECTED_TEXT:-$(cat \"$ZED_FILE\")}' | curl -s -F \"content=<-\" https://dpaste.com/api/v2/ | pbcopy
Though if you try to run that on the same selection, you'll run into a small culprit (we perform variable substitution ourselves on cmd
. I can fix that.
@osiewicz Thanks for the hint. I always run into trouble when trying to quote variables. If there are clear rules of how it works, it would be great.
Check for existing issues
Describe the feature
Add a
selected text or current buffer
variable in tasks. If there is no text selected, the value of the variable default to current whole buffer. With this variable, the below two tasks can be merged into oneThis is a common pattern in Emacs, e.g.
If applicable, add mockups / screenshots to help present your vision of the feature
No response