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

Consider converting simple aliases to abbreviations #41

Closed
bingocaller opened this issue May 6, 2020 · 10 comments · Fixed by #42
Closed

Consider converting simple aliases to abbreviations #41

bingocaller opened this issue May 6, 2020 · 10 comments · Fixed by #42

Comments

@bingocaller
Copy link
Contributor

What?

Since fish supports abbreviations, perhaps we should convert the simple aliases (like gf for git fetch) to abbreviations?
For example, with an abbreviation in place, the input g f Space will result in the full text git fetch on the command line; from here the user can keep typing to append stuff to the command. Alternatively, if the user ends the abbreviation with Enter, the full text gets unfolded and the command is issued immediately.

Why?

  1. I think this would be helpful for users to see which git commands are actually being run and also make command history more searchable (it's probably easier to remember to search for git rebase rather than grb).
  2. We don't flood the user's functions directory with non-namespaced functions.
  3. It might eliminate the need for custom completions.
  4. See more pros and cons in Abbreviations fish-shell/fish-shell#731

However!

Depending on how we handle it, this might be a breaking change if people use their breeze aliases inside functions or other aliases.

Also, I'm not entirely sure how to get this to the users since each abbreviation is stored as a global or universal variable and not as a function. Maybe we can add it in a conf.d script which runs as part of the fisher install process?

@bingocaller
Copy link
Contributor Author

@shinriyo Should I give this a stab? I can provide a PR, which might help clarify what this change will mean for the project.

@shinriyo
Copy link
Owner

@bingocaller Thank you for your pullrequest.

@shinriyo shinriyo reopened this Aug 30, 2020
@shinriyo
Copy link
Owner

@bingocaller

Hello, can you run gs command?

_breeze_git_branch
fish: Unknown command _breeze_git_branch

So, I reopened the issue.

@bingocaller
Copy link
Contributor Author

@shinriyo Yes, it works for me. I'm on the latest version of shinriyo/breeze, installed through fisher.
Maybe you're still installing from my branch or there are some leftover abbreviations in your config?
Does abbr --show | grep _breeze give you any output? If so, you might have to run an abbr --erase command for each abbreviation you want to get rid of.

@shinriyo
Copy link
Owner

@bingocaller

Thank you for replying. I didn't know abbr command.

I ran it.

> abbr --show | grep _breeze
abbr -a -U -- ga _breeze_git_add
abbr -a -U -- gb _breeze_git_branch
abbr -a -U -- gbl _breeze_git_blame
abbr -a -U -- gbu _breeze_git_branch_upstream
abbr -a -U -- gco _breeze_git_checkout
abbr -a -U -- gd _breeze_git_diff
abbr -a -U -- gl _breeze_git_log
abbr -a -U -- grm _breeze_git_rm
abbr -a -U -- gs _breeze_git_status

So, how do I use abbr --erase command?

@shinriyo
Copy link
Owner

I don't know what it is 😄 . but it may resove.

abbr --erase: No abbreviation named _breeze_git_add
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase ga
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase gb
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase gbl
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase gbu
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase gbo
abbr --erase: No abbreviation named gbo
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase gd
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase gl
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase gco
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase gl
abbr --erase: No abbreviation named gl
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase grm
shinriyo@Shinsukes-MBP ~/d/f/andu> abbr --erase gs

but, I wanted to know the one-liner remove command 👍

@bingocaller
Copy link
Contributor Author

bingocaller commented Sep 1, 2020

@shinriyo You would have to run abbr --erase for each abbreviation you want to erase, so abbr --erase gs, abbr --erase gd, etc. until they are all gone. I just realised this is exactly what you did! 😅
You could potentially also create a one-liner, which chains together all the abbr --erase commands with and or && like so: abbr --erase gs; and abbr --erase gd ... or abbr --erase gs && abbr --erase gd ...

@shinriyo
Copy link
Owner

shinriyo commented Sep 1, 2020

@bingocaller
putting gs and gd, ... are troublesome.
I'd like to automatically collect them.

I didn't try it yet. but I guess like this

abbr --show | grep _breeze | awk -F'[ ]' '{print $5}' | xargs -n1 abbr --erase

@bingocaller
Copy link
Contributor Author

@shinriyo Yeah, that could probably work! But I don't think it's a problem for other users than you and I, since we're the only ones (that I know of) who have tested the _breeze_git approach.

@shinriyo
Copy link
Owner

shinriyo commented Jan 3, 2021

I forgot to close

@shinriyo shinriyo closed this as completed Jan 3, 2021
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 a pull request may close this issue.

2 participants