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.
Thanks
The extension is inspired by vscode-action-buttons extension created by Seun Lanlege, maintains compatibility and expands functionality.
Basic features
- 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.
🔥 Extended features
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}
.
Donation
☕ If this project help you reduce time to develop, you can give me a cup of coffee ❤️
Installation and setup
- [x] Install the
VSCode Action Buttons
extension in your VS Code instance.
- [x] After installing, open your VS Code settings (
Ctrl+,
). Navigate to the Extensions
section then to the VSCode Action Buttons
subsection (at the end or almost at the end of list).
- [x] 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.
- [x] 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}`*/
}
}
Config Options
- 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.
- defaultColor
- Default text color of action buttons. Defaults to
white
.
- loadNpmCommands
- Whether or not to automatically generate action buttons from commands specified in
package.json
. Defaults to false
.
- 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.
- 🔥 customVars
- List of user defined config options. Defaults to
{}
. Can be used in commands for terminal in form like ${var}
.
Command Options
- name
- Name of the action button. This field is required.
- command
- Command to execute when action is activated. This field is required.
- If
useVsCodeApi
is true
, 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
.
- tooltip
- Tooltip text to display when hovering over the button. Defaults to
command
.
- cwd
- Start directory when executing terminal command. Defaults to
${workspaceFolder}
. Only valid when useVsCodeApi
is false
.
- If
ignoreCwd
is true
, the terminal does not receive cmd
nor ${workspaceFolder}
as start directory and opens in its own start directory.
- singleInstance
- Reopen associated terminal each time this action is activated. Defaults to
false
. Only valid when useVsCodeApi
is false
.
- focus
- Focus the terminal after executing the command. Defaults to
false
. Only valid when useVsCodeApi
is false
.
- useVsCodeApi
- Specifies whether to execute a VS Code command or terminal command. Defaults to
false
.
- args
- Specifies additional arguments to pass to VS Code command. Only valid when
useVsCodeApi
is true
.
- 🔥 ignoreCwd
- Specifies whether to ignore
cwd
parameter while creating a terminal. Defaults to false
that means cwd
is not ignored.
- 🔥 ignoreClear
- Specifies whether to send builtin
clear
command to the terminal before the user defined command
. Defaults to false
that means builtin clear
is sent before the user defined command
.
- 🔥 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}
.
- 🔥 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.
- 🔥 timeoutAfterCreate
- Specifies timeout in milliseconds between creating a new terminal and sending the command(s) to it. If terminal already exists no timeout inserted.
Config Vars
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.
Specific for esp-idf users
VS Code configuration for comfortable work in esp-idf will be described in separate document.
Contributing
Release Notes
See CHANGELOG for more information.
License
MIT