ajout templ.md et .yml

This commit is contained in:
Jephté Clain 2024-02-06 23:57:22 +04:00
parent 3734e0b3c7
commit 537263216e
3 changed files with 63 additions and 0 deletions

31
bin/templ.md Executable file
View File

@ -0,0 +1,31 @@
#!/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 .markdown"
"<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.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

View File

@ -17,6 +17,7 @@ parse_args "$@"; set -- "${args[@]}"
for file in "$@"; do
[ -e "$file" ] && die "$file: fichier existant"
estep "Création de $file"
if [ -n "$executable" ]; then
cat >"$file" <<EOF
#!/bin/bash

31
bin/templ.yml Executable file
View File

@ -0,0 +1,31 @@
#!/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