(I'm talking about the shell Fish, esp. Fish's Fish.)
For Bash/ZSH, I had ~/.profile
with some exports, aliases and other stuff.
I don't want to have a separate config for environment variables for Fish, I want to re-use my ~/.profile
. How?
In The FAQ, it is stated that I can at least import those via /usr/local/share/fish/tools/import_bash_settings.py
, however I don't really like running that for each Fish-instance.
Answer
My current solution (see here for a maybe more recent version):
egrep "^export " ~/.profile | while read e
set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\1/")
set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\2/")
# remove surrounding quotes if existing
set value (echo $value | sed -E "s/^\"(.*)\"\$/\1/")
if test $var = "PATH"
# replace ":" by spaces. this is how PATH looks for Fish
set value (echo $value | sed -E "s/:/ /g")
# use eval because we need to expand the value
eval set -xg $var $value
continue
end
# evaluate variables. we can use eval because we most likely just used "$var"
set value (eval echo $value)
set -xg $var $value
end
Comments
Post a Comment