In Gnome3, how do I create a keyboard shortcut for opening a file with a variable in the file name?

0

Typing gvim note_$(date +%F).md in terminal, opens a file in gvim that has today's date in the title. When I try to bind a keyboard shortcut to the same command, gvim throws an error message:

"note_$(date" [New File]
Error detected while processing command line:
E492: Not an editor command: ).md
Press ENTER or type command to continue

The file title reads note_$(date (~). I have tried with backticks and expr, but I receive the same error. I am on Gnome3 and trying to create the shortcut via Keyboard >> Shortcuts >> Custom Shortcuts.

How should I go about getting the keyboard shortcut command to work the same way as when typed directly in the terminal?

joelostblom

Posted 2016-02-19T01:35:13.800

Reputation: 1 833

Answers

0

I just figured out that the command runs fine if I put it in a script and then just assign a keyboard shortcut to the script. So in /path/to/file:

#!/bin/bash
gvim note_$(date +%F).md

Make the script executable (chmod +x /path/to/file), and in the 'command'-field for the shortcut, just put path/to/file.

joelostblom

Posted 2016-02-19T01:35:13.800

Reputation: 1 833