I see Define an alias in fish shell, and I know how to setup alias and/or functions,
But is it possible to setup different alias target based on OS? Maybe use function?
What I experience isn't standard I believe. I am currently using one FISH setup (dotfile) for all of my systems, such as macOS and Linux (Arch or Debian). I noticed that sometime for some program, it's not same across different OS.
For example, I try to use bat
to replace cat
and on Archlinux, bat
is a program that you can install from pacman
, but on Debian, if you install bat
with apt install bat
, you will get batcat
instead.
My current alias setup is
alias cat='bat'
but with this setup, Debian will throw error.
What I plan to do is something that can use different program based on different operation system. Or if possible, use first available command if it's available. Something like
function cat if os == 'debian': use batcat elseif os == 'archlinux': use batend
Or something probably better
function cat try to use bat first, if does not exist, try to use batcat, if not fallback to catend
I believe on ZSH, we can do alias cat="bat | cat"
for OR operation. But seems like it's not available on FISH
What is the best option for it?