Bash-it / bash-it

A community Bash framework.
MIT License
14.14k stars 2.29k forks source link

Align Git short aliases with Oh My Zsh #1191

Open bittner opened 6 years ago

bittner commented 6 years ago

I've noticed that the short Git aliases in Bash-it do not match the ones defined by the Oh My Zsh project.

Wouldn't it be a good idea to match them? This would make it easier for users to switch between Bash and Zsh.

bittner commented 6 years ago

Any hard feelings about this? Should I try to prepare a PR for git.aliases.bash?

nwinkler commented 6 years ago

Before you embark on this, could you outline the main differences? To be honest, I think backwards-compatibility (and people's muscle memory) is more important than using the same aliases as Oh My Zsh.

If you really want to use the same (and if there are huge differences), then I'd vote for adding a separate alias file like git-oh-my-zsh to make it clear that these are the same aliases.

Out of curiosity: Why do you think that it's important that both use the same set of aliases?

bittner commented 6 years ago

A bit of background on my motivation:

I've only recently started working with short aliases. Before that I worked on automating the setup of development machines in a SWD agency roughly for the last year. Most of the developers were using Zsh when I joined, and new hires were forced to jump into it too, because it was a controlled, centralized setup without root access. I helped to make this more flexible, allowing a unified setup for all developers that gives freedom for - automated - custom setups, while still retaining centralized control for maintenance (but maintained from everyone in a DevOps fashion from then on). Hence, someone preferring a different distro, or Bash instead of Zsh, could have that easily too, by adding some custom adaptions to the configuration repositories.

Personally, I prefer having a setup that is as close to a distro default as possible, and ideally mainstream (which translates to Ubuntu and Bash, sorry folks!). Also, the wonky magic of the Oh My Zsh prompt made me feel uncomfortable. - But that may all be just a question of taste and getting used to it!

TL;DR

Before you embark on this, could you outline the main differences?

I've not really made an analysis yet. When you click on the two links above you'll see that - from a first impression - On My Zsh has more. Some are also different (e.g. gs vs. gst, which makes sense when you use Ghostscript :smirk:).

Why do you think that it's important that both use the same set of aliases?

Three reasons:

  1. It's easier to switch from Zsh to Bash (and vice-versa). No excuses anymore.
  2. When developers do pair programming they can use the same set of short Git commands, and they can learn from each other, even though one may be using Zsh and the other Bash.
  3. I promote employing best practices in SWD. And best practices are things that are popular. As Oh My Zsh seems to be tremendously popular already it makes sense, in my eyes, to build on their popularity aligning with them (which somewhat brings us back to item no. 1).

Bottom line: I want (to provide) more freedom.

What we could do

adding a separate alias file

I'll give that a shot. You're right, we shouldn't punish the muscle memory of people using Bash-it today. Therefore, I'll try to find out

and put that in a PR, if it makes sense.

How does that sound?

See also

You may be interested to know that I'm also talking to the Oh My Zsh project:

nwinkler commented 6 years ago

Wow - thanks for the detailed reply! Yes, that makes a lot of sense. Please go ahead with this...

Are you planning to duplicate the common aliases in each of the files (git and git-oh-my-zsh), or putting them in a common file? The latter case would be cleaner, but I'm not sure how they would be loaded in this case, since Bash-it currently does not have an out-of-the-box way of importing an alias file from another alias file...

bittner commented 6 years ago

I would like to try coming up with just one configuration in the long run (i.e. avoid a "run Bash-it in Oh-My-Zsh mode" feature), so it's the latter case, the common file for now.

Maybe I can just have a single file with the Oh My Zsh configuration on top and the current Bash-it differences at the bottom, thus overriding aliases where there are conflicts. But I have to figure that out. The Oh My Zsh configuration seems to have constructs proprietary to Zsh that make taking things over repeatedly not a totally trivial task.

Let's talk through the details once I have a better idea about what the differences really are.

bittner commented 6 years ago

Bash-it currently does not have an out-of-the-box way of importing an alias file

Sourcing a file seems to be possible, though it looks and feels a bit ugly. I've tried putting Oh My Zsh's Git alias plugin into a ./aliases/compat/ folder and source it, like this:

cite 'about-alias'
about-alias 'common git abbreviations'

BASHIT_HOME="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source "${BASHIT_HOME}/aliases/compat/git.plugin.zsh"

# Aliases
alias gcl='git clone'
...

Is there a better way?

nwinkler commented 6 years ago

The BASH_IT variable should be set to the install location of Bash-it. You shouldn't have to do the BASHIT_HOME dance that you did there, just use ${BASH_IT} instead.

bittner commented 6 years ago

Done.

How does the autocompletion work? Can we get this working easily with the additional aliases coming from Oh My Zsh?

And bash-it help aliases git, same story.

bittner commented 5 years ago

Hi @nwinkler, how was your summer season?

Can you shed light into my 2 questions from above (autocompletion, aliases-help) to help us figure out if PR #1201 is complete as it is, or if we can make it more useful?

nwinkler commented 5 years ago

Sorry for the late response, @bittner... Yes, summer vacation was very nice, thanks for asking.

To be honest, I don't know off the top of my head whether your code would be causing any issues with these two cases. I had a quick look at the code that generates the help for the aliases (in lib/helpers.bash), and it looks like the current code is simply using cat to pipe the alias file through a couple of filters. Based on this, I don't think that the new aliases (sourced) will be showing up, since the cat does not source the referenced file. This will probably require some changes...

The autocomplete will probably work, since it uses the aliases that are defined in the current shell.

Best strategy for verifying this:

Sorry if this does not help much...

NoahGorny commented 3 years ago

hey @bittner do you still want to do it?

bittner commented 3 years ago

Actually, this would be a super-important addition. I still have this fix on my local machine.

Unless there is a very good reason not to do so, the short aliases of Bash-it and Oh My Zsh should be align as much as possible, I feel. Motivations are mentioned above.

NoahGorny commented 3 years ago

Actually, this would be a super-important addition. I still have this fix on my local machine.

Unless there is a very good reason not to do so, the short aliases of Bash-it and Oh My Zsh should be align as much as possible, I feel. Motivations are mentioned above.

I see, I think that in that case, we should see what is the difference, and either create a new zsh-git completion file, or just change ours. I think that adding a new file would be ideal, and willing to do so provided someone would research the difference between us and oh-my-zsh. We would also need to write it done somewhere in the documentation in order to add new git aliases in the correct place.

Thanks for opening it up again @bittner, sorry for closing it in the first place!

cornfeedhobo commented 3 years ago

@NoahGorny The zsh aliases can be seen here

gaelicWizard commented 2 years ago

I think that adding a new file would be ideal

I suggest that having a single file would be ideal. I agree with @bittner that having similarity and building on popular usage are valuable in and of themselves. Its weird to do "Bash It in Oh My Zsh compatibility mode"... I'd suggest even disabling some old aliases, like gs, for new users. $0.02

NoahGorny commented 2 years ago

I just think that bash-it has his own flavours of aliases, and I wouldn't like to throw them all away. Its better to leave the option for people to choose for themselves between the bash-it ones and ohmyzsh ones

davidpfarrell commented 2 years ago

I'd suggest even disabling some old aliases, like gs

I've already used my gs alias over 100 times today, so I vote to keep it :)

I just think that bash-it has his own flavours of aliases

I completely agree.

I also don't see zsh as being any particular authority on aliases in general.

side note: I do wish there was a central website for shell alias discussion / best practices - then we could introduce plugins that align with them.

As it is, I think adding a new separate plugin that ports the zsh git aliases as much as possible to bash, would be useful to many people. It would essentially exist to be a proper bashified port of the zsh aliases and would not stray from that mandate.

That leaves the current git aliases to grow and evolve on their own, as seen fit by the bash-it community.

gaelicWizard commented 2 years ago

Should this issue be closed now that #1831 is merged?

NoahGorny commented 2 years ago

Unfortunately, its not merged yet- I still need to get around and address your comments and other things as well!

gaelicWizard commented 2 years ago

Oy! All this merging and I jumped the gun!!