GithubHelp home page GithubHelp logo

usernamehw / vscode-commands Goto Github PK

View Code? Open in Web Editor NEW
60.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 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  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-commands's Issues

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.

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

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.

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 !

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!

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.

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)

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

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.

Write documentation page

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

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)

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.

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

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?

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).

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".

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.

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 :-)

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?

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

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",

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}

"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.

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

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).

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.

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.

`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.

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

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,
},

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.

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.

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!

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)

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).

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".

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.