amoilanen / Brackets-Command-Line-Shortcuts

Brackets IDE plugin. Adds support of shortcuts for execution of terminal commands right from the IDE.
8 stars 1 forks source link

Add a special variable for currently openned file #5

Closed dvorapa closed 9 years ago

dvorapa commented 9 years ago

Add a special variable for currently openned file to use in the command ("cmd" option)

amoilanen commented 9 years ago

Thanks for filing an issue, this would be a useful feature and should be fairly straightforward to implement. The current selection is available via the method ProjectManager.getSelectedItem() http://brackets.io/docs/current/modules/project/ProjectManager.html, we can add a couple of variables in the configuration like $CURRENT_FILE to be used in cmd and $CURRENT_FILE_DIR to be used in dir.

dvorapa commented 9 years ago

Wow, thanks for quick response. :thumbsup: for your work

amoilanen commented 9 years ago

Implemented in the commit 009ff20be77cea59d071ed9d784e1846c5048484. The variable for currently selected file is SELECTED_ITEM and for its parent directory SELECTED_ITEM_DIR.

Example configuration fragment:

[
    ...
    {
        "name": "Display contents of the currently selected file",
        "dir": "$SELECTED_ITEM_DIR",
        "cmd": "cat $SELECTED_ITEM",
        "shortcut": "Ctrl-Alt-C"
    }
    ...
]

The new version is not yet in the extension repository, but you can just check out the sources and overwrite the installed extension in the directory /home/username/.config/Brackets/extensions/user/aivanov.command-line-shortcuts (for Linux). Be careful not to overwrite your customized configuration file.

dvorapa commented 9 years ago

Works as expected, many thanks!

amoilanen commented 9 years ago

Thank you also for feedback, please, feel free to suggest further extensions.