Skip to content

shell version of gh alias set #941

Description

@vilmibm

This issue covers augmenting gh alias to support shell-based invocation.

What's a shell alias? It's like doing this in git:

git config --global alias.beanlog '!sh -c "git log | grep beans"'

and for us would look like

gh alias set beanissue '!sh -c "gh issue list | grep beans"'

Seeing the ! prefix on an alias would bypass any checking for correct commands, leaving that in the
hands of the user. Otherwise these should be printable and shareable and deletable just like the
other style of alias.

Considerations

  • Should have an affordance (either just a documented pattern or editor mode) for multiline alias
    expansions
  • Should generally mirror git's alias implementation

Activity

  1. mislav commented on May 18, 2020

    @mislav
    Contributor

    What's a shell alias? It's like doing this in git:

    git alias beanlog "!sh -c 'git log | grep beans'"
    

    Just a small correction: I don't think there is a git alias command, at least there never was one for me 🤔 So wouldn't the git example be something like:

    git config --global alias.beanlog "!sh -c 'git log | grep beans'"

    Furthermore, I would just like to warn that enclosing a ! character in double quotes in bash is usually going to explode:

    $ echo "!"
    -bash: !: event not found

    This is because ! is a special character that triggers history expansion in bash. It can be escaped with a backslash, but in that case the backslash isn't stripped (for some reason):

    $ echo "\!"
    \!

    I would recommend that we always enclose strings that contain a ! in single quotes rather than double quotes when showing usage examples, to ensure maximum portability:

    gh alias set beanissue '!sh -c "gh issue list | grep beans"'
  2. vilmibm commented on May 19, 2020

    @vilmibm
    ContributorAuthor

    ah thanks for pointing that out; my brain was inventing syntax ^_^

  3. self-assigned this
    on Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions