Hacker News new | ask | show | jobs
by tester457 471 days ago
For more power try fish's abbreviations.

With `--position anywhere` you can expand an abbreviation even if it's not at the beginning of a line.

4 comments

Another great advantage of fish abbreviations is your history shows the actual command that was run (and in fact as soon as you've typed it, it expands, so you SEE what you're running).
Yes, essentially on the fly editable aliases. Fish is so good. I assume there's a zsh plugin that mimics that functionality - zsh people should try it.
I like putting my "aliases" into the functions directory of my config.

I have one that uses podman if it's available when I type `docker`. If I ever specifically need Docker I can use the fully-qualified path. I have a similar trick for `nvim`/`vim`.

This is the right way. I mentioned in another comment, but abbreviations also shine when screen sharing: Everyone can follow along quickly without having to ask the "what does this gcob command do" questions.
zsh also supports the "alias anywhere" concept (their term is "global alias") by using the `-g` flag.

   alias -g ag='2>&1 | grep'
   some-command ag 'words' # equivalent to: some-command 2>&1 | grep 'words'
Yeah, it's very convenient. Here are a few of mine(tested on OS X):

  alias -g L="| less"
  alias -g T="| tee"
  alias -g C="| pbcopy"
  alias -g @all="> /dev/null 2>&1"
  if command -v rg > /dev/null; then
   alias -g G="| rg"
  else
   alias -g G="| grep"
  fi