Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wasn't aware of +commands, thanks. Though I'm not sure this is easier and you can translate mine to bash trivially

Yours isn't technically equivalent though it is functionally. If we have both vim and nvim then we'll alias vi twice.

Also, your program provides less clarity. It saves lines but at a large cost to readability. I tend to share my dotfiles with newbies a lot so readability is very meaningful.

I wrap mine up in functions too because at the end of my alias file I can add something like this

  # aliases.zsh
  main() {
    alias_ls || echo "ls aliasing failed"
    alias_vim || echo "vim aliasing vailed"
  }

  main
It's a bit overkill and I never expect a simple alias like that to fail but there are three distinct advantages I get for being just a tad more verbose:

1) I have more complicated versions to deal with things like fd and batcat which have different names different operating systems (`fd` vs `fd-find` / `bat` vs `batcat`) and some additional configurations.

2) I can disable the alias by commenting out one line

3) knowing exactly where the alias is being loaded and thus what aliases are loaded.

Bonus) fails loudly but continues (it's an alias, I don't want you fail fail)

A few extra keystrokes are worth this advantage imo. Especially since I'm using vim so it's actually not any additional typing lol

It's style, so the choice is up to you and they'll accomplish the same things, but I'm just explaining why I use this design pattern. I've only given a stripped down snippet of code so I hope this context helps explain the larger pictures and how it can be used for larger needs.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: