Re:Ask HN: Do you use the bash alias feature much?
by ksaj on Sunday May 29, 2022 @03:51PM
(#31552286)
Functions are great. Aliases are no replacement for them since every time you'd use one, the arguments are likely to be different. Here are a few examples I use for WSL:
None of these would work as aliases, unless you only want them to keep doing whatever they did in the first invocation every time thereafter. Eg: as an alias, yt would be limited to downloading the same video over and over again.
pbpaste () { powershell.exe -noprofile -command Get-Clipboard }
pbcopy () { clip.exe < "${1:-/dev/stdin}" }
yt () { youtube-dl -fmp4 --no-check-certificate `pbpaste` }
None of these would work as aliases, unless you only want them to keep doing whatever they did in the first invocation every time thereafter. Eg: as an alias, yt would be limited to downloading the same video over and over again.