Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom command and custom command #3799

Open
yam-liu opened this issue Aug 6, 2024 · 6 comments
Open

Custom command and custom command #3799

yam-liu opened this issue Aug 6, 2024 · 6 comments

Comments

@yam-liu
Copy link
Contributor

yam-liu commented Aug 6, 2024

Topic

  1. Rename the 'Custom command' thing associated with : to Execute Shell Command or Shell command.
  2. Bring Custom command placeholders like `{{ .SelectedPath }} to Shell command.

Your thoughts

  1. We have two features named Custom command. It's hard to refer clearly to which one when we use the 'custom command' keyword. Like this context.
    I propose to use:

    • Custom command: for custom command defined in config.yml.
    • Shell command: execute the shell command that user inputs.
  2. Another thought, we cannot use placeholders in Shell command. But it is convenient to provide this feature.

    • Use case 1:
      To execute a git command over the current selected file, what I want is:

      git --update-index --skip-worktree {{ .SelectedPath }}
      

      The file is modified and selected in Files tab, I hope I can pass the selected file path to execute arbitrary commands.

    • Use case 2:
      To change file attribute, add execute permission. Example command:

      chmod +x {{ .SelectedPath }}
      
@stefanhaller
Copy link
Collaborator

I very much like the first suggestion; the double use of the term "Custom Command" has often bothered me. Here's a PR: #3800.

I'm not so sure about the value of the second suggestion, but I wouldn't be opposed; seems like it shouldn't be too hard to implement it.

@stefanhaller
Copy link
Collaborator

The first issue is fixed by #3800.

For the second, I have the feeling that what you really want is something else. The : command prompt is for typing ad-hoc commands, and you wouldn't want to type something like {{ .SelectedPath }} at that prompt, this is too cumbersome. It would be faster to select the file, hit y p to copy its path, and then type : chmod +x <Command-V>.

So it seems that you want to "abuse" the : command prompt for something more permanent; you want to use the : history for preconfiguring a command for later re-use. Normally you could just configure a custom command for these, but probably you don't want to sacrifice a keybinding for them, or you may have a hard time remembering the keybindings for those commands that you don't use daily.

I feel it might be worth adding a configuration that allows configuring a key binding for a list of custom commands instead of just one. Pressing the key would bring up a menu that lists all the configured commands for that key, with filtering, very similar to the : dialog.

This would be very similar to what you are suggesting, but it would clearly separate those pre-configured commands from the commands that you really type ad-hoc.

But it may well be easier to do what you suggested; just wanted to bring up this thought for discussion.

@a-jentleman
Copy link
Sponsor

FWIW - I think the ability to search for custom commands by name without needing to bind them to a key would be a great enhancement.

I think it would be nice if there was a single command search functionality that suggested results from various sources (built-in, custom command, unbound custom command, recent ad-hoc, etc). But, I'd take the functionality however it comes. If this is something that could be a good fit for a PR from the community, I could take a stab at it

@mark2185
Copy link
Collaborator

FWIW - I think the ability to search for custom commands by name without needing to bind them to a key would be a great enhancement.

@a-jentleman that's already possible, you can search in the help (?) menu with /.

image

@a-jentleman
Copy link
Sponsor

@a-jentleman that's already possible, you can search in the help (?) menu with /.

Oh, sweet. Wish I tried this earlier.

Is this a known & supported setup? If so, perhaps my contribution would be small doc changes to Custom_Command_Keybindings.md and/or Custom-Commands-Compendium to demonstrate it

@mark2185
Copy link
Collaborator

If so, perhaps my contribution would be small doc changes to Custom_Command_Keybindings.md and/or Custom-Commands-Compendium to demonstrate it

Huh, it looks like the docs state key as required which it obviously isn't, so I guess that needs changing, yeah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants