Merge branch 'release/0.6'
This commit is contained in:
commit
64518e980a
|
@ -7,8 +7,10 @@ Memo organizes is structured through topics which are folders in `~/memo`.
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* add text to a topic to memorize it
|
* add text to a topic to memorize it
|
||||||
|
* remote topics
|
||||||
* search for strings in your memo-database
|
* search for strings in your memo-database
|
||||||
* copy/import files to topic folder.
|
* copy/import files to topic folder.
|
||||||
|
* git support
|
||||||
|
|
||||||
## Run
|
## Run
|
||||||
|
|
||||||
|
@ -19,7 +21,8 @@ Memo organizes is structured through topics which are folders in `~/memo`.
|
||||||
* tree
|
* tree
|
||||||
* ack
|
* ack
|
||||||
* man
|
* man
|
||||||
* pandoc
|
* git
|
||||||
|
* pandoc (optional)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ _memo(){
|
||||||
local cur opt prev
|
local cur opt prev
|
||||||
|
|
||||||
MEMO_FOLDER="${MEMO_DIR:-$HOME/memo}"
|
MEMO_FOLDER="${MEMO_DIR:-$HOME/memo}"
|
||||||
opts="add copy search show list"
|
opts="add rm copy search show list"
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
|
|
@ -7,18 +7,23 @@ function _memo {
|
||||||
_arguments \
|
_arguments \
|
||||||
"1:action:((
|
"1:action:((
|
||||||
add\:'add a text to a topic'
|
add\:'add a text to a topic'
|
||||||
|
rm\:'delete a topic folder with all its content'
|
||||||
copy\:'copy a file to a topic'
|
copy\:'copy a file to a topic'
|
||||||
search\:'search for text in all topics'
|
search\:'search for text in all topics'
|
||||||
show\:'show a topic'
|
show\:'show a topic'
|
||||||
edit\:'edit a topic'
|
edit\:'edit a topic'
|
||||||
list\:'print a list of all topics'
|
list\:'print a list of all topics'
|
||||||
|
git\:'run git command'
|
||||||
))" \
|
))" \
|
||||||
"*::arg:->args"
|
"*::arg:->args"
|
||||||
|
|
||||||
case $line[1] in
|
case $line[1] in
|
||||||
add|copy|show|edit)
|
add|rm|copy|show|edit)
|
||||||
_memo_topics
|
_memo_topics
|
||||||
;;
|
;;
|
||||||
|
git)
|
||||||
|
_git
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -31,3 +36,17 @@ function _memo_topics {
|
||||||
compadd -X "A vailable Topics" $topics
|
compadd -X "A vailable Topics" $topics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _git {
|
||||||
|
local -a subcommands
|
||||||
|
subcommands=(
|
||||||
|
"init:Initialize git repository"
|
||||||
|
"status:Status of git repository"
|
||||||
|
"push:Push to remote repository"
|
||||||
|
"pull:Pull from remote repository"
|
||||||
|
"config:Show git config"
|
||||||
|
"log:Show git log"
|
||||||
|
"reflog:Show git reflog"
|
||||||
|
)
|
||||||
|
_describe -t commands 'git' subcommands
|
||||||
|
}
|
||||||
|
|
||||||
|
|
19
doc/memo.1
19
doc/memo.1
|
@ -1,5 +1,5 @@
|
||||||
.\" Text automatically generated by txt2man
|
.\" Text automatically generated by txt2man
|
||||||
.TH memo 1 "17 May 2018" "doc" "Linux Reference Manual"
|
.TH memo 1 "10 August 2018" "doc" "Linux Reference Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
\fBmemo
|
\fBmemo
|
||||||
\fB
|
\fB
|
||||||
|
@ -30,6 +30,10 @@ adds text to the memo.md in the topic folder.
|
||||||
if text is not given it will read from stdin.
|
if text is not given it will read from stdin.
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
|
rm <topic>
|
||||||
|
remove $MEMO_DIR/topic folder with all it's content.
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
copy <topic> <file-to-copy>
|
copy <topic> <file-to-copy>
|
||||||
copy a file to the topic folder.
|
copy a file to the topic folder.
|
||||||
.TP
|
.TP
|
||||||
|
@ -49,6 +53,11 @@ opens your favorite editor to edit the \fBmemo\fP topic
|
||||||
.B
|
.B
|
||||||
list
|
list
|
||||||
prints a list of all topics.
|
prints a list of all topics.
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
git <command>
|
||||||
|
run git command in $MEMO_DIR.
|
||||||
|
Once $MEMO_DIR is a git repository all \fBmemo\fP commands create commits.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
|
|
||||||
|
@ -91,5 +100,13 @@ Copy the "Invoice.pdf" file to the "lawsuit" topic.
|
||||||
.fam C
|
.fam C
|
||||||
$> memo copy lawsuit ~/Downloads/Invoice.pdf
|
$> memo copy lawsuit ~/Downloads/Invoice.pdf
|
||||||
|
|
||||||
|
.fam T
|
||||||
|
.fi
|
||||||
|
Make $MEMO_DIR a git repository.
|
||||||
|
.PP
|
||||||
|
.nf
|
||||||
|
.fam C
|
||||||
|
$> memo git init
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ COMMANDS
|
||||||
add <topic> [text] adds text to the memo.md in the topic folder.
|
add <topic> [text] adds text to the memo.md in the topic folder.
|
||||||
if text is not given it will read from stdin.
|
if text is not given it will read from stdin.
|
||||||
|
|
||||||
|
rm <topic> remove $MEMO_DIR/topic folder with all it's content.
|
||||||
|
|
||||||
copy <topic> <file-to-copy> copy a file to the topic folder.
|
copy <topic> <file-to-copy> copy a file to the topic folder.
|
||||||
|
|
||||||
search <term-to-search> search for a term in $MEMO_DIR using ack.
|
search <term-to-search> search for a term in $MEMO_DIR using ack.
|
||||||
|
@ -28,6 +30,9 @@ COMMANDS
|
||||||
|
|
||||||
list prints a list of all topics.
|
list prints a list of all topics.
|
||||||
|
|
||||||
|
git <command> run git command in $MEMO_DIR.
|
||||||
|
Once $MEMO_DIR is a git repository all memo commands create commits.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CONFIGURATION
|
CONFIGURATION
|
||||||
|
@ -54,5 +59,9 @@ EXAMPLE
|
||||||
|
|
||||||
$> memo copy lawsuit ~/Downloads/Invoice.pdf
|
$> memo copy lawsuit ~/Downloads/Invoice.pdf
|
||||||
|
|
||||||
|
Make $MEMO_DIR a git repository.
|
||||||
|
|
||||||
|
$> memo git init
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
86
memo
86
memo
|
@ -9,9 +9,11 @@
|
||||||
ack_cmd=ack
|
ack_cmd=ack
|
||||||
man_cmd=man
|
man_cmd=man
|
||||||
tree_cmd=tree
|
tree_cmd=tree
|
||||||
|
git_cmd=git
|
||||||
# comment pandoc_cmd to fall back to cat
|
# comment pandoc_cmd to fall back to cat
|
||||||
pandoc_cmd=pandoc
|
pandoc_cmd=pandoc
|
||||||
|
|
||||||
|
|
||||||
# Script
|
# Script
|
||||||
|
|
||||||
MEMO_FOLDER="${MEMO_DIR:-$HOME/memo}"
|
MEMO_FOLDER="${MEMO_DIR:-$HOME/memo}"
|
||||||
|
@ -37,13 +39,72 @@ function precondition::provide_topic(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# git commands
|
||||||
|
#
|
||||||
|
|
||||||
|
IS_GIT_REPO=0
|
||||||
|
# check if it is a gitrepository
|
||||||
|
# use the IS_GIT_REPO variable to
|
||||||
|
# verify later if it is a git repo
|
||||||
|
function git:status(){
|
||||||
|
cd ${MEMO_FOLDER}
|
||||||
|
${git_cmd} status &> /dev/null
|
||||||
|
if [[ $? -eq 0 ]]
|
||||||
|
then
|
||||||
|
IS_GIT_REPO=1
|
||||||
|
else
|
||||||
|
IS_GIT_REPO=0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# run before commit
|
||||||
|
function git:add_all_topics(){
|
||||||
|
if [[ ${IS_GIT_REPO} -eq 1 ]]
|
||||||
|
then
|
||||||
|
cd ${MEMO_FOLDER}
|
||||||
|
${git_cmd} add .
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# make a commit
|
||||||
|
function git:commit(){
|
||||||
|
local message="${1:-blind commit}"
|
||||||
|
if [[ ${IS_GIT_REPO} -eq 1 ]]
|
||||||
|
then
|
||||||
|
cd ${MEMO_FOLDER}
|
||||||
|
${git_cmd} commit -m "${message}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function git:run_command(){
|
||||||
|
cd ${MEMO_FOLDER}
|
||||||
|
${git_cmd} $@
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# remove command
|
||||||
|
#
|
||||||
|
|
||||||
|
function remove_topic (){
|
||||||
|
topic_name=$1
|
||||||
|
#precondition::provide_topic ${topic_name}
|
||||||
|
topic_path=${MEMO_FOLDER}/${topic_name}
|
||||||
|
|
||||||
|
if [[ -d ${topic_path} ]]
|
||||||
|
then
|
||||||
|
rm -rf ${topic_path}
|
||||||
|
fi
|
||||||
|
|
||||||
|
git:add_all_topics
|
||||||
|
git:commit "edit : ${topic_name}"
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# edit command
|
# edit command
|
||||||
#
|
#
|
||||||
|
|
||||||
function edit_memo() {
|
function edit_topic () {
|
||||||
topic_name=$1
|
topic_name=$1
|
||||||
precondition::provide_topic ${topic_name}
|
precondition::provide_topic ${topic_name}
|
||||||
topic_path=${MEMO_FOLDER}/${topic_name}
|
topic_path=${MEMO_FOLDER}/${topic_name}
|
||||||
|
@ -56,6 +117,8 @@ function edit_memo() {
|
||||||
|
|
||||||
${EDITOR} ${topic_file}
|
${EDITOR} ${topic_file}
|
||||||
|
|
||||||
|
git:add_all_topics
|
||||||
|
git:commit "edit : ${topic_name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -83,6 +146,9 @@ EOF
|
||||||
cat >>${topic_file} -
|
cat >>${topic_file} -
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
git:add_all_topics
|
||||||
|
git:commit "add : ${topic_name}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,6 +184,9 @@ function copy_file(){
|
||||||
echo "copy '${path}' to '${topic_name}'"
|
echo "copy '${path}' to '${topic_name}'"
|
||||||
cp -r "${path}" ${topic_path}/
|
cp -r "${path}" ${topic_path}/
|
||||||
|
|
||||||
|
git:add_all_topics
|
||||||
|
git:commit "copy $( dirname ${path} ): ${topic_name}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,6 +293,9 @@ Commands:
|
||||||
so piping is possible.
|
so piping is possible.
|
||||||
Example: cat file.txt | memo add topic
|
Example: cat file.txt | memo add topic
|
||||||
|
|
||||||
|
rm <topic>
|
||||||
|
remove ${MEMO_FOLDER}/<topic> (with all its content)
|
||||||
|
|
||||||
copy <topic> <file to copy>
|
copy <topic> <file to copy>
|
||||||
copy a file to ${MEMO_FOLDER}/<topic>/
|
copy a file to ${MEMO_FOLDER}/<topic>/
|
||||||
|
|
||||||
|
@ -241,6 +313,9 @@ Commands:
|
||||||
list
|
list
|
||||||
prints a list of all topics
|
prints a list of all topics
|
||||||
|
|
||||||
|
git <command>
|
||||||
|
run git <command> in ${MEMO_FOLDER}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,6 +329,7 @@ command=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
precondition::provide_memo_folder
|
precondition::provide_memo_folder
|
||||||
|
git:status
|
||||||
|
|
||||||
case $command in
|
case $command in
|
||||||
add) add_memo $@
|
add) add_memo $@
|
||||||
|
@ -268,11 +344,17 @@ case $command in
|
||||||
show_topic $@
|
show_topic $@
|
||||||
;;
|
;;
|
||||||
edit)
|
edit)
|
||||||
edit_memo $@
|
edit_topic $@
|
||||||
;;
|
;;
|
||||||
list)
|
list)
|
||||||
list_topics
|
list_topics
|
||||||
;;
|
;;
|
||||||
|
git)
|
||||||
|
git:run_command $@
|
||||||
|
;;
|
||||||
|
rm)
|
||||||
|
remove_topic $@
|
||||||
|
;;
|
||||||
*) show_help
|
*) show_help
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue