How do you "source" a file in fish?

Solution 1:

Below is what I have in ~/.config/fish/config.fish for your specific example.

set -gx HOSTNAME (hostname)
if status --is-interactive;
    keychain --nogui --clear ~/.ssh/id_rsa
    [ -e $HOME/.keychain/$HOSTNAME-fish ]; and source $HOME/.keychain/$HOSTNAME-fish
end

The source command is source, which also works in bash.


Prior to fish 2.1.0, the source command was called ..

Solution 2:

Use the source command:

source filename.txt