32 lines
766 B
YAML
32 lines
766 B
YAML
|
#!/bin/bash
|
||
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||
|
source /etc/nulib.sh || exit 1
|
||
|
|
||
|
: ${EDITOR:=vim}
|
||
|
|
||
|
args=(
|
||
|
"créer un nouveau fichier .yaml"
|
||
|
"<files...>"
|
||
|
)
|
||
|
parse_args "$@"; set -- "${args[@]}"
|
||
|
|
||
|
[ $# -gt 0 ] || die "vous devez spécifier les noms des fichiers à créer"
|
||
|
|
||
|
for file in "$@"; do
|
||
|
setx filename=basename "$file"
|
||
|
if [[ "$filename" == *.* ]]; then
|
||
|
: # y'a une extension, ne rien faire
|
||
|
elif [ -f "$file.yaml" ]; then
|
||
|
file="$file.yaml"
|
||
|
else
|
||
|
file="$file.yml"
|
||
|
fi
|
||
|
[ -e "$file" ] && die "$file: fichier existant"
|
||
|
estep "Création de $file"
|
||
|
echo >"$file" "\
|
||
|
# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||
|
|
||
|
"
|
||
|
"$EDITOR" +3 "$file"
|
||
|
done
|