This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.local/bin/mom

42 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env sh
######################################################################
2020-05-23 15:47:21 +02:00
# @author : swytch
# @file : mom
# @license : MIT
2020-05-23 15:47:21 +02:00
# @created : Wednesday May 20, 2020 18:19:56 CEST
#
2020-05-23 15:47:21 +02:00
# @description : create a groff doc with genereic metadata
# open it with (neo)vim
######################################################################
2020-05-06 03:20:19 +02:00
if [ -z "$1" ]; then
printf 'Please provide a name for your file\n'
2020-05-06 03:20:19 +02:00
elif [ -e "$1" ]; then
printf 'This filename is already taken, please provide a different name\n'
2020-05-06 03:20:19 +02:00
else
touch "$1" && \
printf '\# metadata' >> "$1" && \
printf '\n.AUTHOR "David JULIEN"' >> "$1" && \
printf '\n.TITLE' >> "$1" && \
printf '\n\# template' >> "$1" && \
printf '\n.PRINTSTYLE TYPESET' >> "$1" && \
printf '\n.QUOTE_STYLE QUAD' >> "$1" && \
printf '\n.SMARTQUOTES FR' >> "$1" && \
printf '\n.ATTRIBUTE_STRING "par"' >> "$1" && \
printf '\n.LINEBREAK_CHAR ""' >> "$1" && \
printf '\n\# cover' >> "$1" && \
printf '\n.COVER AUTHOR TITLE BLANKPAGE' >> "$1" && \
printf '\n.DOCHEADER OFF' >> "$1" && \
printf '\n\#' >> "$1" && \
printf '\n.START' >> "$1" && \
2020-05-06 03:20:19 +02:00
# checks if neovim is intalled
if command -v nvim > /dev/null 2>&1; then
2020-05-06 03:20:19 +02:00
nvim "$1"
else
vim "$1"
fi
fi