Home » Questions » Computers [ Ask a new question ]

How do you "source" a file in fish?

How do you "source" a file in fish?

I'd like to use keychain with the fish shell, but I'm not sure how to get fish to load the ~/.keychain/hostname-fish file to set the appropriate environment variables.

Asked by: Guest | Views: 233
Total answers/comments: 2
bert [Entry]

"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 .."
bert [Entry]

"If the file you're trying to source contains bash, consider using Bass.

This will let you write, for example:

bass source ~/.bash_profile"