LANGUAGE » SHELL_SCRIPT » FISH

Variable

Usage

Creating variables

fish
set var_name value
set my_name (read)

Using variables

fish
echo $HOME
echo {$WORD}s
echo "$foo and $bar"

Special variables

BashFishDescription
$0status filenameFilename of current script.
$* $@ $1$argvScript or function arguments.
$#count $argvNumber of arguments.
$?$statusReturn code of last command.
$!$last_pidPID of last program run in background.
$$$fish_pidCurrent fish PID.
$-status is-interactive status is-loginCheck shell interactivity.

Load environment file

Considering .env an environment file (with KEY=VALUE tuples), one can export those variables in fish using:

fish
export (xargs -L 1 < .env)

Or a more complex solution like:

fish
export (grep -E '^[^#;].+=.*' .env | xargs -L 1)