mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
20 lines
664 B
Fish
20 lines
664 B
Fish
function export --description 'Set global variable. Alias for set -gx, made for bash compatibility'
|
|
if test -z "$argv"
|
|
set
|
|
return 0
|
|
end
|
|
for arg in $argv
|
|
set -l v (string split -m 1 "=" -- $arg)
|
|
switch (count $v)
|
|
case 1
|
|
set -gx $v $$v
|
|
case 2
|
|
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
|
|
end
|
|
end
|
|
end
|