diff --git a/bin/groff_addfont.sh b/bin/groff_ttf.sh similarity index 84% rename from bin/groff_addfont.sh rename to bin/groff_ttf.sh index 263c653..bd4468a 100755 --- a/bin/groff_addfont.sh +++ b/bin/groff_ttf.sh @@ -19,11 +19,22 @@ DIR=$(dirname "$(readlink -f "$0")") FONTPATH=$(readlink -f "$1") # with R B I suffix STYLE=$2 +case "$STYLE" in + R|B|I|BI) + ;; + *) + echo "warning: unknown style $STYLE, are u sure? [y/N]" + read -r CONFIRM_STYLE + if [ "$CONFIRM_STYLE" != 'y' ]; then + exit + fi + ;; +esac GROFF_CURRENT=$(readlink -f /usr/share/groff/current) GROFF_SITEFONT=/usr/share/groff/site-font TMPDIR="$(mktemp -d)" -trap 'rm -rf '"$TMPDIR"';cd -' EXIT +trap 'rm -rf '"$TMPDIR"';cd - >/dev/null' EXIT cd "$TMPDIR" echo "Change working directory to: $(pwd)" @@ -50,12 +61,20 @@ if ! grep "$PFA" "$GROFF_CURRENT/font/devps/download" ; then printf '%s\t%s\n' "$INA" "$PFA" | sudo tee -a "$GROFF_CURRENT/font/devps/download" >/dev/null fi +echo echo "Done, now you may use this font in your .ms file:" +printf "\033[32m" echo " .ds FAM $FONTNAME" +if [ "$STYLE" != "R" ] ; then +echo " .$STYLE \"text\"" +fi +printf "\033[0m" echo echo "Then, use following command to generate pdf file:" +printf "\033[32m" echo " groff -ms -U -Kutf8 input.ms > tmp.ps" echo " ps2pdf tmp.ps output.pdf" +printf "\033[0m" echo #sudo ln -sf "/usr/share/groff/site-font/devps/$PFA" "/usr/share/groff/site-font/devpdf/$PFA" diff --git a/cli/vim/init.vim b/cli/vim/init.vim index aba8cd6..76da5b9 100644 --- a/cli/vim/init.vim +++ b/cli/vim/init.vim @@ -253,3 +253,22 @@ fu! NERDCommenter_after() g:ft endif endfu + +" ==== groff ==== +function! ToggleGroffAutoCompilation() + let g:GroffAutoCompilation = !get(g:, "GroffAutoCompilation", 0) + + augroup GroffPdf + autocmd! + augroup END + + if g:GroffAutoCompilation + augroup GroffPdf + autocmd BufWritePost,FileWritePost *.ms :silent !groff -Kutf8 -ms % -U > /tmp/tmp.ps && ps2pdf /tmp/tmp.ps %.pdf + augroup END + echo "Auto compilation enabled" + else + echo "Auto compilation disabled" + endif +endfunction +nnoremap ac :call ToggleGroffAutoCompilation()