Skip to content

Instantly share code, notes, and snippets.

@michaelmrose
Created June 28, 2015 23:49
Show Gist options
  • Save michaelmrose/112611102c201fb965a3 to your computer and use it in GitHub Desktop.
Save michaelmrose/112611102c201fb965a3 to your computer and use it in GitHub Desktop.
default variables and variable parsing in fish
set somevariable default val
set someothervariable default val
for i in (getvariables $argv)
set val (explode $i)
set $val[1] $val[2]
end
function getvariables
if not substr "$argv" =
return 1
else
set vars (println $argv | grep =)
for i in $vars
echo (echo $i | cut -d "=" -f1) (echo $i | cut -d "=" -f2)
end
end
end
function explode
echo $argv | sed 's/ /\n/g'
end
function substr
set e1 (tolower $argv[1])
set e2 (tolower $argv[2])
expr match $e1 .\*$e2.\* > /dev/null
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment