The VS Code extension adds buttons to status bar. The buttons can be used to execute custom commands in Terminal or to activate any VS Code command just like keyboard shortcuts do. The extension has adaptation for esp-idf framework.
The extension is inspired by vscode-action-buttons extension created by Seun Lanlege, maintains compatibility and expands functionality.
- Executing commands in terminal.
- Predefined vars like
${file}
can be used in commands for terminal. - Executing VS Code commands.
- Any command that can be activated via a keyboard shortcut can be activated via a button.
- Ability to customize text color for a buttons.
- Iconized buttons.
- Icons can be added to buttons by using the Markdown icons-in-labels syntax. For example, to add an alert icon you include
$(alert)
in the button name. See https://code.visualstudio.com/api/references/icons-in-labels for more info.
- Icons can be added to buttons by using the Markdown icons-in-labels syntax. For example, to add an alert icon you include
The main feature for which the new version of the extension was created is an ability to run commands in the same terminal, regardless of which button they are generated by.
- Commands can be executed in any allready opened terminal without creating a new one.
- Define the terminal name in command option, so that the command will be executed in the existing terminal. If a terminal with that name does not exist it will be created.
- A button can send one or more commands to a terminal.
- Builtin command
clear
before the custom command is now conditional. - User defined config options can be used in commands for terminal.
- Use these variables in form like
${var}
.
- Use these variables in form like
β If this project help you reduce time to develop, you can give me a cup of coffee β€οΈ
- Install the
VSCode Action Buttons
extension in your VS Code instance. - After installing, open your VS Code settings (
Ctrl+,
). Navigate to theExtensions
section then to theVSCode Action Buttons
subsection (at the end or almost at the end of list). - Press
Edit in settings.json
and define the action buttons you want. Below is a sample configuration for reference. See Config Options for a list of valid options for each command. - Reload the VS Code window to see the new buttons. Alternatively, you can run the
Refresh Action Buttons
command to refresh without reloading the window.
"actionButtons": {
"reloadButton": "β»οΈ", /* Custom reload button text */
"defaultColor": "#ff0034", /* Can also use string color names */
"loadNpmCommands": false, /* Disables automatic generation of actions for npm commands */
"commands": [
{
"cwd": "/home/custom_folder", /* Terminal initial folder */
"name": "Run Cargo",
"color": "green",
"singleInstance": true,
"command": "cargo run ${file}", /* This is executed in the terminal */
},
{
"name": "Build Cargo",
"color": "green",
"command": "cargo build ${file}",
},
{
"name": "πͺ Split editor",
"color": "orange",
"useVsCodeApi": true,
"command": "workbench.action.splitEditor"
},
{
/* example for esp-idf oriented command */
"name": "Flash",
"terminalName": "ESP-IDF 4.4 CMD",
"color": "red",
"useVsCodeApi": false,
"ignoreCwd": true,
"ignoreClear": true,
"command": "idf.py -p ${port} flash",
"extraCommands": [
"idf.py -p ${port} monitor"
]
}
]
"customVars": {
"port": "COM4" /* Can be used in command as `${port}`*/
}
}
- reloadButton
- Text for reload actions button. Defaults to
β»
. Set to null value to enable automatic reload on configuration change, in this case the reload button is disabled.
- Text for reload actions button. Defaults to
- defaultColor
- Default text color of action buttons. Defaults to
white
.
- Default text color of action buttons. Defaults to
- loadNpmCommands
- Whether or not to automatically generate action buttons from commands specified in
package.json
. Defaults tofalse
.
- Whether or not to automatically generate action buttons from commands specified in
- commands
- List of action buttons to add to the status bar. Defaults to
[]
. See Command Options for a list of valid options for each command.
- List of action buttons to add to the status bar. Defaults to
- π₯ customVars
- List of user defined config options. Defaults to
{}
. Can be used in commands for terminal in form like${var}
.
- List of user defined config options. Defaults to
- name
- Name of the action button. This field is required.
- command
- Command to execute when action is activated. This field is required.
- If
useVsCodeApi
istrue
, this is the VS Code command to execute. Otherwise, this specifies the command to execute in the terminal. - Predefined vars like
${file}
can be used in commands for terminal. See Config Vars for a list of valid vars. - User defined config options can be used in commands for terminal. Use these variables in form like
${var}
.
- color
- Specifies the action button text color. Defaults to
defaultColor
.
- Specifies the action button text color. Defaults to
- tooltip
- Tooltip text to display when hovering over the button. Defaults to
command
.
- Tooltip text to display when hovering over the button. Defaults to
- cwd
- Start directory when executing terminal command. Defaults to
${workspaceFolder}
. Only valid whenuseVsCodeApi
isfalse
. - If
ignoreCwd
istrue
, the terminal does not receivecmd
nor${workspaceFolder}
as start directory and opens in its own start directory.
- Start directory when executing terminal command. Defaults to
- singleInstance
- Reopen associated terminal each time this action is activated. Defaults to
false
. Only valid whenuseVsCodeApi
isfalse
.
- Reopen associated terminal each time this action is activated. Defaults to
- focus
- Focus the terminal after executing the command. Defaults to
false
. Only valid whenuseVsCodeApi
isfalse
.
- Focus the terminal after executing the command. Defaults to
- useVsCodeApi
- Specifies whether to execute a VS Code command or terminal command. Defaults to
false
.
- Specifies whether to execute a VS Code command or terminal command. Defaults to
- args
- Specifies additional arguments to pass to VS Code command. Only valid when
useVsCodeApi
istrue
.
- Specifies additional arguments to pass to VS Code command. Only valid when
- π₯ ignoreCwd
- Specifies whether to ignore
cwd
parameter while creating a terminal. Defaults tofalse
that meanscwd
is not ignored.
- Specifies whether to ignore
- π₯ ignoreClear
- Specifies whether to send builtin
clear
command to the terminal before the user definedcommand
. Defaults tofalse
that means builtinclear
is sent before the user definedcommand
.
- Specifies whether to send builtin
- π₯ extraCommands
- Specifies additional commands to be sent to the terminal just after the user defined
command
. Defaults to[]
. - Predefined vars like
${file}
can also be used in commands. - User defined config options can also be used in commands in form like
${var}
.
- Specifies additional commands to be sent to the terminal just after the user defined
- π₯ terminalName
- Specifies the terminal name in which the command(s) to be executed. If there is no runnnig terminal with such name than new terminal with name
terminalName
will be created. Defaults to empty string.
- Specifies the terminal name in which the command(s) to be executed. If there is no runnnig terminal with such name than new terminal with name
- π₯ timeoutAfterCreate
- Specifies timeout in milliseconds between creating a new terminal and sending the command(s) to it. If terminal already exists no timeout inserted.
As seen in the previous example, vars such as ${file}
can be used. Below is a list of each of them and what they do.
workspaceFolder
- the path of the folder opened in VS Code.workspaceFolderBasename
- the name of the folder opened in VS Code without any slashes (/).file
- the current opened file.relativeFile
- the current opened file relative to workspaceFolder.fileBasename
- the current opened file's basename.fileBasenameNoExtension
- the current opened file's basename with no file extension.fileDirname
- the current opened file's dirname.fileExtname
- the current opened file's extension.cwd
- the task runner's current working directory on startup.lineNumber
- the current selected line number in the active file.selectedText
- the current selected text in the active file.execPath
- the path to the running VS Code executable.
VS Code configuration for comfortable work in esp-idf will be described in separate document.
- If you want to give feedback or report issue, please create a new GitHub issue. Please check if a topic about your issue already exists.
- Leave a review on Visual Studio Marketplace.
See CHANGELOG for more information.