vim ~/.config/fish/config.fish
添加以下代码
# REUSE ENVIRONMENT VARIABLES FROM ~/.bash_profile
bash -c '. ~/.bash_profile; env' | while read e
set var (echo $e | sed -E "s/([a-zA-Z0-9_]+)=(.*)\$/\1/")
set value (echo $e | sed -E "s/([a-zA-Z0-9_]+)=(.*)\$/\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)
#echo "set -xg '$var' '$value' (via '$e')"
switch $value
case '`*`';
# executable
set NO_QUOTES (echo $value | sed -E "s/^\`(.*)\`\$/\1/")
set -x $var (eval $NO_QUOTES)
case '*'
# default
switch $var
case 'PWD'
case 'SHLVL'
case '_'
case '*'
eval set -xg $var $value
end
end
end
标签:profile,case,set,fish,value,echo,eval,var,bash
From: https://www.cnblogs.com/hangj/p/17879327.html