mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-13 01:10:40 +00:00
20ed43983b
Having a clear namespace `omf.` improves the readability of the code as we clarify what is the function name and what is the namespace.
28 lines
729 B
Fish
28 lines
729 B
Fish
function omf.new_from_template -a path github user name
|
|
for file in $path/*
|
|
if test -d $file
|
|
mkdir (basename $file)
|
|
pushd (basename $file)
|
|
omf.new_from_template $file $github $user $name
|
|
else
|
|
set -l target (begin
|
|
if test (basename $file) = "{{NAME}}.fish"
|
|
echo "$name.fish"
|
|
else
|
|
echo (basename "$file")
|
|
end
|
|
end)
|
|
sed "s/{{USER_NAME}}/$user/;s/{{GITHUB_USER}}/$github/;s/{{NAME}}/$name/" \
|
|
$file > $target
|
|
echo (omf::em)" create "(omf::off)" "(begin
|
|
if test (basename $PWD) = $name
|
|
echo ""
|
|
else
|
|
echo (basename "$PWD")"/"
|
|
end
|
|
end)$target
|
|
end
|
|
end
|
|
popd >/dev/null ^&2
|
|
end
|