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

Check gh command exists before setting git gh alias #1499

Merged
merged 2 commits into from
Apr 27, 2020

Conversation

jmthvt
Copy link
Contributor

@jmthvt jmthvt commented Feb 20, 2020

Fixes #1498

gh was for git home so I am renaming it ghm

@jmthvt jmthvt force-pushed the feature/unalias-gh branch from f48b4f4 to 03905fd Compare February 20, 2020 07:46
@jmthvt jmthvt changed the title Free gh git alias and replaxce with ghome Free gh git alias and replace with ghome Feb 20, 2020
@nwinkler
Copy link
Member

As discussed in #1498, can you please add a check for the gh command and then, if gh is not installed, set the gh alias to the same command as ghome (or make gh an alias for ghome).

Bash-it provides the _command_exists function to check for the presence of a command, you can find many examples in the codebase for its usage...

@jmthvt jmthvt closed this Apr 9, 2020
@jmthvt jmthvt force-pushed the feature/unalias-gh branch from 03905fd to 9ef0b33 Compare April 9, 2020 02:57
@jmthvt jmthvt reopened this Apr 9, 2020
@jmthvt jmthvt changed the title Free gh git alias and replace with ghome Check gh command exists before setting git gh alias Apr 9, 2020
@jmthvt
Copy link
Contributor Author

jmthvt commented Apr 9, 2020

Updated - sorry for the delay.
@nwinkler PTAL

Copy link
Member

@nwinkler nwinkler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - left some feedback in a comment, please take a look.

# Git home
alias ghm='cd "$(git rev-parse --show-toplevel)"'
if ! _command_exists gh; then
alias gh='cd "$(git rev-parse --show-toplevel)"'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify this by doing this - avoids repetition:

alias gh='ghm'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@nwinkler
Copy link
Member

Thanks!

@nwinkler nwinkler merged commit a31f4f0 into Bash-it:master Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"gh" git alias clashes with github-cli
2 participants