Improvements - notes - a console notes manager using git DIR Log DIR Files DIR Refs DIR Tags DIR LICENSE --- DIR commit 15b0eb8c733c9fff27256068ba210d3d904bfadb DIR parent 9ae53dab5cc029fd0bdb6aa122ae7f9e90259241 HTML Author: Solene Rapenne <solene@perso.pw> Date: Sat, 14 Jul 2018 00:08:24 +0200 Improvements Suggestions from Quentin Rameau and lgv Diffstat: M notes | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) --- DIR diff --git a/notes b/notes @@ -2,13 +2,13 @@ # tool for taking notes inside a git repository -test -z "$REPO" && REPO=~/notes/ +REPO=${REPO:=~/notes} # default editor to vi if [ -z "$EDITOR" ]; then - which nvim 2>/dev/null 1>/dev/null && EDITOR=nvim - test -z "$EDITOR" && which vim 2>/dev/null 1>/dev/null && EDITOR=vim - test -z "$EDITOR" && which emacs 2>/dev/null 1>/dev/null && EDITOR=emacs + type nvim >/dev/null 2>&1 && EDITOR=nvim + test -z "$EDITOR" && type vim >/dev/null 2>&1 && EDITOR=vim + test -z "$EDITOR" && type emacs >/dev/null 2>&1 && EDITOR=emacs test -z "$EDITOR" && EDITOR=vi fi @@ -120,7 +120,7 @@ _completion_list() { # create a git repo initialization() { - cd $REPO + cd "$REPO" if [ -d .git ] then echo "Git already initialized" @@ -130,25 +130,25 @@ initialization() { fi } -mkdir -p ${REPO} +mkdir -p "${REPO}" if [ $? -ne 0 ] then echo "Can't create ${REPO}. Aborting." exit 2 fi -PARAM1=$1 -PARAM2=$2 +PARAM1="$1" +PARAM2="$2" -if [ "$PARAM1" = "ls" ]; then display ; exit 0 ; fi -if [ "$PARAM1" = "init" ]; then initialization ; exit 0 ; fi -if [ "$PARAM1" = "" ]; then display ; exit 0 ; fi -if expr "$PARAM1" : "^hi" >/dev/null && [ -n "$PARAM2" ]; then histo "$PARAM2" ; exit 0 ; fi -if expr "$PARAM1" : "^c" >/dev/null && [ -n "$PARAM2" ]; then show_file "$PARAM2" ; exit 0 ; fi +if [ "$PARAM1" = "ls" ]; then display ; exit 0 ; fi +if [ "$PARAM1" = "init" ]; then initialization ; exit 0 ; fi +if [ "$PARAM1" = "" ]; then display ; exit 0 ; fi +if [ "$PARAM1" = "_files" ] ; then _completion_list ; exit 0 ; fi if [ "$PARAM1" = "rm" ] && [ -n "$PARAM2" ]; then delete "$PARAM2" ; exit 0 ; fi +if expr "$PARAM1" : "^hi" >/dev/null && [ -n "$PARAM2" ]; then histo "$PARAM2" ; exit 0 ; fi +if expr "$PARAM1" : "^c" >/dev/null && [ -n "$PARAM2" ]; then show_file "$PARAM2" ; exit 0 ; fi if expr "$PARAM1" : "^he" >/dev/null ; then usage ; exit 0 ; fi -if expr "$PARAM1" : "^l" >/dev/null ; then last; exit 0 ; fi -if [ "$PARAM1" = "_files" ] ; then _completion_list ; exit 0 ; fi +if expr "$PARAM1" : "^l" >/dev/null ; then last ; exit 0 ; fi if [ -f "${REPO}/${PARAM1}" ] ; then edit "$PARAM1" ; exit 0 ; fi