/usr/share/defaults/etc/profile equivilent for fish shell

if fish is the users shell and /usr/share/defaults/etc/profile is not sourced.

# /etc/fish/config.fish: system-wide .profile for the fish shell (fish(1))

# Add /usr/bin, the avx2/avx512 bin paths to PATH as needed
# Then cleanup symlink paths
set -l paths /usr/bin
if  grep -q "flags.*:.* avx512bw" /proc/cpuinfo
  set -a paths /usr/bin/haswell/avx512_1
else if grep -q "flags.*:.* fma .* avx2" /proc/cpuinfo
  set -a paths /usr/bin/haswell
end
set -a paths /usr/local/bin ~/.local/bin
for path in $paths
  if not contains $path $PATH
    set -p --path PATH $path
  end
end
# Remove from beginning/end/middle of PATH
set -l num 0
set -l bad_indexes
set -l bad_paths /bin /sbin /usr/sbin
for path in $PATH
  set -l num $(math 1+$num)
  if contains $PATH[$num] $bad_paths
    set -a bad_indexes $num
  end
end
if test -n $bad_indexes
  set -e PATH[$bad_indexes]
end

if test -x /bin/vi
  set -x EDITOR /usr/bin/vi            #needed for packages like cron
else
  set -x EDITOR /usr/bin/nano          #needed for packages like cron
end

if not test -e /etc/localtime
  set -x TZ UTC
end

set -x CFLAGS -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -Wformat -Wformat-security -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -fno-semantic-interposition -ffat-lto-objects -fno-trapping-math -Wl,-sort-common -Wl,--enable-new-dtags -mtune=skylake -mrelax-cmpxchg-loop 
set -x FFLAGS -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -malign-data=abi -fno-semantic-interposition -ftree-vectorize -ftree-loop-vectorize -Wl,--enable-new-dtags 
set -x FCFLAGS -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -malign-data=abi -fno-semantic-interposition -ftree-vectorize -ftree-loop-vectorize -Wl,-sort-common -Wl,--enable-new-dtags 
set -x CXXFLAGS $CFLAGS -fvisibility-inlines-hidden -Wl,--enable-new-dtags 
set -x AR gcc-ar

set -x RANLIB gcc-ranlib
set -x NM gcc-nm
set -x LA_VERSION "OpenBLAS"
set -x LA_LIBS /usr/lib64/libopenblas.so.0
set -x LA_INCLUDE /usr/include
set -x LA_PATH /usr/lib64/
set -x MPI_CC /usr/bin/mpicc
set -x MPI_LIBS /usr/lib64/libmpi.so
set -x MPI_INCLUDE /usr/include/
set -x MPI_PATH /usr/lib64/
set -x MPI_VERSION 3.2
set -x THEANO_FLAGS 'floatX float32,openmp true,gcc.cxxflags "-ftree-vectorize -mavx"'
set -x CC gcc
set -x CXX g++
set -x PYTHONIOENCODING utf-8:surrogateescape
set -x MESA_GLSL_CACHE_DISABLE 0
set -x GTK_IM_MODULE "ibus"
set -x JAVA_INCLUDE_PATH /usr/lib/jvm/java-1.18.0/include
set -x RUSTFLAGS '-C target-cpu=native'

set -l vars /usr/local/lib{,64}/pkgconfig/ /usr/local/share/pkgconfig
for var in $vars
  if not contains $var $PKG_CONFIG_PATH
    set -ax PKG_CONFIG_PATH $var
  end
end

for langfile in /usr/share/defaults/etc/locale.conf /etc/locale.conf "$HOME/.i18n"
  if test -f $langfile
    for var in $(cat $langfile)
      set -x $(string split ' ' $(string replace = ' ' $var))
    end
  end
end

set -x --path XDG_CONFIG_DIRS /usr/share/xdg /etc/xdg

umask 022

Is this necessary for xonsh too ?

yes.
btw, depending on what login manager you use, your login manager may pull in the bash profile regardless.

1 Like

set default shell to bash and exec fish in bashrc