Coder Social home page Coder Social logo

usernamehw / vscode-commands Goto Github PK

View Code? Open in Web Editor NEW
57.0 3.0 15.0 2.52 MB

VSCode extension to run commands from Tree View / Status Bar / Quick Pick.

Home Page: https://marketplace.visualstudio.com/items?itemName=usernamehw.commands

License: MIT License

TypeScript 97.25% JavaScript 2.75%
vscode-extension command run sequence status-bar vscode

vscode-commands's Introduction

Version Installs Rating OpenVSX Downloads

Features

  • Run commands with arguments ("args")
  • Run multiple commands (in sequence)
  • Use Tree View / Quick Pick / Status Bar / Document link to run commands
  • Assign keyboard shortcut to specified commands
  • Create alias for existing commands

Simple command

"Toggle activity": "workbench.action.toggleActivityBarVisibility",

simple

Command with arguments

"Typing": {
    "command": "editor.action.insertSnippet",
    "args": {
        "snippet": "Typing... ",
    },
},

arguments

Multiple commands (sequence)

"Toggle multiple settings": {
    "sequence": [
        "editor.action.toggleMinimap",
        "workbench.action.toggleStatusbarVisibility",
    ],
},

sequence

Tree View icons list | colors

"GitHub": {
    "icon": "github",
},
"Flame": {
    "icon": "flame",
    "iconColor": "errorForeground",
},

icons

Folders (nested items)

"folder": {
    "nestedItems": {
        "Flame": {
            "icon": "flame",
            "iconColor": "errorForeground",
        },
        "Trusted": {
            "icon": "workspace-trusted",
            "iconColor": "terminal.ansiGreen",
        },
    },
},

folder

Quick Pick commands.openAsQuickPick

quick_pick

Status Bar

"Toggle line numbers": {
    "command": "commands.toggleSetting",
    "args": {
        "setting": "editor.lineNumbers",
        "value": [
            "on",
            "off",
        ],
    },
    "statusBar": {
        "alignment": "left",
        "text": "๐Ÿ”ข",
        "priority": -9999,
    },
},

status_bar

Commands (10)

Command Description
commands.openAsQuickPick Commands: Open as Quick Pick
commands.selectAndRun Commands: Select and run command
commands.rerun Commands: Rerun last command
commands.suggestCommands Commands: Suggest (autocomplete) commands
commands.suggestCodicons Commands: Suggest Codicons
commands.suggestVariables Commands: Suggest variables that are supported by this extension's variable substitutions, e.g: ${workspaceFolderBasename}. ๐Ÿ“š Docs
commands.suggestSettings Commands: Suggest setting ids (user & workspace).
commands.suggestColors Commands: Suggest theme color ids theme-color.
commands.newCommand Commands: Add new command to the list
commands.escapeCommandUriArgument Commands: Escape command uri argument

Settings (15)

Setting Default Description
commands.commands {} Main extension property. Commands that will be rendered in the View.
commands.workspaceCommands {} Commands that will be rendered in the View, specific to the workspace.
commands.alias {} Use shorter command ids. Extension registers aliased commands so that they can be also used in keybindings.
commands.showKeybindings false Whether or not to show keyboard shortcuts assigned to command contributed by user. (Currently only displayed in Tree View).
commands.treeViewCollapseFolders false Collapse folders by default. Requires reload before being applied.
commands.treeViewStatusBarVisibleSymbol "๐Ÿ’ " Symbol used in the tree view to indicate that command is also visible in the status bar.
commands.treeViewWorkspaceCommandSymbol "๐ŸŽฏ" Symbol used in the tree view to indicate workspace command (from #commands.workspaceCommands#) setting.
commands.statusBarDefaultText "same" Controls the text of Status Bar item when adding from Tree View context menu.
commands.statusBarDefaultPosition "left" Where to put command on Status Bar (left or right).
commands.quickPickIncludeAllCommands false When checked - include all commands from Command Palette to the Quick Pick.
commands.populateCommandPalette false Adds all items to Command Palette (Requires editor reload after every change of main config #commands.commands#).
commands.documentLinksEnabled false Run commands as links in documents. Links have format @command?args@.
issues/2
commands.documentLinksPattern "" Glob for #commands.documentLinksEnabled#. Example: **/*.{ts,js} - only enable in TypeScript & JavaScript files.
commands.variableSubstitutionEnabled true Allow "args" to replace variables: ๐Ÿ“š Docs.
commands.toggleSettings.showNotification false When enabled - show notification after using commands.toggleSetting or commands.incrementSetting.
// Command object structure
interface CommandObject {
    command: string;// command id to execute
    args?: unknown;// command arguments to execute
    delay?: number;// delay (ms) BEFORE execution
    repeat?: number;// run this command or sequence this number of times
    icon?: string;// icon id https://code.visualstudio.com/api/references/icons-in-labels#icon-listing
    iconColor?: string;// color id https://code.visualstudio.com/api/references/theme-color
    markdownTooltip?: string;// add custom markdown text to hover tooltip
    disableTooltip?: boolean;// do not show the hover tooltip for this Tree View Item
    hidden?: boolean;// Do not show this in Tree View
    inputs?: {...}[];// Objects for input variable substitution like https://code.visualstudio.com/docs/editor/variables-reference#_input-variables

    sequence?: (CommandObject | string)[];// execute multipe commands

    nestedItems: {// Transform this into folder: Group items
        [key: string]: CommandObject
    }

    // add command or folder to status bar
    statusBar?: {
        alignment: 'left' | 'right';// status bar alignment
        text: string;// status bar item text
        name?: string;// name of the item in status bar context menu
        priority?: number;// item position (can also be a negative number)
        tooltip?: string;// hover text
        markdownTooltip?: string;// hover text (in markdown)
        hidden?: boolean;// do not show this status bar item
        color?: string;// color of status bar item text
        backgroundColor?: 'error' | 'warning';// status bar item background color
        activeEditorGlob?: string// only show status bar item when active editor matches glob pattern
        activeEditorLanguage?: string;// only show status bar item when active editor language id matches
        updateEvents?: {// update status bar text (substitute variables)
            kind: 'onDidConfigurationChange' | 'onDidChangeActiveTextEditor' | 'onDidChangeTextEditorSelection' | 'interval';
        }[]
    };
}

type Type text into active editor

"Typing": {
    "command": "type",
    "args": {
        "text": "---",
    },
},

workbench.action.tasks.runTask Run task by its label

// tasks.json
{
    "label": "hello",
    "type": "shell",
    "command": "echo Hello",
},
// commands
"Run task": {
    "command": "workbench.action.tasks.runTask",
    "args": "hello",
},

editor.action.insertSnippet Insert Snippet

"Insert snippet": {
    "command": "editor.action.insertSnippet",
    "args": {
        "snippet": "$BLOCK_COMMENT_START ${0:?} $BLOCK_COMMENT_END",
    },
},

workbench.action.terminal.sendSequence Send text to active terminal

"Terminal: Run Watch": {
    "command": "workbench.action.terminal.sendSequence",
    "args": {
        "text": "npm run watch\r",
    },
},

workbench.action.quickOpen Quick access

Can open Quick Pick with prefilled prefix (@... - symbol, view ... - open view, ...)

"Quick open (symbol)": {
    "command": "workbench.action.quickOpen",
    "args": "?",
},

workbench.action.openSettings Open settings with prefilled input value

"Open Settings": {
    "command": "workbench.action.openSettings",
    "args": "commands",
},

workbench.action.openGlobalKeybindings Open keybindings with prefilled value

"Quick Keybindings Editor": {
    "command": "workbench.action.openGlobalKeybindings",
    "args": "commands.",
},

workbench.extensions.search Open Extensions View with prefilled value

"Quick Extensions View": {
    "command": "workbench.extensions.search",
    "args": "@builtin",
},

editor.action.codeAction Execute code action

"Organize imports": {
    "command": "editor.action.codeAction",
    "args": {
        "kind": "source.organizeImports",
    },
},

workbench.action.findInFiles Open search with specified args

"Search with args": {
    "command": "workbench.action.findInFiles",
    "args": {
        "query": "TODO",
        "isRegex": false,
        "isCaseSensitive": false,
        "matchWholeWord": false,
        "preserveCase": false,
        "excludeSettingAndIgnoreFiles": true,
        "triggerSearch": true,
        "onlyOpenEditors": false,
        // "replace": "",
        // "filesToInclude": "",
        // "filesToExclude": "",
    },
},

editor.actions.findWithArgs Open Editor Find Widget

"Find Widget with args": {
    "command": "editor.actions.findWithArgs",
    "args": {
        "searchString": "TODO",
        "replaceString": "",
        "isRegex": false,
        "isCaseSensitive": false,
        "matchWholeWord": false,
        "preserveCase": false,
        "findInSelection": false,
    },
},

search.action.openNewEditor Open Search Editor with specified args

"Open search editor with args": {
    "command": "search.action.openNewEditor",
    "args": {
        "query": "TODO",
        "isRegexp": false,
        "isCaseSensitive": false,
        "matchWholeWord": false,
        "preserveCase": false,
        "excludeSettingAndIgnoreFiles": true,
        "triggerSearch": true,
        "contextLines": 2,
        "showIncludesExcludes": true,
        // "filesToInclude": "",
        // "filesToExclude": "",
    },
},

cursorMove Move cursor to a logical position in the view

Arguments object:

  • to A mandatory logical position value providing where to move the cursor.

'left', 'right', 'up', 'down', 'prevBlankLine', 'nextBlankLine', 'wrappedLineStart', 'wrappedLineEnd', 'wrappedLineColumnCenter' 'wrappedLineFirstNonWhitespaceCharacter', 'wrappedLineLastNonWhitespaceCharacter' 'viewPortTop', 'viewPortCenter', 'viewPortBottom', 'viewPortIfOutside'

  • by Unit to move. Default is computed based on 'to' value.

'line', 'wrappedLine', 'character', 'halfLine'

  • value Number of units to move. Default is '1'.
  • select If 'true' makes the selection. Default is 'false'.
"Cursor move 10 down": {
    "command": "cursorMove",
    "args": {
        "to": "down",
        "by": "line",
        "value": 10,
    },
},

editorScroll Scroll editor in the given direction

Arguments object:

  • to A mandatory direction value (up or down).
  • by Unit to move. Default is computed based on 'to' value. (line, wrappedLine, page, halfPage).
  • value: Number of units to move. Default is 1.
  • revealCursor: If 'true' reveals the cursor when it is outside view port.
"Scroll 10 lines down": {
    "command": "editorScroll",
    "args": {
        "to": "down",
        "by": "line",
        "value": 10,
        "revealCursor": true,
    },
},

moveActiveEditor Move the active editor by tabs or groups

  • to String value providing where to move (left or right).
  • by String value providing the unit for move (by tab or by group).
  • value Number value providing how many positions or an absolute position to move.
"Move editor to the left": {
    "command": "moveActiveEditor",
    "args": {
        "to": "left",
        "by": "tab",
        "value": 50,
    },
},

vscode.setEditorLayout Sets the editor layout

Example for a 2x2 grid:

"2x2 grid": {
    "command": "vscode.setEditorLayout",
    "args": { "orientation": 0, "groups": [{ "groups": [{}, {}], "size": 0.5 }, { "groups": [{}, {}], "size": 0.5 }] },
},

editor.emmet.action.wrapWithAbbreviation Wrap text with emmet

"Wrap in div": {
    "command": "editor.emmet.action.wrapWithAbbreviation",
    "args": {
        "abbreviation": "div",
        "language": "html",
    },
},

workbench.action.openSettingsJson Opens settings.json file

"Reveal setting json": {
    "command": "workbench.action.openSettingsJson",
    "args": {
        "openToSide": true,
        "revealSetting": {
            "key": "editor.fontSize",
        },
    },
},

vscode.removeFromRecentlyOpened Removes an entry with the given path from the recently opened list

"Remove from recently opened": {
    "command": "vscode.removeFromRecentlyOpened",
    "args": "C:/temp/1.txt",
},

vscode.openIssueReporter Opens the issue reporter with the provided extension id as the selected source

  • extensionId - extensionId to report an issue on
"Issue: preselect extension": {
    "command": "vscode.openIssueReporter",
    "args": "usernamehw.commands",
},

workbench.extensions.installExtension Install extension by id

"Install extension": {
    "command": "workbench.extensions.installExtension",
    "args": "usernamehw.errorlens",
},

workbench.extensions.uninstallExtension Uninstall extension by id

"Uninstall extension": {
    "command": "workbench.extensions.uninstallExtension",
    "args": "usernamehw.errorlens",
},

workbench.extensions.action.showExtensionsWithIds Show extensions in Extensions View by id

"Show specific extensions": {
    "command": "workbench.extensions.action.showExtensionsWithIds",
    "args": [
        "usernamehw.commands",
        "usernamehw.errorlens",
    ],
},

Additional commands

commands.toggleSetting Toggle settings

"Toggle boolean setting (pass string args)": {
    "command": "commands.toggleSetting",
    "args": "editor.renderIndentGuides",
},
"Pass array of values to cycle through": {
    "command": "commands.toggleSetting",
    "args": {
        "setting": "workbench.colorTheme",
        "value": ["Monokai", "Kimbie Dark"],
    },
    "icon": "symbol-color",
},
"Toggle workspace setting": {
    "command": "commands.toggleSetting",
    "args": {
        "setting": "workbench.editor.showTabs",
        "target": "workspace",
    },
},
"Set/reset setting": {
    "command": "commands.toggleSetting",
    "args": {
        "setting": "window.zoomLevel",
        "value": [0],
    },
},

commands.incrementSetting Increment/decrement setting

"Font size ++": {
    "command": "commands.incrementSetting",
    "args": {
        "setting": "editor.fontSize",
        "value": 0.5,
        // "target": "workspace",
    },
},
"Font size --": {
    "command": "commands.incrementSetting",
    "args": {
        "setting": "editor.fontSize",
        "value": -0.5,
    },
},

commands.toggleTheme Toggle themes by groups (depending on active theme kind)

"Toggle Themes": {
    "command": "commands.toggleTheme",
    "args": {
        "dark": "Default Dark+,GitHub Dark",
        "light": "Default Light+,GitHub Light",
    },
},

commands.openFolder Open file/folder in vscode

"Open file": {
    "command": "commands.openFolder",
    "args": "C:\\temp\\temp.txt",// Accepts array ["C:/temp/1.txt","C:/temp/2.txt"]
},
"Open relative file": {
    "command": "commands.openFolder",
    "args": "./package.json",// open relative to the first opened workspace folder
},
"Open folder": {
    "command": "commands.openFolder",
    "args": "C:\\temp",
},

commands.focusTerminal Focus specific terminal

"Focus newest non-task terminal": {
    "command": "commands.focusTerminal",
},
"Focus terminal named 'foobar' (string argument)": {
    "command": "commands.focusTerminal",
    "args": "foobar",
},
"Focus terminal named 'foobar'": {
    "command": "commands.focusTerminal",
    "args": {
        "target": "newest",// focus newest matching terminal; create new if no match
        "name": "foobar",// if no match, assign a name to the new terminal
    },
},

commands.runInTerminal Send text to new (or specified) terminal

"Terminal => watch (string argument)": {
    "command": "commands.runInTerminal",
    "args": "npm run watch",
},
"Terminal => watch": {
    "command": "commands.runInTerminal",
    "args": {
        "text": "npm run watch",
        "name": "watch",
        "reveal": true,
        "waitForExit": false,// will wait for terminal to exit before running next command
        "reuse": "newest",// reuse newest same-named terminal; create new if no match
    },
},

commands.startDebugging Start debugging by "name" property from launch.json

"Debug extension": {
    "command": "commands.startDebugging",
    "args": "Extension",
},

commands.setEditorLanguage Change active editor language id

"Set Language JavaScript": {
    "command": "commands.setEditorLanguage",
    "args": "javascript",
},

commands.clipboardWrite Write text to clipboard

"Populate clipboard": {
    "command": "commands.clipboardWrite",
    "args": "||||||||",
},

commands.showNotification Show VSCode notification

"Msg": {
    "command": "commands.showNotification",
    "args": "info msg",
},
"Msg error": {
    "command": "commands.showNotification",
    "args": {
        "severity": "error",// "warning" | "info"
        "message": "bad",
    },
},

commands.showStatusBarNotification Show notification in Status Bar

"Notification in status bar": {
    "command": "commands.showStatusBarNotification",
    "args": {
        "message": "Read me fast",
        "color": "#f00",
        "timeout": 5000,
    },
},

commands.openExternal Open link in default browser

"Open google.com": {
    "command": "commands.openExternal",
    "args": "https://www.google.com",// Accepts array ["https://www.google.com","https://github.com/"]
},
"Open Extension Preview": {
    "command": "commands.openExternal",
    "args": "vscode:extension/usernamehw.commands",
},

commands.open Open file in default app (Uses open)

"Open in default app": {
    "command": "commands.open",
    "args": "C:\\temp\\img.png",
},
"Open in specified app": {
    "command": "commands.open",
    "args": {
        "target": "C:\\temp\\img.png",
        "app": "firefox",// Or absolute path
        "arguments": ["-devtools"],
    },
},

commands.revealFileInOS Open system file explorer at the specified path

"commands.revealFileInOS": {
    "command": "commands.revealFileInOS",
    "args": "C:/Users",
},

Running sequence without adding it to settings.json

If the only purpose for a command sequence is to run it from a keybinding, then it might be easier to just run it from a keybindings.json file directly:

{
    "key": "ctrl+shift+9",
    "command": "commands.run",
    "args": [
        "editor.action.toggleMinimap",
        "workbench.action.toggleSidebarVisibility",
    ],
},

Using your own color for tree view icon

"workbench.colorCustomizations": {
    "mycolor": "#ffc01f",
},
"commands.commands": {
    "Command": {
        "icon": "dashboard",
        "iconColor": "mycolor",
    },
},

Upstream issues

Please upvote the following VS Code issues:

vscode-commands's People

Contributors

0biwankenobi avatar elazarcoh avatar frypf avatar gitmensch avatar gorvgoyl avatar usernamehw avatar zardoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-commands's Issues

FR command in editor menu bar

With commands in Tree View / Status Bar / Quick Pick this extension has all places covered but the editor menu bar.
Please add this, allowing all command configuration be done with this extension.

There's a "kind of hard-wired" extension that does this single thing quite well so the general idea can be seen there https://open-vsx.org/extension/jerrygoyal/shortcut-menu-bar (the code can't be copied because it is GPL, but the public vscode API would be accessed the same way).

The configuration here would be similar to the Status Bar implementation (own sub-configuration and a "Toggle Editor Menu Bar" context menu entry to add/remove it).

FR doc: add markdownTooltip / disableToolTip example

This is kind of a follow-up to #40 where it was implemented and API-documented in the README.
As the README has nice examples for (all?) other attributes: please add a doc entry, maybe the following would be a starting point

## Tooltips

```js
"GitHub": {
    "icon": "github",
    "markdownTooltip": "## Description:\n\n- one\n- two",
},
"GitLab": {
    "icon": "gitlab",
    "disableToolTip": true,
},

commands.startDebugging does not look for launch configurations declared in code-workspace files

Hello,
I think the title is self-explanatory.
Most of my development environment is located in a file called "myproject.code-workspace".
I have declared a launch configuration called "Launch Debug" into that file.
Then I use the following code to add a command for starting that launch configuration:
"Launch Debug": { "icon": "run-view-icon", "command": "commands.startDebugging", "args": "Launch Debug", "statusBar": { "text": "Launch" } }

When I click the command's button I have the following error:
Configuration 'Launch Debug' is missing in "launch.json"

My guess is that the extension looks only for launch configurations located in the launch.json file. It should also look for launch configurations located in the current active code-workspace file.

Let me know if you need more pieces of information regarding this bug.
Anyway, thank you for this great extension !

When expressions & workspace specific commands

Hi @usernamehw,
I had the same idea for extension some time ago.
I've started toying with it. In my initial implementation (which I never published), I had some feature that I want to contribute here, if you would accept it:

  1. Support when expression for the command-palette. This gives more flexibility of when to show command in the command palette, for example.
  2. Support workspace specific commands. Those commands would be available only in the workspace they where written in.
  3. Implement new commands in a js file, and dynamically run it. This can be very convenient for creating a new command without having to create a new extension.
    (This feature I have only in a POC state, so I won't expect to make a PR for it just yet)

Let me know what you think. would you accept PR for any of those?
We can discuss detail further, if you'd like.

Feature request: filter by editor's language

Please add ability to filter by active editor's language for status bar items, rather than just activeEditorGlob, to define actions specific to a language.

It's currently possible to do a workaround by filtering on extension using activeEditorGlob but it's a rather inconvenient hack to achieve this functionality.

Can you please lower vscode dependency?

@usernamehw It seems that the vscode engine version in pacakge.json was only increased as part of a dependency update - but this means that the current version only works with the noted minimal version.

To support "legacy" environments it would be nice to support older versions, an you please drop that to 1.55? If it still builds fine afterwards then it should also run fine (the current last working version with that dependency was 0.0.6).

... and with the current bugfixes this could even get in the soon upcoming version :-)

argument as popup input box

it will be very helpful if I can input some custom text as part of the command code.
for example,
echo ${agrument}
it will pop up an input box to take the argument value.

Show user-facing error notification when running command fails

I tried to setup the following sequence as per the example:

"DefaultTabsInGroups": {
            "sequence": [
                {
                    "command": "workbench.action. focusFirstEditorGroup",
                },
                {
                    "command": "commands.openFolder",
                    "args": "O:\\main.md",
                },
            ],
        },

But when I run it, it does not execute anything.

The "simple" syntax without declaring the command object in your example does work though, though there is no way to enter arguments that way (and be able to open the file as in the 2nd step in my sequence above).

Is my formatting incorrect? Is comma-separation not required inside and outside the bracket? The example's image and text syntax did not match and had different syntaxes so it was confusing.

Conflicts with the more popular Commands extension

This extension conflicts with Commands by Fabio Spampinato.

I was using Fabio's Commands with your Change Language Mode
but that was deprecated for your new Commands extension. The issue is when I install your Commands extension to use the setEditorLanguage function, it breaks my Fabio Commands extension.

Specifically the commands.commands in the settings.json is already used by Fabio's Commands extension.

Extension conflicts with another extension by the same name

For a long time, I have used this extension to customize my statusbar:
https://github.com/fabiospampinato/vscode-commands

The problem is your extension uses the exact same name, "vscode-commands", and the exact same identifier in the vs-code settings.json file, "commands.commands". I want to use both extensions so I can add commands to my sidebar and to the statusbar. Can you please rename so the two do not conflict with one another in settings.json. I am asking you because the other extension has more downloads and is several years older.

Alternatively, maybe you and the other developer can merge your extensions into one. That would be super cool and make your efforts and the other developers extension a lot more popular. It would probably be the most powerful extension for modifying vs-code UI in the whole marketplace.

Simplify args for built-in commands

For example, to send sequence to terminal vscode command requires you to write:

"command": "workbench.action.terminal.sendSequence",
"args": {
	"text": "npm run watch",
},

"text" is a primary argument. Allow to write inside "commands.commands" like that:

"command": "workbench.action.terminal.sendSequence",
"args": "npm run watch",

Add suggestions for setting ids

There are commands for suggesting commands and codicons, but not setting ids. Also would be useful to have them in arg completions for toggleSetting command. I think it's possible since we can access settings schema.

Thanks so so much

This library really solves a problem for my team, and it's gotten so much better, so quickly. Just wanted to acknowledge all of your team's hard work and that we're making it a pillar of our VSCode stack going forward.

`commands.diff`: request for new `kind`: `file`

The "kind": "file" would feature two options: from and to (or diffFrom and diffTo).

both could contain:

  • enum value previousEditor (or previous) selects the one that was previously opened
  • enum value currentEditor (or current) selects the one that is currently opened
  • a string, which would point to a filename (whih woul feature variable substitution, so can be explicit specified an/or selected via input vaiables)

the two options allow to specify which is on the left and which o the right side

As commands.diff was not published yet it would also be possible to drop the kind and provide enum values to select what it currently does as from / to.

Write documentation page

  • Create documentation page
  • Documentation page should have headers & TOC
  • Settings should reference it as links from "markdownDescription" property

Implement when clause for Quick Pick

I'm uncertain if the Extension API supports this, so I'm creating this to track eventual blocking issues if not.

I really like the idea of using the when clause for commands. Personally however I don't see much benefit of enabling it for the Command Palette, it would be awesome if it could be implemented for the Quick Pick though.

The use case is that I would like to make the Quick Pick completely context based. Imagine opening the Quick Pick and only see your choice of commands, and only see commands relative to the context from which it was opened, what a wonderful world.

I was researching for achieving this with the RMB Context Menu, but there are too many issues blocking this atm.

Related PR #22
Ping @elazarcoh

Removes commands completion in keybindings.json

Bug STR:
Vscode adds commands completion via JSON definition. It would be good to not remove keybindings.json completions in the following location (|):

[
  {
    "command": "|",
    "when": "isWindows",
    "key": "ctrl+p"
  }
]

Command: > Preferences: Open Keyboard Shortcuts (JSON)

Command 'changeLanguageMode.change' not found

hello,

Using the new commands add-in, I get this error when trying to switch languages via this:
{ "key": "ctrl+alt+d", "command": "changeLanguageMode.change", "args": "django-html" },

However, installing the 'deprecated' change language mode add-in, it works again. Is 'commands' meant to have this functionality since its the replacement?

Items with same statusBar "text" are not displayed

I currently have 20 commands.commands items in my status bar and I need to have separators to break up the different sections.

If I use the following for blank/separator spaces in my statusbar, blank2 is not visible since the "text" is the same as blank1:

       . . .
        "blank1": {
            "statusBar": {
                "text": " ",
                "priority": 99999
            }
        },
       . . .
        "blank2": {
            "statusBar": {
                "text": " ",
                "priority": 99999
            }
        },
       . . .

The blank2 is not visible unless the "text" is unique. So if I make it 2 spaces, then it is visible but takes up 2x more space than it needs. Then blank3, blank4, etc.. needs 3 and 4 blank spaces respectively.

Advanced alias

  1. allow args in alias
"commands.alias": {
	"watch": {
		"command": "commands.runInTerminal",
		"args": "npm run watch",
	},
},
  1. allow sequence in alias
"commands.alias": {
	"toggle": [
		"editor.action.toggleMinimap",
		"workbench.action.toggleStatusbarVisibility"
	]
},

Downside: setting won't render in Settings UI (Edit in settings.json button).

Glob issue

Glob doesn't seem to parse the "one of" matchers correctly. For example string **/*.@(scala|sbt) (and same with *, !, +) is supposed to match files

/foo/bar/test.scala
/foo/bar/test.sbt

(https://www.digitalocean.com/community/tools/glob?comments=true&glob=%2A%2A%2F%2A.%40%28scala%7Csbt%29&matches=false&tests=%2Ffoo%2Fbar%2Ftest.scala&tests=%2Ffoo%2Fbar%2Ftest.sbt)

However it does not. Using pattern without the "one of" group like **/*.scala works fine.

Commands: V.1.4.0
VSCode:

Version: 1.71.2
Commit: 74b1f979648cc44d385a2286793c226e611f59e7
Date: 2022-09-14T21:12:14.256Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 5.19.9-arch1-1
Sandboxed: No

FR variable substition: configuration variables

The one I miss the most in the list above are the configuration variables ${config:CONFIG_VAR}. Can you add that, please?

Note: as it is possible to self-define configurations (the settings ui creates a warning "unknown configuration", but otherwise it works perfect) this can be easily used to move often used strings to a single place and use it in the complete workspace configuration.

Things I've used for this so far, leading to multiple "nearly identical" workspace definitions that move out the parts that are specific to the actual user and that are specific to that project, are similar to:

"my.config.server": "servername",
"my.config.serverFallback": "servername2",
"my.config.port": "12345",
"my.config.projectName": "project",
"my.config.projectDesc": "stuff this project is about",
"my.configUser.folder": "/path/to/folder/outside/workspace"  // setup in user config

this allows using it in different places, especially useful for launch and task configurations where they can be referenced, for example with ${config:my.configUser.folder}/${config:my.config.projectName}.

I'd like to use those in the args, too, and see those are missing in the docs and in https://github.com/usernamehw/vscode-commands/blob/master/src/substituteVariables.ts. I guess that's a nearly copy+paste of 84d6223 using https://code.visualstudio.com/api/references/vscode-api#workspace.getConfiguration instead of process.env.

Originally posted by @GitMensch in #9 (comment)

Cycle commands

Add a way to cycle through multiple commands. Example would be:

  • editor.foldAll
  • editor.unfoldAll

If the last executed command was foldAll => run unfoldAll
If the last executed command was unfoldAll => run foldAll

Different icon for setting values in statusbar

Hi! Currently we have toggleSetting command and a way to add a command to statusbar, but I don't see a way to add visual representation of the current setting value in statusbar. For example let's say I have to toggle a boolean setting. I want to have check prefix icon when value of the setting is true and close otherwise (or vice versa if the setting is mean to disable something)

Run defined command from arg (for use in keybinding)

Hi! AFAIU all commands to run must be defined in commands.commands, however I want to define them (for example a sequence) in keybindings.json.

For example:

{
    "key": "cmd+r",
    "command": "commands.executeSequence",
    "args": [
        {
            "sequence": ["editor.action.toggleMinimap", "workbench.action.toggleStatusbarVisibility"]
        }
    ]
},

Motivation: easier to use in shared keybindings

add tags for versions

Which are automatically shown as releases on GitHub (and provide the option later to run a CI action like uploading to the marketplaces someday).

Variable substitution

Make it possible to use inside "args" https://code.visualstudio.com/docs/editor/variables-reference

  • ${userHome}
  • ${file}
  • ${fileBasename}
  • ${fileBasenameNoExtension}
  • ${fileExtname}
  • ${fileDirname}
  • ${fileWorkspaceFolder}
  • ${workspaceFolder}
  • ${workspaceFolderBasename}
  • ${execPath}
  • ${pathSeparator}
  • ${lineNumber}
  • ${selectedText}
  • ${currentYear}
  • ${currentYearShort}
  • ${currentMonth}
  • ${currentMonthName}
  • ${currentMonthNameShort}
  • ${currentDate}
  • ${currentDayName}
  • ${currentDayNameShort}
  • ${currentHour}
  • ${currentMinute}
  • ${currentSecond}
  • ${currentSecondsUnix}
  • ${currentTimezoneOffset}
  • ${config:VSCODE_SETTING_ID}
  • ${input:Name}
  • ${command:Name}
  • ${env:ENV_VAR}
"commands.variableSubstitutionEnabled": true,
"Input file name from selection": {
	"command": "workbench.action.quickOpen",
	"args": "${selectedText}",
},
  • Predefined variables ${file},${fileBasename},...
  • Environment variables ${env:MY_SYSTEM_VAR}
  • Configuration variables ${config:CONFIG_VAR}
  • Command variables ${command:vscodeCommandId}
  • Substitute inside arrays/objects
  • Input variables
  • Quick Pick list variables
  • Other
    • ${clipboard} current clipboard value
    • ${random} 6 random Base-10 digits
    • ${randomHex} 6 random Base-16 digits
    • ${selectedLineCount} Number of selected lines in active file
    • ${currentYear}
    • ${currentYearShort}
    • ${currentMonth}
    • ${currentMonthName}
    • ${currentMonthNameShort}
    • ${currentDate}
    • ${currentDayName}
    • ${currentDayNameShort}
    • ${currentHour}
    • ${currentMinute}
    • ${currentSecond}
    • ${currentSecondsUnix}
    • ${currentTimezoneOffset}

nested commands with the same name

Hi,

I have a nested items with the structure as show on the screenshot.
Would it be possible to prefix command name with the folder name before registering command in vscode?

If I use the same name, I get error Failed to register command: command 'caddy' already exists

image

thanks!

Missing name in the status bar context menu

I just discovered this extension and I like it. One thing that I cannot find is how to get displayed the name of the command in the context menu of status bar. The statusbar_commands extension that I am using right now has that option.

Here is what I am trying:

    "commands.commands": {
        "Save Without Formatting": {
            //"command": "workbench.action.files.saveWithoutFormatting",
            "statusBar": {
                "alignment": "left",
                "text": "$(save)",
                "tooltip": "Save Without Formatting (Ctrl+K Ctrl+Shift+S)",
                "priority": -9999,
                "color": "#00ffff",
            },
            "sequence": [
                "workbench.action.files.saveWithoutFormatting",
                "workbench.action.focusActiveEditorGroup"
            ]
        }
    },

When I right click on the status bar I see the item for that command in it, but with the empty name. It would be nice if your extension has additional settings for that (it is called "name" in the mentioned other extension), or you could just use the same text that is specified for that command. I tried adding:
"commands.statusBarDefaultText": "same",
but I don't see that anything changed.

By the way, your extension also has the problem with the focus that I reported recently, which is why I have added "workbench.action.focusActiveEditorGroup" to the "sequence".

"Unable to write to Workspace Settings because my.workspaceColor is not a registered configuration." / ability to access nested settings

I was experimenting with the ideas discussed in #25, ie. using custom config settings to pass as variables to other commands (eg. ${config:my.workspaceColor}). I've realised that while this works if I've added it to the json manually, it's impossible at the moment to add or update it via the extension - eg. the following sequence fails with the above notification:

{
  "sequence": [
    {
      "command": "commands.toggleSetting",
      "args": {
        "setting": "my.workspaceColor",
        "target": "workspace",
        "value": [ "#00f00f33" ]
      }
    },
    {
      "command": "commands.toggleSetting",
      "args": {
        "setting": "workbench.colorCustomizations",
        "target": "workspace",
        "value": [ {
            "statusBar.background": "${config:my.workspaceColor}",
            "titleBar.activeBackground": "${config:my.workspaceColor}",
            "tab.activeBackground": "${config:my.workspaceColor}",
            "sideBar.background": "${config:my.workspaceColor}"
          } ]
      }
    }
  ]
}

Is there any way to force an unknown configuration into settings? The second part of that sequence works as intended on its own, correctly reading the value of a manually-set my.workspaceColor into the specified settings. I also noticed the extension doesn't complain if I add my unknown config into a nested object. Thus, as an alternative I attempted:

{
  "sequence": [
    {
      "command": "commands.toggleSetting",
      "setting": "workbench.colorCustomizations",
      "target": "workspace",
      "value": [ { "my.workspaceColor": "#00f00f33" } ]
    },
    {
      "command": "commands.toggleSetting",
      "args": {
        "setting": "workbench.colorCustomizations",
        "target": "workspace",
        "value": [ {
            "statusBar.background": "${config:workbench.colorCustomizations['my.workspaceColor']}",
            "titleBar.activeBackground": "${config:workbench.colorCustomizations['my.workspaceColor']}",
            "tab.activeBackground": "${config:workbench.colorCustomizations['my.workspaceColor']}",
            "sideBar.background": "${config:workbench.colorCustomizations['my.workspaceColor']}"
          } ]
      }
    }
  ]
},

However I then realised it's not possible to grab a nested value from a ${config:...} variable (I'd also initially tried ${config:workbench.colorCustomizations.my.workspaceColor}). Is there any syntax available to access such nested settings?

PS: I was originally investigating all this as a workaround for using shell command substitutions as variables. If there was any way to read a command substitution directly into a variable - or even just access the current clipboard OR content from a specified tempfile OR environment variables from an open terminal, I could greatly simplify this or similar sequences by initially using a runInTerminal command to set clipboard via pbcopy / write said tempfile / export said env var. Albeit I don't know enough about TS and the available VSCode APIs to get a feel for how feasible or difficult any of that may prove to implement.

Possible to add a repeat option for a command?

Would it be possible to implement repeating a single command without specifying it as a sequence and typing the same thing multiple times? Eg: at the moment I have this (because there's no VSCode API command to do the same ๐Ÿ™„):

"cmd.sidebar.minimumWidth": {
  "sequence": [
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    "workbench.action.increaseViewWidth",
    (etc...)
  ]
}

but it would be so much more convenient to specify it as something along the lines of:

"cmd.sidebar.minimumWidth": {
  "command": "workbench.action.increaseViewWidth",
  "repeats": 15
}

Many thanks for your efforts on this extension - it's proving very useful!

command configuration cannot be stored in workspace files

Version 0.0.6 - commands defined in .code-workspace (because they depend on the workspace) work fine
Version 1.5.0 (presumably also some versions before): the configured commands are ignored, checking the problem pane in the workspace configuration shows that commands.commands now have an application scope and can only be set in the user configuration.

@usernamehw: is there any option to roll that back? Maybe it would be possible to say "it can be workspace configured but those settings are only read if there's enabled workspace trust".

Command sequence

Hi

Very good extension, and good work !

I'm using a sequence command, but in case of "failure" of a command , the sequence continues to run.

It could be nice if we could add a parameter for each command to indicate if we would like to continue the sequence or not.
"continueSequenceOnError" : boolean.

In my case, my first command is a cmake.build; which is not failing in case of build error. Then the second command is a deployment ; and it would be great if the deployment not being done in case of build error.

        "Build and deploy @ 0.11": {
            "sequence": [
                {
                    "command": "cmake.build",
                },
                {
                    "command": "commands.runInTerminal",
                    "args": {
                        "text": "bash scripts/publish.sh -i=192.168.0.11",
                        "reveal": true,
                        "reuse": "newest",
                        "waitForExit": true
                    }        
                }
            ],
            "icon": "cloud-upload",
            "iconColor": "charts.orange",
            "statusBar": { "text": "All->0.11", "backgroundColor": "warning", "color": "#FF0000" }
        },   

Thanks

an option, per item, to disable tooltips

Love this extension so much, i want to take it home AND buy it breakfast the next day!!!

can forgive it almost anything, but must admit this is irritating...would love to turn it off (for some commands, not all):

image

run specific task not working?

task.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "ech o",
            "type": "shell",
            "command": "echo Hello you"
        },
        {
            "label": "clearme",
            "type": "shell",
            "command": "cls"
        }
    ]
}

settings.json:

    "commands.commands": {
        "โ–ถ๏ธ Run Task": {
            "command": "workbench.action.tasks.runTask",
            "args": "ech\\ o"
        },
    },

I think this worked that way with run-commands-view before and I know we did document it in its repo (sadly it cannot be found, please make it public again btw), but with this extension and vscode 1.59.1 I always get the prompt which task to execute.

Toggle setting with arrays as values does not work

I want to toggle a VSC extension that hast the following format:
"author.extension": [ "val1", "val2"],

With commands extension it does not seem to be possible to toggle this setting like follows:

[ "val1", "val2"] -> [ "val3", "val4"]

Would it be possible to get this to work somehow?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.