diff --git a/global/common.zsh b/global/common.zsh index 656ace2..25b597d 100644 --- a/global/common.zsh +++ b/global/common.zsh @@ -15,17 +15,27 @@ __ENV_TEMPLATE=$SCWRYPTS_ROOT/.env.template ##################################################################### +__GET_PATH_TO_RELATIVE_ARGUMENT() { + [[ $1 =~ ^[.] ]] \ + && echo $(readlink -f "$EXECUTION_DIR/$1") \ + || echo "$1" \ + ; + true +} + +##################################################################### + __RUN_SCWRYPT() { ((SUBSCWRYPT+=1)) - printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) " - echo " BEGIN SUBSCWRYPT : $(basename $1)" + { printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "; } >&2 + echo " BEGIN SUBSCWRYPT : $(basename $1)" >&2 SUBSCWRYPT=$SUBSCWRYPT SCWRYPTS_ENV=$ENV_NAME \ "$SCWRYPTS_ROOT/scwrypts" $@ EXIT_CODE=$? - printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) " - echo " END SUBSCWRYPT : $(basename $1)" + { printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "; } >&2 + echo " END SUBSCWRYPT : $(basename $1)" >&2 ((SUBSCWRYPT-=1)) return $EXIT_CODE diff --git a/run b/run index 7d5a86f..826c83d 100755 --- a/run +++ b/run @@ -1,4 +1,6 @@ #!/bin/zsh +export EXECUTION_DIR=$(pwd) + SCWRYPTS_ROOT="${0:a:h}" source "$SCWRYPTS_ROOT/zsh/common.zsh" || exit 42 ##################################################################### @@ -14,7 +16,6 @@ OPTIONS -h, --help display this message and exit ' - cd "$SCWRYPTS_ROOT" local ENV_NAME="$SCWRYPTS_ENV" @@ -103,7 +104,7 @@ OPTIONS [ ! $LOGFILE ] && { [ $HEADER ] && echo $HEADER - [[ $SUBSCWRYPT -eq 0 ]] && { + [ $SUBSCWRYPT ] && { eval $RUN_STRING $@ exit $? } || { diff --git a/zsh/db/run-sql/common.zsh b/zsh/db/run-sql/common.zsh new file mode 100644 index 0000000..1191a72 --- /dev/null +++ b/zsh/db/run-sql/common.zsh @@ -0,0 +1,4 @@ +_DEPENDENCIES+=() +_REQUIRED_ENV+=() +source ${0:a:h}/../common.zsh +##################################################################### diff --git a/zsh/db/run-sql/postgres b/zsh/db/run-sql/postgres new file mode 100755 index 0000000..5da5727 --- /dev/null +++ b/zsh/db/run-sql/postgres @@ -0,0 +1,72 @@ +#!/bin/zsh +_DEPENDENCIES+=( + psql +) +_REQUIRED_ENV+=() +source ${0:a:h}/common.zsh +##################################################################### + +_RUN_SQL_POSTGRES() { + local _HOST _NAME _PASS _PORT _USER INPUT_FILE + + while [[ $# -gt 0 ]] + do + case $1 in + --host | -h ) _HOST="$2"; shift 2 ;; + --name | -d ) _NAME="$2"; shift 2 ;; + --pass | -w ) _PASS="$2"; shift 2 ;; + --port | -p ) _PORT="$2"; shift 2 ;; + --user | -U ) _USER="$2"; shift 2 ;; + --file | -i ) INPUT_FILE="$2"; shift 2 ;; + * ) shift 1 ;; + esac + done + + [ ! $_HOST ] && _HOST=127.0.0.1 + [ ! $_NAME ] && _NAME=postgres + [ ! $_PORT ] && _PORT=5432 + [ ! $_USER ] && _USER=postgres + + local SQL_DIR="$SCWRYPTS_DATA_PATH/sql" + [ ! -d $SQL_DIR ] && mkdir -p $SQL_DIR + cd $SQL_DIR + + [[ $(ls "*.sql" 2>&1 | wc -l) -eq 0 ]] && { + __ERROR "you haven't made any SQL commands yet" + __REMINDER "add '.sql' files here: '$SQL_DIR/'" + exit 1 + } + + [ ! $INPUT_FILE ] && INPUT_FILE=$(\ + __FZF 'select a sql file to run' + ) + [ ! $INPUT_FILE ] && __ABORT + + [ ! -f $INPUT_FILE ] && { + __FAIL 2 "no such sql file '$SQL_DIR/$INPUT_FILE'" + } + + __STATUS "loading $INPUT_FILE preview..." + _LESS $INPUT_FILE + + __STATUS "login : $_USER@$_HOST:$_PORT/$_NAME" + __STATUS "command : ./$INPUT_FILE" + + __yN 'run this command?' || __ABORT + + __STATUS "running './$INPUT_FILE'" + PGPASSWORD="$_PASS" psql \ + -h $_HOST \ + -p $_PORT \ + -U $_USER \ + -d $_NAME \ + < $INPUT_FILE \ + && __SUCCESS "finished running './$INPUT_FILE'" \ + || __FAIL 3 "something went wrong running './$INPUT_FILE' (see above)" +} + +##################################################################### +__WARNING +__WARNING 'this function is in a beta state' +__WARNING +_RUN_SQL_POSTGRES $@ diff --git a/zsh/latex/build-pdf b/zsh/latex/build-pdf new file mode 100755 index 0000000..0902495 --- /dev/null +++ b/zsh/latex/build-pdf @@ -0,0 +1,31 @@ +#!/bin/zsh +_DEPENDENCIES+=( + pdflatex + rg +) +_REQUIRED_ENV+=() +source ${0:a:h}/common.zsh +##################################################################### + +PDFLATEX() { + [ ! $1 ] && __FAIL 1 'must provide filename' + local FILENAME=$(GET_MAIN_LATEX_FILENAME "$1") + + local ARGS=(-interaction=nonstopmode) + ARGS+=("$FILENAME") + + cd "$(dirname $FILENAME)" + + __STATUS 'running compile (1/2)' + pdflatex ${ARGS[@]} \ + || __FAIL 2 'first compile failed (see above)' + + __STATUS 'running compile (2/2)' + pdflatex ${ARGS[@]} >/dev/null 2>&1 \ + || __FAIL 3 'second compile failed :c' + + __SUCCESS "created '$(echo $FILENAME | sed 's/\.[^.]*$/.pdf/')'" +} + +##################################################################### +PDFLATEX $@ diff --git a/zsh/latex/cleanup b/zsh/latex/cleanup new file mode 100755 index 0000000..28fc576 --- /dev/null +++ b/zsh/latex/cleanup @@ -0,0 +1,20 @@ +#!/bin/zsh +_DEPENDENCIES+=() +_REQUIRED_ENV+=() +source ${0:a:h}/common.zsh +##################################################################### + +CLEAN_LATEX_LOGFILES() { + local DIRECTORY=$(__GET_PATH_TO_RELATIVE_ARGUMENT ".") + [ $1 ] && DIRECTORY="$(dirname "$(GET_MAIN_LATEX_FILENAME "$1")")" + [ $DIRECTORY ] && [ -d $DIRECTORY ] \ + || __FAIL 1 'unable to parse valid directory' + + cd $DIRECTORY + rm $(ls | grep '\.\(aux\)\|\(log\)\|\(pdf\)\|\(out\)\|\(dvi\)$') + + __SUCCESS "cleaned up latex artifacts in '$DIRECTORY'" +} + +##################################################################### +CLEAN_LATEX_LOGFILES $@ diff --git a/zsh/latex/common.zsh b/zsh/latex/common.zsh new file mode 100644 index 0000000..d91aa77 --- /dev/null +++ b/zsh/latex/common.zsh @@ -0,0 +1,34 @@ +_DEPENDENCIES+=( + rg +) +_REQUIRED_ENV+=() +source ${0:a:h}/../common.zsh +##################################################################### + +GET_MAIN_LATEX_FILENAME() { + local FILENAME=$(__GET_PATH_TO_RELATIVE_ARGUMENT "$1") + local DIRNAME="$FILENAME" + + for _ in {1..3} + do + CHECK_IS_MAIN_LATEX_FILE && return 0 + DIRNAME="$(dirname "$FILENAME")" + __STATUS "checking '$DIRNAME'" + [[ $DIRNAME =~ ^$HOME$ ]] && break + FILENAME=$( + rg -l --max-depth 1 'documentclass' "$DIRNAME/" \ + | grep '\.tex$' \ + | head -n1 \ + ) + __STATUS "here is '$FILENAME'" + done + + __WARNING 'unable to find documentclass; pdflatex will probably fail' + echo "$1" +} + +CHECK_IS_MAIN_LATEX_FILE() { + [ ! $FILENAME ] && return 1 + grep -q 'documentclass' $FILENAME 2>/dev/null && echo $FILENAME || return 3 +} + diff --git a/zsh/latex/create-new b/zsh/latex/create-new new file mode 100755 index 0000000..1cee37a --- /dev/null +++ b/zsh/latex/create-new @@ -0,0 +1,63 @@ +#!/bin/zsh +_DEPENDENCIES+=( + pdflatex + rg +) +_REQUIRED_ENV+=() + +TEMPLATE_DIR="${0:a:h}/templates" + +source ${0:a:h}/common.zsh +##################################################################### + +CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE() { + local DOCUMENT_DIR="$EXECUTION_DIR" + local TEMPLATE=$(GET_TEMPLATES | __FZF 'select a template') + [ ! $TEMPLATE ] && __ABORT + __SUCCESS "selected template '$TEMPLATE'" + + __INPUT DOC_TITLE 'document title' || __ABORT + + local DOCUMENT_FILE="$DOCUMENT_DIR/$(SLUGIFY_TITLE).tex" + [ -f "$DOCUMENT_FILE" ] && __FAIL 1 "'$(basename $DOCUMENT_FILE)' already exists" + + __INPUT DOC_ID 'document id/subtitle' + __INPUT AUTHOR 'author name' + __INPUT AUTHOR_ID 'author id/title' + + { + PRINT_TITLE_INFO + cat "$TEMPLATE_DIR/$TEMPLATE/template.tex" + } > "$DOCUMENT_FILE" + cp "$TEMPLATE_DIR/gitignore" "$DOCUMENT_DIR/.gitignore" + for FILE in $(find "$TEMPLATE_DIR/$TEMPLATE" -type f | grep -v '/template.tex$') + do + cp "$FILE" "$DOCUMENT_DIR/" || return 2 + done + [[ ! $TEMPLATE =~ ^basic$ ]] \ + && mkdir "$DOCUMENT_DIR/sections" "$DOCUMENT_DIR/graphics" + + __SUCCESS "finished generating '$(basename $DOCUMENT_FILE)' from '$TEMPLATE'" +} + +GET_TEMPLATES() { + find "$TEMPLATE_DIR" -type d | sed "s^$TEMPLATE_DIR/*^^; /^$/d" +} + +PRINT_TITLE_INFO() { + local DATESTRING=$(date '+%B %_d, %Y' | sed 's/ \{1,\}/ /g') + sed " + s^LATEX-DOC-TITLE^$DOC_TITLE^ + s^LATEX-DOC-DATE^$DATESTRING^ + s^LATEX-DOC-ID^$DOC_ID^ + s^LATEX-AUTHOR-NAME^$AUTHOR^ + s^LATEX-AUTHOR-ID^$AUTHOR_ID^ + " "$TEMPLATE_DIR/main.tex" +} + +SLUGIFY_TITLE() { + echo $DOC_TITLE | sed "s^['\"\\/,\!@#\$%^&*()]*^^g; s^\s\+^-^g;" +} + +##################################################################### +CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE $@ diff --git a/zsh/latex/get-pdf b/zsh/latex/get-pdf new file mode 100755 index 0000000..42a776c --- /dev/null +++ b/zsh/latex/get-pdf @@ -0,0 +1,15 @@ +#!/bin/zsh +_DEPENDENCIES+=() +_REQUIRED_ENV+=() +source ${0:a:h}/common.zsh +##################################################################### + +GET_PDF() { + local FILENAME=$(GET_MAIN_LATEX_FILENAME "$1" | sed 's/\.[^.]*$/.pdf/') + [ $FILENAME ] && [ -f $FILENAME ] || __FAIL 1 "no compiled pdf found for '$1'; have you run 'build-pdf'?" + __SUCCESS 'found main pdf' + echo $FILENAME +} + +##################################################################### +GET_PDF $@ diff --git a/zsh/latex/open-pdf b/zsh/latex/open-pdf new file mode 100755 index 0000000..9343eaf --- /dev/null +++ b/zsh/latex/open-pdf @@ -0,0 +1,15 @@ +#!/bin/zsh +_DEPENDENCIES+=() +_REQUIRED_ENV+=() +source ${0:a:h}/common.zsh +##################################################################### + +OPEN_PDF() { + local PDF=$(__RUN_SCWRYPT latex/get-pdf -n -- $1) + [ ! $PDF ] && return 1 + + __OPEN "$PDF" +} + +##################################################################### +OPEN_PDF $@ diff --git a/zsh/latex/templates/basic/template.tex b/zsh/latex/templates/basic/template.tex new file mode 100644 index 0000000..2b79211 --- /dev/null +++ b/zsh/latex/templates/basic/template.tex @@ -0,0 +1,37 @@ +\usepackage[margin=.75in,bottom=0.5in,top=1.0in]{geometry} + +\usepackage{enumitem} +\usepackage{fancyhdr} +\usepackage{hyperref} +\usepackage{lastpage} + +\newcommand{\headerL} {\documentTitle: \documentDate} +\newcommand{\headerC} {\documentId} +\newcommand{\headerR} {\authorName\ (\authorId)} +\newcommand{\pageOfTotal} {\thepage\ of~\pageref{LastPage}} + +\pagestyle{fancy} +\fancypagestyle{plain}{% + \fancyhf{} + \fancyhead[L]{\headerL}\fancyhead[R]{\headerR}\fancyhead[C]{\headerC} + \fancyfoot[C]{\pageOfTotal} +} + +\renewcommand{\baselinestretch}{1} +\setlength{\parskip}{0em} +\hyphenpenalty=5000% + +\fancyhf{} +\fancyhead[L]{\headerL}\fancyhead[R]{\headerR}\fancyhead[C]{\headerC} +\fancyfoot[C]{\pageOfTotal} + +\title{\documentTitle} +\author{\authorName\ \\ \authorId} +\date{\documentDate} + +\begin{document} +\maketitle% +% --------------------------------------------------------------------- + +% --------------------------------------------------------------------- +\end{document} diff --git a/zsh/latex/templates/gitignore b/zsh/latex/templates/gitignore new file mode 100644 index 0000000..d41eaa3 --- /dev/null +++ b/zsh/latex/templates/gitignore @@ -0,0 +1,5 @@ +*.aux +*.log +*.out +*.pdf +*.dvi diff --git a/zsh/latex/templates/main.tex b/zsh/latex/templates/main.tex new file mode 100644 index 0000000..16ba717 --- /dev/null +++ b/zsh/latex/templates/main.tex @@ -0,0 +1,9 @@ +\documentclass[letterpaper]{article} + +\newcommand{\documentTitle} {LATEX-DOC-TITLE} +\newcommand{\documentDate} {LATEX-DOC-DATE} +\newcommand{\documentId} {LATEX-DOC-ID} + +\newcommand{\authorName} {LATEX-AUTHOR-NAME} +\newcommand{\authorId} {LATEX-AUTHOR-ID} + diff --git a/zsh/latex/templates/math/code.sty b/zsh/latex/templates/math/code.sty new file mode 100644 index 0000000..9cc6e16 --- /dev/null +++ b/zsh/latex/templates/math/code.sty @@ -0,0 +1,11 @@ +\ProvidesPackage{code} +% --------------------------------------------------------------------- + +\newcommand{\clispsnippet}[2]{% + \lstinputlisting[% + caption=#1, + language=Lisp, + showstringspaces=false, + numbers=left, + ]{#2} +} diff --git a/zsh/latex/templates/math/formatting.sty b/zsh/latex/templates/math/formatting.sty new file mode 100644 index 0000000..8781a68 --- /dev/null +++ b/zsh/latex/templates/math/formatting.sty @@ -0,0 +1,46 @@ +\ProvidesPackage{formatting} +% --------------------------------------------------------------------- + +\newcommand{\headerLeft} {\documentTitle: \documentDate} +\newcommand{\headerCenter} {\documentId} +\newcommand{\headerRight} {\authorName\ (\authorId)} +\newcommand{\pageOfTotal} {\thepage\ of~\pageref{LastPage}} + +\newtheorem{theorem}{Theorem}[section] +\newtheorem{lemma}[theorem]{Lemma} +\newtheorem{corollary}{Corollary}[theorem] + +\RequirePackage[margin=1in,bottom=.5in,includefoot]{geometry} +\RequirePackage{lastpage} +\RequirePackage{fancyhdr} + +% --------------------------------------------------------------------- +% Page 1 + +\pagestyle{fancy} +\fancypagestyle{plain}{% + \fancyhf{} + \fancyhead[L]{\headerLeft} + \fancyhead[R]{\headerRight} + \fancyhead[C]{\headerCenter} + \fancyfoot[C]{\pageOfTotal} +} + +\renewcommand{\baselinestretch}{1} +\setlength{\parskip}{0em} +\setlength{\parindent}{0em} + +% --------------------------------------------------------------------- +% Pages 2+ + +\fancyhf{} +\fancyhead[L]{\headerLeft} +\fancyhead[R]{\headerRight} +\fancyhead[C]{\headerCenter} +\fancyfoot[C]{\pageOfTotal} + +% --------------------------------------------------------------------- + +\title{\documentTitle} +\author{\authorName\ \\ \authorId} +\date{\documentDate} diff --git a/zsh/latex/templates/math/gitignore b/zsh/latex/templates/math/gitignore new file mode 100644 index 0000000..e69de29 diff --git a/zsh/latex/templates/math/imports.sty b/zsh/latex/templates/math/imports.sty new file mode 100644 index 0000000..8027bc9 --- /dev/null +++ b/zsh/latex/templates/math/imports.sty @@ -0,0 +1,16 @@ +\ProvidesPackage{imports} +% --------------------------------------------------------------------- + +\RequirePackage{amssymb} % "bold" math letters (e.g. set of integers ℤ) +\RequirePackage{amsmath} % advanced math symbols + +\RequirePackage{listings} % code snippet styling block + +\RequirePackage{tikz} % graphic drawing / generation +\usetikzlibrary{arrows,automata} +\usetikzlibrary{trees} + +\RequirePackage{graphicx} % include images +\graphicspath{{./graphics/}} + +\RequirePackage[english]{babel} % -- English compilation rules diff --git a/zsh/latex/templates/math/shorthand.sty b/zsh/latex/templates/math/shorthand.sty new file mode 100644 index 0000000..103aefc --- /dev/null +++ b/zsh/latex/templates/math/shorthand.sty @@ -0,0 +1,13 @@ +\ProvidesPackage{shorthand} +% --------------------------------------------------------------------- + +\newcommand{\egfcoefficient}{\ensuremath{\left[\frac{x^n}{n!}\right]}} +\newcommand{\ogfcoefficient}{\ensuremath{\left[x^n\right]}} +\newcommand{\falling}[1]{^{\underline{#1}}} +\newcommand{\divides}{\ensuremath{\;\backslash\;}} + +\newcommand{\sumgz}{\ensuremath{\sum_{n\geq 0}}} +\newcommand{\sumdiv}{\ensuremath{\sum_{d\divides n}}} + +\newcommand{\union}{\ensuremath{\cup}} +\newcommand{\intersect}{\ensuremath{\cap}} diff --git a/zsh/latex/templates/math/template.tex b/zsh/latex/templates/math/template.tex new file mode 100644 index 0000000..afae7d1 --- /dev/null +++ b/zsh/latex/templates/math/template.tex @@ -0,0 +1,12 @@ +\usepackage{imports} +\usepackage{formatting} +\usepackage{shorthand} +\usepackage{code} + +\begin{document} +\maketitle +% --------------------------------------------------------------------- +% \input{sections/01.introduction.tex} +% \includegraphic{graphics/diagram-a.png} +% --------------------------------------------------------------------- +\end{document} diff --git a/zsh/latex/templates/times-new-roman-12/custom-headers.sty b/zsh/latex/templates/times-new-roman-12/custom-headers.sty new file mode 100644 index 0000000..9dd0034 --- /dev/null +++ b/zsh/latex/templates/times-new-roman-12/custom-headers.sty @@ -0,0 +1,7 @@ +\ProvidesPackage{custom-headers} +% --------------------------------------------------------------------- + +\newcommand{\firstH}[1] {\begin{large}\textbf{#1}\end{large}\par} +\newcommand{\secondH}[1] {\textbf{#1}\par} +\newcommand{\thirdH}[1] {\textbf{#1}. } +\newcommand{\fourthH}[1] {\textbf{\textit{#1}}. } diff --git a/zsh/latex/templates/times-new-roman-12/formatting.sty b/zsh/latex/templates/times-new-roman-12/formatting.sty new file mode 100644 index 0000000..2f3b2a1 --- /dev/null +++ b/zsh/latex/templates/times-new-roman-12/formatting.sty @@ -0,0 +1,31 @@ +\ProvidesPackage{formatting} +% --------------------------------------------------------------------- + +\newcommand{\horizontalHeader} {% + \authorName\hfill + \authorId\hfill + \documentId\hfill + \documentDate% +} + +\RequirePackage[margin=1in]{geometry} +\RequirePackage{fancyhdr} + +% --------------------------------------------------------------------- + +\pagestyle{fancy} +\renewcommand{\headrulewidth}{0pt} +\fancyhead[C]{\horizontalHeader} +\fancyfoot[C]{\thepage} + +\renewcommand{\baselinestretch}{1} +\setlength{\parskip}{1em} +\setlength{\parindent}{0em} +\raggedright% + +% --------------------------------------------------------------------- + +\newcommand{\insertTitle} {% + \centerline{\begin{large}\textbf{\documentTitle}\end{large}} +} + diff --git a/zsh/latex/templates/times-new-roman-12/imports.sty b/zsh/latex/templates/times-new-roman-12/imports.sty new file mode 100644 index 0000000..e166963 --- /dev/null +++ b/zsh/latex/templates/times-new-roman-12/imports.sty @@ -0,0 +1,11 @@ +\ProvidesPackage{imports} +% --------------------------------------------------------------------- + +\RequirePackage{times} % "Times New Roman" font + +\RequirePackage{kantlipsum} % generate Kantian lorem ipsum + +\RequirePackage{graphicx} % include images +\graphicspath{{./graphics/}} + +\RequirePackage[english]{babel} % -- English compilation rules diff --git a/zsh/latex/templates/times-new-roman-12/template.tex b/zsh/latex/templates/times-new-roman-12/template.tex new file mode 100644 index 0000000..1654e12 --- /dev/null +++ b/zsh/latex/templates/times-new-roman-12/template.tex @@ -0,0 +1,15 @@ +\usepackage{imports} +\usepackage{formatting} +\usepackage{custom-headers} + +\begin{document} +\insertTitle% +% --------------------------------------------------------------------- + +% \input{sections/abstract.tex} +% \includgraphics{graphics/table-a.png} +\firstH{First-level Header} +\kant% + +% --------------------------------------------------------------------- +\end{document} diff --git a/zsh/utils/dependencies.zsh b/zsh/utils/dependencies.zsh index f738b10..558c28a 100644 --- a/zsh/utils/dependencies.zsh +++ b/zsh/utils/dependencies.zsh @@ -17,7 +17,7 @@ __CHECK_DEPENDENCY() { } __CHECK_COREUTILS() { - local COREUTILS=(awk find grep sed) + local COREUTILS=(awk find grep sed readlink) local MISSING_DEPENDENCY_COUNT=0 local NON_GNU_DEPENDENCY_COUNT=0 diff --git a/zsh/utils/io.zsh b/zsh/utils/io.zsh index c89c704..9b1a24e 100644 --- a/zsh/utils/io.zsh +++ b/zsh/utils/io.zsh @@ -23,6 +23,13 @@ __PROMPT() { __FAIL() { __ERROR "${@:2}"; exit $1; } __ABORT() { __FAIL 69 'user abort'; } +__INPUT() { + __PROMPT "${@:2}" + __READ $1 + local VALUE=$(eval echo '$'$1) + [ $VALUE ] +} + __Yn() { __PROMPT "$@ [Yn]" [ $CI ] && { echo y; return 0; }