4 ms·
The other advantage that the article misses for aliases is that completions will work through aliases. So, in the case give for `alias g=git` typing `g <tab>` w
by pwagland 2y ago
The other advantage that the article misses for aliases is that completions will work through aliases. So, in the case give for `alias g=git` typing `g <tab>` will give you the bash/zsh completions for git. You _can_ do this for the script as well, but then you need to code that up separately.
- shellnoob 2y agonobody tell him
- JadeNB 2y ago> nobody tell him What?
- tasn 2y agoI came here to say the same thing. I'm also not convinced about the instant reload aspect. You can always just define your aliases in a different file and source it when updating aliases (how often does that happen anyway?), source your .zshrc, or just open a new terminal window.
- chime 2y agoI have alias s='source ~/.zshrc'.
- alkh 2y agoI have an alias reload="exec zsh" for fast reloading. Admittedly, this does wreck up everything set up locally but I doubt you will be modifying ~/.[zsh|bash]rc file often
- chrisfinazzo 2y agoSourcing .zshrc works reasonably well. I have the following at the end of setup.sh -- which creates symlinks and sets up other configurations. makeLinks does most of the work, then sets Homebrew's zsh as the default shell -- this currently runs in bash, so it probably will need to be updated at some point -- and everything gets reloaded. makeLinks && chsh -s /usr/local/bin/zsh exec $SHELL && brew doctor
- watusername 2y agoYes, and this is why I recommend against the alias-y wrappers. Personally, I like using abbreviations ("abbr") in fish, which automatically expand as you hit space. This is especially helpful when screen sharing: No more "what does this gcob command do" questions!
- psychoslave 2y agoCame here to mention just this, all the more as the article mention that the author is considering a move to Fish.
- leojfc 2y agoYeah, I do something kind of similar, using Dash [1] snippets which expand to full commands. Since I'm almost always on my mac, it means they're available in every shell, including remote shells, and in other situations like on Slack or writing documentation. I mostly use § as a prefix so I don't type them accidentally (although my git shortcuts are all `gg`-consonant which is not likely to appear in real typing). [1] https://kapeli.com/dash https://kapeli.com/dash
- BerislavLopac 2y agoI was nearly 10 years old (i.e. as a Fish user) when I learned about abbr. I used to use functions for everything. :facepalm:
- modeless 2y agoThis doesn't work for me in Ubuntu 22.04. Is it a recent feature of bash?
- mqus 2y agoThis is a feature in zsh (I don't think it works in bash and the autocomplete in bash is also a bit inferior to the zsh one)
- lvncelot 2y agoAnother advantage of using alias: `which [alias]` actually tells you what that alias is mapped to, and not just the location of a script in your bin folder.
- Graziano_M 2y agoOn what shell? That doesn't work in bash. I use `type` for that, since it'll tell you if it's on PATH, a function, or an alias which gdb /opt/homebrew/bin/gdb ~ type gdb gdb is aliased to `gdb -q'
- lvncelot 2y agozsh for me ~ ▸ which k k: aliased to kubectl
- pcthrowaway 2y agoIn bash this is how I get git completions working (with bash functions rather than aliases): __git_complete grm _git_rm grm() { git rm "${@}" } Internally git uses the __git_complete function to set up completions for its subcommands, though this may be specific to your OS/distro and perhaps or git version. This does seem to ship as part of git now, here[1]. [1]: https://github.com/git/git/blob/6a64ac7b014fa2cfa7a69af3c253bcd53a94b428/contrib/completion/git-completion.bash#L3958 https://github.com/git/git/blob/6a64ac7b014fa2cfa7a69af3c253...
- darrenf 2y agoThis is something I've never seen. `which` (at least on the hosts I currently have access to) is its own binary `/usr/bin/which` and unrelated to the shell and its aliases or abbreviations. `type` is a builtin on both fish and bash though, and does resolve aliases. [edit] TIL: `zsh` has its own `which`.
- BenjiWiebe 2y agoSome distros use an alias which pipes all the aliases into 'which', which has a flag that supports reading aliases from stdin. Fedora does it. It's very convenient.
- saghm 2y agoI remember years ago seeing a trick related to this to allow aliases after `sudo` (which I think by default won't recognize them due to running as a separate user) by doing `alias sudo="sudo ".