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

[FEAT]: Parameters to define the aliases #103

Open
she11sh0cked opened this issue Nov 15, 2024 · 3 comments
Open

[FEAT]: Parameters to define the aliases #103

she11sh0cked opened this issue Nov 15, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@she11sh0cked
Copy link

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 she11sh0cked added enhancement New feature or request needs-triage needs to be reviewed labels Nov 15, 2024
@andyfeller
Copy link
Contributor

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?

@she11sh0cked
Copy link
Author

  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.

@andyfeller
Copy link
Contributor

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 andyfeller removed the needs-triage needs to be reviewed label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants