Lot of fixes + man update - notes - a console notes manager using git DIR Log DIR Files DIR Refs DIR Tags DIR LICENSE --- DIR commit a17b04a52738103de48395d28fef14ec06008b64 DIR parent cea5b42c3c084d8ecd936c42a5a29bcf3b90da49 HTML Author: Solene Rapenne <solene@perso.pw> Date: Sat, 14 Jul 2018 20:35:06 +0200 Lot of fixes + man update Diffstat: M notes | 26 ++++++++++++++++++++------ M notes.1 | 38 ++++++++++++++++++------------- 2 files changed, 42 insertions(+), 22 deletions(-) --- DIR diff --git a/notes b/notes @@ -13,6 +13,7 @@ done if [ -z "$EDITOR" ]; then printf 'Could not elect an editor. ED is the standard text editor!\n' + EDITOR=ed exit 1 fi @@ -39,8 +40,15 @@ usage() { # display a file tree of notes taken display() { - colortree -C --prune --noreport "$REPO" - exit 0 + if type colortree >/dev/null 2>&1 + then + colortree -C --prune --noreport "$REPO" + exit 0 + else + cd "$REPO" + find . -name '.git' -prune -o -type f -print + exit 0 + fi } # edit a file given as parameter @@ -67,8 +75,14 @@ histo() { cd "$REPO" if [ -f "$1" ] then - tig "$1" - exit 0 + if type tig >/dev/null 2>&1 + then + tig "$1" + exit 0 + else + printf 'Aborting: tig software is needed for history\n' + exit 6 + fi else printf 'Aborting: "%s" file does not exist.\n' "$1" exit 5 @@ -117,7 +131,7 @@ _completion_list() { if [ -d "$REPO" ] then cd "$REPO" - find . -name '.git' -prune -o -type f -print | sed 's,^\./,,' + find ./${1} -name '.git' -prune -o -type f -print | sed 's,^\./,,' exit 0 else printf 'Aborting: "%s" does not exist.\n' "$REPO" @@ -153,7 +167,7 @@ case "$1" in hi*) [ -n "$2" ] && histo "$2" ;; r*) [ -n "$2" ] && delete "$2" ;; c*) [ -n "$2" ] && show_file "$2" ;; - _files) _completion_list ;; + _files) _completion_list "$2" ;; esac # if parameter doesn't match a command, it may be a file DIR diff --git a/notes.1 b/notes.1 @@ -23,20 +23,7 @@ The following commands are available: .It Nm Cm Op ls Show the repository tree with colours using .Xr colortree 1 -.It Nm Cm cat Ar file -Display the content of -.Ar file -on standard output -.It Nm Cm history Ar file -Execute -.Xr tig 1 -on -.Ar file -to display commit history. -.It Nm Cm last -display files and their last commit time ordered by time. - -This is useful to find which files have been modified lastly. +if the command is available or fallback to a simple file list. .It Nm Oo edit Oc file execute $EDITOR on .Ar file @@ -64,17 +51,36 @@ The edit parameter can be used if you need to edit a file which name correspond .Nm single argument command like in .Ql notes edit last +.It Nm Cm cat Ar file +Display the content of +.Ar file +on standard output. +.It Nm Cm history Ar file +Execute +.Xr tig 1 +on +.Ar file +to display commit history. +.It Nm Cm last +display files and their last commit time ordered by time. + +This is useful to find which files have been modified lastly. .It Nm Cm init Initialise the git repository using the command .Ql git --init .It Nm Cm help display the usage help -.It Nm Cm _list -return a raw list of files. This has been made to be run for shell completion. .It Nm Cm rm Ar file delete .Ar file and commit the deletion within git. +.It Nm Cm _list Op path +return a raw list of files. This has been made to provide a file list for shell completion. + +If +.Ar path +is set, then only files inside the path will be displayed. This can be useful if you want only +one folder from your tree. .Sh FILES .Bl -tag -width "~/notes" -compact .It Pa ~/notes