Merge pull request #43 from oh-my-fish/bundle/uniqueize

bundle: make contents unique when adding and installing bundle
This commit is contained in:
Derek Willian Stavis 2015-09-13 18:14:57 -03:00
commit 5e034ebcea
3 changed files with 11 additions and 5 deletions

View File

@ -10,6 +10,8 @@ function omf.bundle.add -a type name_or_url
else else
echo $record > $bundle echo $record > $bundle
end end
sort -u $bundle -o $bundle
end end
function __omf.write_theme function __omf.write_theme

View File

@ -1,10 +1,12 @@
function omf.bundle.install function omf.bundle.install
set bundle $OMF_CONFIG/bundle
if test -f $OMF_CONFIG/bundle if test -f $bundle
set packages (omf.list_local_packages) set packages (omf.list_local_packages)
set themes (omf.list_installed_themes) set themes (omf.list_installed_themes)
set bundle_contents (cat $bundle | sort -u)
for record in (cat $OMF_CONFIG/bundle | uniq) for record in $bundle_contents
set type (echo $record | cut -d' ' -f1) set type (echo $record | cut -d' ' -f1)
set name_or_url (echo $record | cut -d' ' -f2-) set name_or_url (echo $record | cut -d' ' -f2-)
set name (basename $name_or_url | sed 's/\.git//;s/^pkg-//;s/^plugin-//;s/^theme-//') set name (basename $name_or_url | sed 's/\.git//;s/^pkg-//;s/^plugin-//;s/^theme-//')
@ -20,8 +22,9 @@ function omf.bundle.install
omf.install --theme $name omf.install --theme $name
end end
end end
end end
sort -u $bundle -o $bundle
end end
return 0 return 0

View File

@ -4,7 +4,7 @@ function omf.bundle.remove
if test -f $bundle if test -f $bundle
set type $argv[1] set type $argv[1]
set name $argv[2] set name $argv[2]
set bundle_contents (cat $bundle | uniq) set bundle_contents (cat $bundle | sort -u)
rm -f $bundle rm -f $bundle
@ -17,7 +17,8 @@ function omf.bundle.remove
if not test "$type" = "$record_type" -a "$name" = "$record_basename" if not test "$type" = "$record_type" -a "$name" = "$record_basename"
echo "$record_type $record_name" >> $bundle echo "$record_type $record_name" >> $bundle
end end
end end
end end
return 0
end end