Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command substitutions in shell commands #568

Open
flipsi opened this issue Oct 21, 2024 · 3 comments
Open

Command substitutions in shell commands #568

flipsi opened this issue Oct 21, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@flipsi
Copy link
Contributor

flipsi commented Oct 21, 2024

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"] }
@kamiyaa kamiyaa added the enhancement New feature or request label Oct 24, 2024
@kamiyaa
Copy link
Owner

kamiyaa commented Oct 24, 2024

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

@DLFW
Copy link
Contributor

DLFW commented Oct 24, 2024

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.

@flipsi
Copy link
Contributor Author

flipsi commented Oct 24, 2024

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 👌

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants