From efcf1ae26ad42005da8d79109067927a641a2758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Fri, 28 Dec 2018 16:52:54 +0100 Subject: [PATCH 1/4] Unify style --- memo | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/memo b/memo index c344591..d202297 100755 --- a/memo +++ b/memo @@ -18,7 +18,7 @@ pandoc_cmd=pandoc MEMO_FOLDER="${MEMO_DIR:-$HOME/memo}" -function precondition::provide_memo_folder(){ +function precondition:provide_memo_folder(){ if [[ ! -d ${MEMO_FOLDER} ]] then echo "create memo folder : ${MEMO_FOLDER}" @@ -26,7 +26,7 @@ function precondition::provide_memo_folder(){ fi } -function precondition::provide_topic(){ +function precondition:provide_topic(){ topic_name=$1 topic_path=${MEMO_FOLDER}/${topic_name} topic_file=${topic_path}/memo.md @@ -88,7 +88,7 @@ function git:run_command(){ function remove_topic (){ topic_name=$1 - #precondition::provide_topic ${topic_name} + #precondition:provide_topic ${topic_name} topic_path=${MEMO_FOLDER}/${topic_name} if [[ -d ${topic_path} ]] @@ -106,7 +106,7 @@ function remove_topic (){ function edit_topic () { topic_name=$1 - precondition::provide_topic ${topic_name} + precondition:provide_topic ${topic_name} topic_path=${MEMO_FOLDER}/${topic_name} if [[ -z ${EDITOR} ]] @@ -127,7 +127,7 @@ function edit_topic () { function add_memo(){ topic_name=$1 - precondition::provide_topic ${topic_name} + precondition:provide_topic ${topic_name} topic_path=${MEMO_FOLDER}/${topic_name} topic_file=${topic_path}/memo.md @@ -178,7 +178,7 @@ function copy_file(){ exit 1 fi - precondition::provide_topic ${topic_name} + precondition:provide_topic ${topic_name} topic_path=${MEMO_FOLDER}/${topic_name} echo "copy '${path}' to '${topic_name}'" @@ -328,7 +328,7 @@ EOF command=$1 shift -precondition::provide_memo_folder +precondition:provide_memo_folder git:status case $command in From 9685d713f2a8b5f2c418c78bb65b3810aeecf751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Fri, 28 Dec 2018 18:09:59 +0100 Subject: [PATCH 2/4] Generate man page with pandoc --- .gitignore | 1 + doc/memo.1 | 112 -------------------------------------------------- doc/memo.1.md | 71 ++++++++++++++++++++++++++++++++ doc/memo.txt | 67 ------------------------------ shell.nix | 13 ++++++ 5 files changed, 85 insertions(+), 179 deletions(-) delete mode 100644 doc/memo.1 create mode 100644 doc/memo.1.md delete mode 100644 doc/memo.txt create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 1377554..57f1248 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.swp +doc/memo.1 diff --git a/doc/memo.1 b/doc/memo.1 deleted file mode 100644 index e4c029f..0000000 --- a/doc/memo.1 +++ /dev/null @@ -1,112 +0,0 @@ -.\" Text automatically generated by txt2man -.TH memo 1 "10 August 2018" "doc" "Linux Reference Manual" -.SH NAME -\fBmemo -\fB -.SH SYNOPSIS -.nf -.fam C -\fBmemo\fP [\fIarguments\fP] - -.fam T -.fi -.fam T -.fi -.SH DESCRIPTION -A tool to memorize stuff. -It saves files $MEMO_DIR ($HOME/\fBmemo\fP by default). -The structure is $MEMO_DIR//memo.md -You can also copy files in the topic folder as well. -.PP -We call the folder $MEMO_DIR/ a 'topic folder'. -.RE -.PP - -.SH COMMANDS -.TP -.B -add [text] -adds text to the memo.md in the topic folder. -if text is not given it will read from stdin. -.TP -.B -rm -remove $MEMO_DIR/topic folder with all it's content. -.TP -.B -copy -copy a file to the topic folder. -.TP -.B -search -search for a term in $MEMO_DIR using ack. -.TP -.B -show -shows memo.md in the topic folder. -also showes a list of all files in the topic folder -.TP -.B -edit -opens your favorite editor to edit the \fBmemo\fP topic -.TP -.B -list -prints a list of all topics. -.TP -.B -git -run git command in $MEMO_DIR. -Once $MEMO_DIR is a git repository all \fBmemo\fP commands create commits. -.RE -.PP - - -.SH CONFIGURATION - -.TP -.B -$MEMO_DIR -holds the folder where to store the \fBmemo\fP files. -Default is $HOME/\fBmemo\fP -.TP -.B -$EDITOR -Your favorite editor. Must be set for the edit command -.SH EXAMPLE - - -Append the string "A search-engine" to the memo.md file -in the topic "google". -.PP -.nf -.fam C - $> memo add google A search-engine - -.fam T -.fi -Appends the content of "www.google.com" to the memo.md file -the topic "google". -.PP -.nf -.fam C - $> curl www.google.com | memo add google - -.fam T -.fi -Copy the "Invoice.pdf" file to the "lawsuit" topic. -.PP -.nf -.fam C - $> memo copy lawsuit ~/Downloads/Invoice.pdf - -.fam T -.fi -Make $MEMO_DIR a git repository. -.PP -.nf -.fam C - $> memo git init - - - diff --git a/doc/memo.1.md b/doc/memo.1.md new file mode 100644 index 0000000..2b75d90 --- /dev/null +++ b/doc/memo.1.md @@ -0,0 +1,71 @@ +% memo +% +% 10 August 2018 + +# NAME +memo + +# SYNOPSIS +`memo [arguments]` + +# DESCRIPTION +A tool to memorize stuff. +It saves files `$MEMO_DIR` (`$HOME/memo` by default). +The structure is `$MEMO_DIR//memo.md` +You can also copy files in the topic folder as well. + +We call the folder `$MEMO_DIR/` a 'topic folder'. + +# COMMANDS + +`add [text]` +: Adds text to the `memo.md` in the topic folder. If text is not given it will read from stdin. + +`rm ` +: Remove `$MEMO_DIR/topic` folder with all its content. + +`copy ` +: Copy a file to the topic folder. + +`search ` +: Search for a term in `$MEMO_DIR` using `ack`. + +`show ` +: Shows `memo.md` in the topic folder. Also shows a list of all files in the topic folder. + +`edit ` +: Opens your favorite editor to edit the memo topic. + +`list` +: Prints a list of all topics. + +`git ` +: Run a git command in `$MEMO_DIR`. Once `$MEMO_DIR` is a git repository, all memo commands create commits. + +# CONFIGURATION + +`$MEMO_DIR` +: holds the folder where to store the memo files. Default is `$HOME/memo`. + +`$EDITOR` +: Your favorite editor. Must be set for the edit command. + +# EXAMPLE + +Append the string "A search-engine" to the `memo.md` file +in the topic "google". + + $ memo add google A search-engine + +Appends the content of `www.google.com` to the `memo.md` file +the topic "google". + + $ curl www.google.com | memo add google + +Copy the "Invoice.pdf" file to the "lawsuit" topic. + + $ memo copy lawsuit ~/Downloads/Invoice.pdf + +Make `$MEMO_DIR` a git repository. + + $ memo git init diff --git a/doc/memo.txt b/doc/memo.txt deleted file mode 100644 index 0a141a0..0000000 --- a/doc/memo.txt +++ /dev/null @@ -1,67 +0,0 @@ -NAME - memo - -SYNOPSIS - memo [arguments] - -DESCRIPTION - A tool to memorize stuff. - It saves files $MEMO_DIR ($HOME/memo by default). - The structure is $MEMO_DIR//memo.md - You can also copy files in the topic folder as well. - - We call the folder $MEMO_DIR/ a 'topic folder'. - - -COMMANDS - add [text] adds text to the memo.md in the topic folder. - if text is not given it will read from stdin. - - rm remove $MEMO_DIR/topic folder with all it's content. - - copy copy a file to the topic folder. - - search search for a term in $MEMO_DIR using ack. - - show shows memo.md in the topic folder. - also showes a list of all files in the topic folder - - edit opens your favorite editor to edit the memo topic - - list prints a list of all topics. - - git run git command in $MEMO_DIR. - Once $MEMO_DIR is a git repository all memo commands create commits. - - - -CONFIGURATION - - $MEMO_DIR holds the folder where to store the memo files. - Default is $HOME/memo - - $EDITOR Your favorite editor. Must be set for the edit command - -EXAMPLE - - - Append the string "A search-engine" to the memo.md file - in the topic "google". - - $> memo add google A search-engine - - Appends the content of "www.google.com" to the memo.md file - the topic "google". - - $> curl www.google.com | memo add google - - Copy the "Invoice.pdf" file to the "lawsuit" topic. - - $> memo copy lawsuit ~/Downloads/Invoice.pdf - - Make $MEMO_DIR a git repository. - - $> memo git init - - - diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..acf295d --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +{ pkgs ? import {} }: +let manPath = doc/memo.1; +in pkgs.stdenv.mkDerivation { + name = "memo"; + buildInputs = [ + (pkgs.writeShellScriptBin "make-man" '' + ${pkgs.pandoc}/bin/pandoc --standalone --to man -o ${toString manPath} doc/memo.1.md + '') + (pkgs.writeShellScriptBin "view-man" '' + ${pkgs.man-db}/bin/man ${toString manPath} + '') + ]; +} From 19e7fd869cb5a3d84f3cd599e93d2594b4dc847b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Fri, 28 Dec 2018 18:23:47 +0100 Subject: [PATCH 3/4] doc: Add man headers and footers --- doc/memo.1.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/memo.1.md b/doc/memo.1.md index 2b75d90..05342c9 100644 --- a/doc/memo.1.md +++ b/doc/memo.1.md @@ -1,6 +1,10 @@ -% memo -% -% 10 August 2018 +--- +title: memo +date: 10 August 2018 +header: Linux Reference Manual +footer: doc +section: 1 +... # NAME memo From 6555e951113dd916fa51eacd52131c815b1839e2 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Mon, 31 Dec 2018 02:50:13 +0100 Subject: [PATCH 4/4] add add manpage again --- .gitignore | 1 - doc/memo.1 | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 doc/memo.1 diff --git a/.gitignore b/.gitignore index 57f1248..1377554 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ *.swp -doc/memo.1 diff --git a/doc/memo.1 b/doc/memo.1 new file mode 100644 index 0000000..cd3a139 --- /dev/null +++ b/doc/memo.1 @@ -0,0 +1,111 @@ +.\" Automatically generated by Pandoc 2.2.1 +.\" +.TH "memo" "1" "10 August 2018" "doc" "Linux Reference Manual" +.hy +.SH NAME +.PP +memo +.SH SYNOPSIS +.PP +\f[C]memo\ \ [arguments]\f[] +.SH DESCRIPTION +.PP +A tool to memorize stuff. +It saves files \f[C]$MEMO_DIR\f[] (\f[C]$HOME/memo\f[] by default). +The structure is \f[C]$MEMO_DIR//memo.md\f[] You can also copy +files in the topic folder as well. +.PP +We call the folder \f[C]$MEMO_DIR/\f[] a `topic folder'. +.SH COMMANDS +.TP +.B \f[C]add\ \ [text]\f[] +Adds text to the \f[C]memo.md\f[] in the topic folder. +If text is not given it will read from stdin. +.RS +.RE +.TP +.B \f[C]rm\ \f[] +Remove \f[C]$MEMO_DIR/topic\f[] folder with all its content. +.RS +.RE +.TP +.B \f[C]copy\ \ \f[] +Copy a file to the topic folder. +.RS +.RE +.TP +.B \f[C]search\ \f[] +Search for a term in \f[C]$MEMO_DIR\f[] using \f[C]ack\f[]. +.RS +.RE +.TP +.B \f[C]show\ \f[] +Shows \f[C]memo.md\f[] in the topic folder. +Also shows a list of all files in the topic folder. +.RS +.RE +.TP +.B \f[C]edit\ \f[] +Opens your favorite editor to edit the memo topic. +.RS +.RE +.TP +.B \f[C]list\f[] +Prints a list of all topics. +.RS +.RE +.TP +.B \f[C]git\ \f[] +Run a git command in \f[C]$MEMO_DIR\f[]. +Once \f[C]$MEMO_DIR\f[] is a git repository, all memo commands create +commits. +.RS +.RE +.SH CONFIGURATION +.TP +.B \f[C]$MEMO_DIR\f[] +holds the folder where to store the memo files. +Default is \f[C]$HOME/memo\f[]. +.RS +.RE +.TP +.B \f[C]$EDITOR\f[] +Your favorite editor. +Must be set for the edit command. +.RS +.RE +.SH EXAMPLE +.PP +Append the string \[lq]A search\-engine\[rq] to the \f[C]memo.md\f[] +file in the topic \[lq]google\[rq]. +.IP +.nf +\f[C] +$\ memo\ add\ google\ A\ search\-engine +\f[] +.fi +.PP +Appends the content of \f[C]www.google.com\f[] to the \f[C]memo.md\f[] +file the topic \[lq]google\[rq]. +.IP +.nf +\f[C] +$\ curl\ www.google.com\ |\ memo\ add\ google +\f[] +.fi +.PP +Copy the \[lq]Invoice.pdf\[rq] file to the \[lq]lawsuit\[rq] topic. +.IP +.nf +\f[C] +$\ memo\ copy\ lawsuit\ ~/Downloads/Invoice.pdf +\f[] +.fi +.PP +Make \f[C]$MEMO_DIR\f[] a git repository. +.IP +.nf +\f[C] +$\ memo\ git\ init +\f[] +.fi