Right now I'm forced to resort to using uname
to get the operating system name and it works. But in bash
there is the OSTYPE
environment variable that is automatically set and I was wondering if there is something similar.
Regular bash scripts can be used in fish shell just as scripts written in any language with proper shebang or explicitly using the interpreter (i.e. using bash script.sh ). However, many utilities, such as virtualenv, modify the shell environment and need to be sourced, and therefore cannot be used in fish.
bashrc and . profile, this file is always read, even in non-interactive or login shells. The “~/. config” part of this can be set via $XDG_CONFIG_HOME, that's just the default.
Fish, or the “Friendly Interactive Shell,” is the most user-friendly and interactive shell, in my opinion. It is much more customizable than Zsh and Bash. It has a ton of cool features like consistent syntax, nice tab completion and syntax highlighting, is easy to pick up and use, and has excellent runtime help.
From the fish user documentation it seems that the canonical way to execute code conditionally depending on the operating system type is using a switch
statement with the uname
results. See example:
switch (uname)
case Linux
echo Hi Tux!
case Darwin
echo Hi Hexley!
case FreeBSD NetBSD DragonFly
echo Hi Beastie!
case '*'
echo Hi, stranger!
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With