Stop displaying usage everytime - notes - a console notes manager using git
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR LICENSE
---
DIR commit cee1836f8f24b0630210aa0958dafe10821ab764
DIR parent 50c7e26a5acf0153960eb30d30316cb7be21d320
HTML Author: Solene Rapenne <solene@perso.pw>
Date: Sat, 14 Jul 2018 12:08:59 +0200
Stop displaying usage everytime
Diffstat:
M notes | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
DIR diff --git a/notes b/notes
@@ -36,11 +36,13 @@ usage() {
': delete file' \
"$name [edit] PATH" \
": start \$EDITOR ($EDITOR) on file and auto commit"
+ exit 0
}
# display a file tree of notes taken
display() {
colortree -C --prune --noreport "$REPO"
+ exit 0
}
# edit a file given as parameter
@@ -52,6 +54,7 @@ edit() {
"$EDITOR" "$1"
git add "$1"
git commit -m "editing by $USER" "$1"
+ exit 0
else
printf 'Aborting: "%s" is a directory.\n' "$1"
exit 1
@@ -62,12 +65,14 @@ edit() {
histo() {
cd "$REPO"
tig "$1"
+ exit 0
}
# output the content of a file
show_file() {
cd "$REPO"
cat "$1"
+ exit 0
}
# delete a file and commit in git
@@ -77,6 +82,7 @@ delete() {
then
git rm "$1"
git commit -m "deleted by $USER" "$1"
+ exit 0
else
printf 'Aborting: "%s" is a directory.\n' "$1"
exit 1
@@ -96,6 +102,7 @@ last() {
printf("%20s: %s\n", date, file)
}
}'
+ exit 0
}
# raw list of files for completion
@@ -104,6 +111,7 @@ _completion_list() {
then
cd "$REPO"
find . -name '.git' -prune -o -mindepth 2 -type f -print | sed 's,^\./,,'
+ exit 0
else
printf 'Aborting: "%s" does not exist.\n' "$REPO"
exit 4
@@ -119,6 +127,7 @@ initialization() {
exit 3
else
git init
+ exit 0
fi
}
@@ -132,10 +141,10 @@ case "$1" in
"ls") display ;;
"i*") initialization ;;
"la*") last ;;
- "e*") [ -n "$2" ] && edit "$2" ;;
- "hi*") [ -n "$2" ] && histo "$2" ;;
- "c*") [ -n "$2" ] && show_file "$2" ;;
+ "e*") [ -n "$2" ] && edit "$2" ;;
+ "hi*") [ -n "$2" ] && histo "$2" ;;
"r*") [ -n "$2" ] && delete "$2" ;;
+ "c*") [ -n "$2" ] && show_file "$2" ;;
"_files") _completion_list ;;
esac