Fish shell not loading in paths from bashrc

Viewed 2516

I have a fish shell which does not load the paths from bash when I start it.

I have the following line in my ~/.bashrc

export PATH=$PATH:/usr/local/go/bin

When a new fish terminal is opened by default go is not recognised. However, when I switch to bash by running bash and then back to fish by running fish the paths are loaded in and go works. Is there a way for the paths in the bashrc file to be loaded in automatically without me defining them again in fish?

2 Answers

As @chepner has rightly pointed out, it is good to keep fish's config.fish independent of .bashrc since these shells use different syntax. If you do need to use .bashrc and limit that script to the syntactic nuances of fish, then try adding this to your ~/.config/fish/config.fish file:

bashrc=$HOME/.bashrc
[ -f "$bashrc" ] && source "$bashrc"

A fishy way to load in in paths is to just run the following command once.

set -U fish_user_paths /usr/local/go/bin $fish_user_paths

Running this command once is the equivalent of adding the export statement to your .bashrc file.

Thank you everyone else for your answers but I feel like this solved my problem the best!

Related