Re:Why “alias” is my last resort for aliases
by lvncelot on Wednesday March 05, 2025 @09:13AM
(#43266638)
Another 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.
[ Parent
| on HN ]
Re:Why “alias” is my last resort for aliases
by darrenf on Wednesday March 05, 2025 @09:30AM
(#43266883)
This 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`.
Re:Why “alias” is my last resort for aliases
by BenjiWiebe on Wednesday March 05, 2025 @01:55PM
(#43270662)
Some 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.
Re:Why “alias” is my last resort for aliases
by Graziano_M on Wednesday March 05, 2025 @09:26AM
(#43266821)
On 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'
Re:Why “alias” is my last resort for aliases
by pcthrowaway on Wednesday March 05, 2025 @09:54AM
(#43267288)
In 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/6a64ac7b014fa2cfa7a69af3c253...