mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
parent
7ab1c6c7ad
commit
d9b30ab090
2 changed files with 22 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
function export --description 'Set global variable. Alias for set -gx, made for bash compatibility'
|
||||
if test -z "$argv"
|
||||
set
|
||||
function export --description 'Set env variable. Alias for `set -gx` for bash compatibility.'
|
||||
if not set -q argv[0]
|
||||
set -x
|
||||
return 0
|
||||
end
|
||||
for arg in $argv
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
|
||||
function setenv --description 'Set global variable. Alias for set -g, made for csh compatibility'
|
||||
set -gx $argv
|
||||
function setenv --description 'Set env variable. Alias for `set -gx` for csh compatibility.'
|
||||
if not set -q argv[0]
|
||||
set -x
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue