2017-03-14 19:14:22 +00:00
|
|
|
function export --description 'Set env variable. Alias for `set -gx` for bash compatibility.'
|
2017-03-14 20:17:53 +00:00
|
|
|
if not set -q argv[1]
|
2017-03-14 19:14:22 +00:00
|
|
|
set -x
|
2015-10-12 09:35:45 +00:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
for arg in $argv
|
2016-02-10 19:33:43 +00:00
|
|
|
set -l v (string split -m 1 "=" -- $arg)
|
|
|
|
switch (count $v)
|
2015-10-12 09:35:45 +00:00
|
|
|
case 1
|
|
|
|
set -gx $v $$v
|
|
|
|
case 2
|
2017-02-10 12:25:32 +00:00
|
|
|
if contains -- $v[1] PATH CDPATH MANPATH
|
|
|
|
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
|
|
|
|
set -gx $v[1] (string split ":" -- $colonized_path)
|
|
|
|
else
|
|
|
|
set -gx $v[1] $v[2]
|
|
|
|
end
|
2014-11-28 11:48:11 +00:00
|
|
|
end
|
2015-10-12 09:35:45 +00:00
|
|
|
end
|
2014-11-28 11:48:11 +00:00
|
|
|
end
|