37 lines
959 B
Markdown
Executable File
37 lines
959 B
Markdown
Executable File
#!/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}
|
|
|
|
autoext=1
|
|
args=(
|
|
"créer un nouveau fichier .markdown"
|
|
"<files...>"
|
|
-j,--no-autoext autoext= "ne pas rajouter l'extension .yaml ni .yml"
|
|
)
|
|
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 déjà une extension, ne rien faire
|
|
elif [ -z "$autoext" ]; then
|
|
: # ne pas rajouter d'extension
|
|
elif [ -f "$file.markdown" ]; then
|
|
file="$file.markdown"
|
|
else
|
|
file="$file.md"
|
|
fi
|
|
[ -e "$file" ] && die "$file: fichier existant"
|
|
estep "Création de $file"
|
|
|
|
echo -n >"$file" "\
|
|
|
|
|
|
-*- coding: utf-8 mode: markdown -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8:noeol:binary"
|
|
"$EDITOR" "$file"
|
|
done
|