From 366f49e6b3ad73f330e04bbaf8020398292c0a3b Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sat, 19 Jan 2019 14:38:47 +0530 Subject: [PATCH] Take notes with N --- README.md | 7 ++++--- nnn.1 | 11 +++++++++-- src/nnn.c | 15 ++++++++++++++- src/nnn.h | 3 +++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a6c2d06f..68a14ae6 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Noice is Not Noice, a noicer fork...

nnn in action! (Thanks Luke Smith for the video!)

-`nnn` is probably the [fastest and most lightweight](#comparison) file manager you have ever used. It integrates seamlessly with your DE and favourite GUI utilities, has a unique [navigate-as-you-type](#navigate-as-you-type-mode) mode with auto-select, disk usage analyzer mode, bookmarks, contexts, application launcher, familiar navigation shortcuts, subshell spawning and much more. +`nnn` is probably the [fastest and most lightweight](#comparison) file manager you have ever used. It integrates seamlessly with your DE and favourite GUI utilities, has a unique [navigate-as-you-type](#navigate-as-you-type-mode) mode with auto-select, disk usage analyzer mode, bookmarks, contexts, application launcher, familiar navigation shortcuts, subshell spawning, quick notes and much more. Integrate utilities like sxiv (image preview) or fzy (fuzzy subtree search) easily, transfer selected files using lftp or use it as a (neo)vim plugin; `nnn` supports as many scripts as you need! Refer to the [How to](https://github.com/jarun/nnn/wiki/How-to) section on wiki for more details. @@ -104,6 +104,7 @@ It runs on Linux, macOS, Raspberry Pi, BSD, Cygwin, Linux subsystem for Windows - Run current file as executable - Change directory at exit (*easy* shell integration) - Edit file in EDITOR or open in PAGER + - Take quick notes - Terminal locker integration - Unicode support - Highly optimized, static analysis integrated code @@ -237,7 +238,7 @@ Press ? in `nnn` to see the list anytime. MISC !, ^] Spawn SHELL in dir C Execute entry R, ^V Run custom script L Lock terminal - ^S Run a command + ^S Run a command N Take note ``` Help & settings, file details, media info and archive listing are shown in the PAGER. Please use the PAGER-specific keys in these screens. @@ -275,7 +276,7 @@ When a context is quit, the next active context is selected. If the last active Each context can have its own color for directories specified: - export NNN_CONTEXT_COLORS="1234" + export NNN_CONTEXT_COLORS='1234' colors: 0-black, 1-red, 2-green, 3-yellow, 4-blue (default), 5-magenta, 6-cyan, 7-white #### Selection diff --git a/nnn.1 b/nnn.1 index 5307b2fe..c444659a 100644 --- a/nnn.1 +++ b/nnn.1 @@ -148,6 +148,8 @@ Execute entry Run or choose a custom script .It Ic L Lock terminal +.It Ic N +Take note .It Ic ^S Run a command .El @@ -278,7 +280,7 @@ files. .Pp \fBNNN_CONTEXT_COLORS:\fR string of color codes for each context, e.g.: .Bd -literal - export NNN_CONTEXT_COLORS="1234" + export NNN_CONTEXT_COLORS='1234' codes: 0-black, 1-red, 2-green, 3-yellow, 4-blue (default), 5-magenta, 6-cyan, 7-white .Ed @@ -292,13 +294,18 @@ files. The path is shown in the help and configuration screen. .Ed .Pp -\fBNNN_SCRIPT:\fR absolute path to a directory to select a script from or a single script to invoke with currently selected file name as argument 1. +\fBNNN_SCRIPT:\fR \fIabsolute\fR path to a directory to select a script from or a single script to invoke with currently selected file name as argument 1. .Bd -literal export NNN_SCRIPT=/home/user/scripts OR export NNN_SCRIPT=/usr/local/bin/nscript.sh .Ed .Pp +\fBNNN_NOTE:\fR \fIabsolute\fR path to a note file. +.Bd -literal + export NNN_NOTE='/home/user/.mynotes' +.Ed +.Pp \fBNNN_SHOW_HIDDEN:\fR show hidden files. .Bd -literal export NNN_SHOW_HIDDEN=1 diff --git a/src/nnn.c b/src/nnn.c index 923e121e..65f6c432 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -2120,7 +2120,7 @@ static bool show_help(char *path) "1MISC\n" "a!, ^] Spawn SHELL in dir C Execute entry\n" "aR, ^V Run custom script L Lock terminal\n" - "d^S Run a command\n"}; + "d^S Run a command N Take note\n"}; if (fd == -1) return FALSE; @@ -3068,6 +3068,7 @@ nochange: break; // fallthrough case SEL_REDRAW: // fallthrough case SEL_HELP: // fallthrough + case SEL_NOTE: // fallthrough case SEL_LOCK: { if (ndents) @@ -3100,11 +3101,23 @@ nochange: case SEL_RUNEDIT: if (!quote_run_sh_cmd(editor, dents[cur].name, path)) goto nochange; + r = TRUE; break; case SEL_RUNPAGE: r = TRUE; spawn(pager, pager_arg, dents[cur].name, path, F_NORMAL); break; + case SEL_NOTE: + tmp = getenv("NNN_NOTE"); + if (!tmp) { + printmsg("set NNN_NOTE"); + goto nochange; + } + + if (!quote_run_sh_cmd(editor, tmp, NULL)) + goto nochange; + r = TRUE; + break; default: /* SEL_LOCK */ r = TRUE; spawn(utils[LOCKER], NULL, NULL, NULL, F_NORMAL | F_SIGINT); diff --git a/src/nnn.h b/src/nnn.h index 0c4ea74d..9a2930fb 100644 --- a/src/nnn.h +++ b/src/nnn.h @@ -89,6 +89,7 @@ enum action { SEL_RUNCMD, SEL_RUNEDIT, SEL_RUNPAGE, + SEL_NOTE, SEL_LOCK, SEL_QUITCTX, SEL_QUITCD, @@ -225,6 +226,8 @@ static struct key bindings[] = { /* Open in EDITOR or PAGER */ { 'e', SEL_RUNEDIT }, { 'p', SEL_RUNPAGE }, + /* Open notes file */ + { 'N', SEL_NOTE }, /* Lock screen */ { 'L', SEL_LOCK }, /* Quit a context */