17

Is there a way I can do something like run myscript.sh in fish ?

I am using Arch Linux, and have installed the fish shell together with oh-my-fish

Can someone tell me which file I must edit to add my custom shell startup commands?

In zsh it was the ~/.zshrc file. What is it in the fish shell?

I have a problem: if I put my stuff in bashrc it is not loaded by fish. If I enter bash commands in the fish file ~/.config/fish/config.fish, it throws errors

Is there a way to get fish to load an "sh" file so that I can put all my bash things in that file?

2 Answers 2

15

bash and fish have incompatible syntax, so they cannot share startup files. You can put startup commands in ~/.config/fish/config.fish.

However this is usually unnecessary! For creating functions or aliases, you can use autoloading functions. For setting variables, including env vars, you can use universal variables.

3
  • 1
    is there a way i can do something like run myscript.sh in fish
    – Mr Mixin
    Jun 23, 2015 at 10:22
  • 1
    Of course you can: sh myscript.sh (or use "bash" instead of "sh"). However if you are expecting that script to set environment variables for you, it won't: fish does not have the same syntax as sh. You have to rewrite all your bash settings, variables, functions, etc, into fish. It's not that hard. Read the fish docs, and ask specific questions here if you run into problems. Jun 23, 2015 at 13:15
  • Adding folders to $PATH as universal variable: set -U fish_user_paths ~/.bin/ ~/.cargo/bin/ ...
    – arve0
    Jun 16, 2019 at 18:09
8

I tried sourcing .profile on fish startup and it worked like a charm for me.

just do :

echo 'source ~/.profile;clear;' >  ~/.config/fish/config.fish

Quit terminal or iterm2 followed by firing up an alias from .profile to test.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .