Skip to content

Instantly share code, notes, and snippets.

@alyssaq
Created April 30, 2015 03:54
Show Gist options
  • Save alyssaq/f3d8173cb952182a4a6b to your computer and use it in GitHub Desktop.
Save alyssaq/f3d8173cb952182a4a6b to your computer and use it in GitHub Desktop.
config.fish set environment variables from bash_profile
# 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