_files to get a list of files for autocompletion - notes - a console notes manager using git DIR Log DIR Files DIR Refs DIR Tags DIR LICENSE --- DIR commit f4c996c7032765c73fdce88c65d43c8d9844e34e DIR parent e5b96dbf99c8250f3b5287f5c0d75dd65640edd3 HTML Author: Solene Rapenne <solene@perso.pw> Date: Fri, 13 Jul 2018 18:47:45 +0200 _files to get a list of files for autocompletion Diffstat: M notes | 13 +++++++++++++ 1 file changed, 13 insertions(+), 0 deletions(-) --- DIR diff --git a/notes b/notes @@ -102,6 +102,18 @@ last() { }' } +# raw list of files for completion +_completion_list() { + if [ -d "$REPO" ] + then + cd "$REPO" + find . -name '.git' -prune -o -mindepth 2 -type f -print | sed 's,^\./,,' + else + echo "$REPO does not exist. Aborting..." + exit 4 + fi +} + # create a git repo initialization() { cd $REPO @@ -133,6 +145,7 @@ if expr "$PARAM1" : "^c" >/dev/null && [ -n "$PARAM2" ]; then show_file "$PARAM2 if [ "$PARAM1" = "rm" ] && [ -n "$PARAM2" ]; then delete "$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 [ -f "${REPO}/${PARAM1}" ] ; then edit "$PARAM1" ; exit 0 ; fi