Add customizable buttons to the status bar to execute actions or tasks in VS Code.
- Execute command in terminal
- Execute VS Code command
- Any command that can be activated via a keyboard shortcut can be activated via a button
- Ability to customize text color for each button
- Add icons to 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
- Install the
VsCode Action Buttons
extension in your VS Code instance. - After installing, open your VS Code settings (
Ctrl + ,
). Navigate to theVsCode Action Buttons
section. - Define the action buttons you want. Below is a sample configuration for reference.
- 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": {
"defaultColor": "#ff0034", // Can also use string color names.
"loadNpmCommands":false, // Disables automatic generation of actions for npm commands.
"reloadButton":"♻️", // Custom reload button text or icon (default ↻). null value enables automatic reload on configuration change
"commands": [
{
"cwd": "/home/custom_folder", // Terminal initial folder ${workspaceFolder} and os user home as defaults
"name": "$(triangle-right) Run Cargo",
"color": "green",
"singleInstance": true,
"command": "cargo run ${file}", // This is executed in the terminal.
},
{
"name": "$(tools) Build Cargo",
"color": "green",
"command": "cargo build ${file}",
},
{
"name": "$(split-horizontal) Split editor",
"color": "orange",
"useVsCodeApi": true,
"command": "workbench.action.splitEditor"
}
]
}
- reloadButton
- Text for reload actions button. Defaults to
↻
. If null, the reload button is disabled.
- Text for reload actions button. Defaults to
- defaultColor
- Default text color of action buttons. Defaults to
white
. To set default theme color typenone
.
- 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 below for a list of valid options for each command
- List of action buttons to add to the status bar. Defaults to
- name
- Name of the action button. This field is required. You can add icons in command name by typing
$(icon-name)
. Look here for icons. (Note: If you will misspell no icons will show)
- Name of the action button. This field is required. You can add icons in command name by typing
- saveAll
- Save all open files before execute command
- 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
- 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
- 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
"actionButtons": {
"reloadButton": null,
"loadNpmCommands": false,
"commands": [
{
"name": "Run Cargo",
"singleInstance": true,
"color": "#af565c",
"command": "cargo run ${file}",
},
]
}
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 CodeworkspaceFolderBasename
- the name of the folder opened in VS Code without any slashes (/)file
- the current opened filerelativeFile
- the current opened file relative to workspaceFolderfileBasename
- the current opened file's basenamefileBasenameNoExtension
- the current opened file's basename with no file extensionfileDirname
- the current opened file's dirnamefileExtname
- the current opened file's extensioncwd
- the task runner's current working directory on startuplineNumber
- the current selected line number in the active fileselectedText
- the current selected text in the active fileexecPath
- the path to the running VS Code executable
Fix clear terminal command on windows #85
Added support for VSCode API calls
Added api
option.
Added support for VSCode predefined variables as ${file}
Added cwd
option.
Added reloadButton
option.
Added loadNpmCommands
option.
Added Refresh Action Buttons
action button
Changed configuration name from run
to actionButton
Better support for js projects
Added singleInstance
option.
Added support for default Colors
Added support for reading actions from the scripts segment of package.json.
Better documentation.
Initial Release