2023-10-30 21:50:18 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
declare -A mapper=(
|
|
|
|
["nix"]="nix"
|
|
|
|
)
|
|
|
|
|
|
|
|
declare -A edit_file=(
|
|
|
|
["nix"]="shell.nix"
|
|
|
|
)
|
|
|
|
|
|
|
|
if [ -z "$1" ]
|
|
|
|
then
|
|
|
|
echo "No argument given. Use --list (-l) to show all options."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "-l" ] || [ "$1" = "--list" ]
|
|
|
|
then
|
|
|
|
echo "${!mapper[@]}"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
target="${mapper["$1"]}"
|
|
|
|
if [ -z "$target" ]
|
|
|
|
then
|
|
|
|
echo "Template not found. Use --list (-l) to show all options."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
target="$XDG_CONFIG_HOME/templates/$target"
|
|
|
|
if [ -f "$target" ]
|
|
|
|
then
|
2023-10-30 21:54:28 +00:00
|
|
|
cp -i "$target" .
|
2023-10-30 21:50:18 +00:00
|
|
|
echo "Template copied."
|
|
|
|
elif [ -d "$target" ]
|
|
|
|
then
|
2023-10-30 21:54:28 +00:00
|
|
|
cp -irT "$target" .
|
2023-10-30 21:50:18 +00:00
|
|
|
echo "Template copied."
|
|
|
|
else
|
|
|
|
echo "Error copying template."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${edit_file["$1"]}" ]
|
|
|
|
then
|
|
|
|
$EDITOR "${edit_file["$1"]}"
|
|
|
|
fi
|