-
-
Save meotimdihia/0c2c029b21cee45c6b85cc8aa9911bef to your computer and use it in GitHub Desktop.
config.fish set environment variables from bash_profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fish shell | |
egrep "^export " ~/.bash_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) | |
#echo "set -xg '$var' '$value' (via '$e')" | |
set -xg $var $value | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment