2024-02-06 23:57:22 +04:00
|
|
|
#!/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}
|
|
|
|
|
2024-03-05 20:56:51 +04:00
|
|
|
autoext=1
|
2024-02-06 23:57:22 +04:00
|
|
|
args=(
|
|
|
|
"créer un nouveau fichier .markdown"
|
|
|
|
"<files...>"
|
2024-03-05 20:56:51 +04:00
|
|
|
-j,--no-autoext autoext= "ne pas rajouter l'extension .yaml ni .yml"
|
2024-02-06 23:57:22 +04:00
|
|
|
)
|
|
|
|
parse_args "$@"; set -- "${args[@]}"
|
|
|
|
|
|
|
|
[ $# -gt 0 ] || die "vous devez spécifier les noms des fichiers à créer"
|
|
|
|
|
|
|
|
for file in "$@"; do
|
2024-03-05 20:56:51 +04:00
|
|
|
setx filename=basename -- "$file"
|
2024-02-06 23:57:22 +04:00
|
|
|
if [[ "$filename" == *.* ]]; then
|
2024-03-05 20:56:51 +04:00
|
|
|
: # y'a déjà une extension, ne rien faire
|
|
|
|
elif [ -z "$autoext" ]; then
|
|
|
|
: # ne pas rajouter d'extension
|
2024-02-06 23:57:22 +04:00
|
|
|
elif [ -f "$file.markdown" ]; then
|
|
|
|
file="$file.markdown"
|
|
|
|
else
|
|
|
|
file="$file.md"
|
|
|
|
fi
|
|
|
|
[ -e "$file" ] && die "$file: fichier existant"
|
|
|
|
estep "Création de $file"
|
2024-03-05 20:56:51 +04:00
|
|
|
|
2024-02-06 23:57:22 +04:00
|
|
|
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
|