Enable redhats devtoolset in fish shell

679 Views Asked by At

Is there an appropriate way to enable devtoolset or any of the rh tools in the fish shell on startup? Normally in Zsh (~/.zshrc) or Bash (~/.bashrc) you would add lines similar to:

source /opt/rh/devtoolset-7/enable

or

source scl_source enable devtoolset-7

Unfortunately neither of those work in the ~/.config/fish/config.fish since the syntax isn't supported by fish. The only way I know how to do it is manually add all the lines in the enable file to my fish paths.

2

There are 2 best solutions below

0
On

I just found a way to do this. The key is to use a third-party tool which allows fish-shell source command read bash scripts. I use bass.

After installing bass, you can simply use bass source scl_source enable devtoolset-7 to change gcc version. You can also add it to ~/.config/fish/config.fish so that it takes effect everytime you log in.

More discussion here.

2
On

You can add commands in /etc/fish/config.fish

# Put system-wide fish configuration entries here
# or in .fish files in conf.d/
# Files in conf.d can be overridden by the user
# by files with the same name in $XDG_CONFIG_HOME/fish/conf.d

# This file is run by all fish instances.
# To include configuration only for login shells, use
# if status --is-login
#    ...
# end
# To include configuration only for interactive shells, use
# if status --is-interactive
#   ...
# end
source scl_source enable rh-git29
source scl_source enable rh-postgresql10