Here's some examples of what this would look like in fish:
set -x INBOX $NOTES_HOME/inbox
if [ -d "$MINION_INSTALL" ]
set -x PATH $MINION_INSTALL $PATH
end
Note the absence of the quotes, which is especially important in the line that sets PATH. Quoting it would collapse all of the paths in the list to a single entry, which is not what you want.
The aliases are valid in fish, except for the $@ at the end. fish has arguments as $argv
, not $@
, but more importantly, any arguments are implicitly appended to the alias command. So you can just write:
alias newnote="minion --new-note"
Then, for example, newnote foo bar
will become minion --new-note foo bar
If you like, you can verify it with functions newnote
, which will show you the function that the alias produced.
Hope that helps!
bash has special syntax for setting environment variables, while fish uses a builtin. I would suggest writing your .env file like so:
setenv VAR1 val1
setenv VAR2 val2
and then defining setenv
appropriately in the respective shells. In bash (e.g. .bashrc):
function setenv() { export "$1=$2"; }
. ~/.env
In fish (e.g. config.fish):
function setenv; set -gx $argv; end
source ~/.env
Note that PATH will require some special handling, since it's an array in fish but a colon delimited string in bash. If you prefer to write setenv PATH "$HOME/bin:$PATH"
in .env, you could write fish's setenv like so:
function setenv
if [ $argv[1] = PATH ]
# Replace colons and spaces with newlines
set -gx PATH (echo $argv[2] | tr ': ' \n)
else
set -gx $argv
end
end
This will mishandle elements in PATH that contain spaces, colons, or newlines.
The awkwardness in PATH is due to mixing up colon-delimited strings with true arrays. The preferred way to append to PATH in fish is simply set PATH $PATH ~/bin
.
Best Answer
\t
, without quotes. Same thing for other control characters (\n
for a newline, etc.).