joshuto icon indicating copy to clipboard operation
joshuto copied to clipboard

Command substitutions in shell commands

Open flipsi opened this issue 1 year ago • 3 comments

Question: Is there support for command substitutions in shell commands? If not, consider this a feature request.

I tried

:shell echo $(date)

and

:shell echo \$(date)

but I always only see the literal (escaped?) string

$(date)

instead of the desired

Mon Oct 21 12:51:29 PM CEST 2024

My use case is is to create a keybinding to create a copy of a file like this:

  { keys = ["y", "b"], commands = ["shell cp -r %s %s.$(date +%F-%%H%M%S).bak"] }

flipsi avatar Oct 21 '24 10:10 flipsi

There isn't support for this yet, but might be currently possible with a bash script and calling the bash script instead

kamiyaa avatar Oct 24 '24 14:10 kamiyaa

Or maybe just by calling shell bash -c "cp ...."? Then you would not require an additional script file.... Haven't tried that but I guess it should work.

DLFW avatar Oct 24 '24 16:10 DLFW

There isn't support for this yet, but might be currently possible with a bash script and calling the bash script instead

Thank you, that workaround didn't come to mind yet! And yes, it works :ok_hand:

Or maybe just by calling shell bash -c "cp ...."? Then you would not require an additional script file.... Haven't tried that but I guess it should work.

Thank you, that'd be elegant, but I can't get it to work with the file substitution (%s).

flipsi avatar Oct 24 '24 21:10 flipsi