gh-copilot icon indicating copy to clipboard operation
gh-copilot copied to clipboard

[FEAT]: Parameters to define the aliases

Open she11sh0cked opened this issue 1 year ago • 4 comments

I like to use ?? and ?! as aliases for ghcs and ghce. At the moment I'm able to do this by first calling the alias eval and then assigning my own aliases:

eval "$(gh copilot alias -- zsh)"

alias -- '?!'=ghce
alias -- '??'=ghcs

It would however be much nicer to directly define the aliases. Something like this maybe?

eval "$(gh copilot alias --suggest='??' --explain='?!' -- zsh)"

she11sh0cked avatar Nov 15 '24 10:11 she11sh0cked

Thank you for your support and your feedback, @she11sh0cked! ❤

If these flags for defining aliases existed:

  1. Would you expect the existing functions preserved and simply add alias statements to the output?

    $ gh copilot alias --suggest='??' --explain='?!' -- zsh
    
    ghcs() {
    	...
    }
    
    ghce() {
    	...
    }
    
    alias -- '?!'=ghce
    alias -- '??'=ghcs
    
  2. Are there any inputs that would be invalid or dangerous to allow being used?

andyfeller avatar Nov 15 '24 13:11 andyfeller

  1. Would you expect the existing functions preserved and simply add alias statements to the output?

Yeah I think that's good. I'd suggest prepending the function with underscores though:

$ gh copilot alias --suggest='??' --explain='?!' -- zsh

_ghcs() {
	...
}

_ghce() {
	...
}

alias -- '?!'=_ghce
alias -- '??'=_ghcs
  1. Are there any inputs that would be invalid or dangerous to allow being used?

I'm not sure, but if the user provides invalid arguments they will see as soon as the eval runs, right? And sure you can do stupid stuff like alias -- 'bash', but that's definitely user fault.

she11sh0cked avatar Nov 18 '24 16:11 she11sh0cked

Good call out about namespacing the functions. 🤔 I also agree that anything the user plugs in would be their fault if it doesn't work as expected; you should know the limitations of your shell when customizing it.

andyfeller avatar Dec 02 '24 20:12 andyfeller

Is it possible now to define custom aliases directly instead of separately creating them?

itpropro avatar Sep 04 '25 12:09 itpropro