-
-
Save larromba/f3e597f8d986574f23cdd7c3c9b6bfa3 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
set -g -x fish_greeting '' | |
function fish_prompt | |
importProfile ~/.bashrc | |
set_color $fish_color_cwd | |
echo -n (prompt_pwd) | |
echo -n (git-radar --fish --fetch) | |
set_color normal | |
echo -n ' > ' | |
end | |
function importProfile | |
egrep "^export " $argv | while read e | |
set var (echo $e | sed -E "s/^export ([A-Z_0-9]+)=(.*)\$/\1/") | |
set value (echo $e | sed -E "s/^export ([A-Z_0-9]+)=(.*)\$/\2/") | |
# remove comments if existing | |
set value (echo $value | sed -E "s/# [A-Za-z ]+//g") | |
# remove surrounding quotes if existing | |
set value (echo $value | sed -E "s/\"//g") | |
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 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment