Skip to content

Instantly share code, notes, and snippets.

@deseven
Created December 26, 2019 23:33
Show Gist options
  • Save deseven/141d8f1b2323d4114e278ffe6ecfc096 to your computer and use it in GitHub Desktop.
Save deseven/141d8f1b2323d4114e278ffe6ecfc096 to your computer and use it in GitHub Desktop.
removes dupes from fish variable (taken from fish issue #296)
function varclear --description 'Remove duplicates from environment variable'
if test (count $argv) = 1
set -l newvar
set -l count 0
for v in $$argv
if contains -- $v $newvar
set count (math $count+1)
else
set newvar $newvar $v
end
end
set $argv $newvar
test $count -gt 0
and echo Removed $count duplicates from $argv
else
for a in $argv
varclear $a
end
end
return 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment