]> Sergey Matveev's repositories - nnn.git/commitdiff
Take notes with N
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 19 Jan 2019 09:08:47 +0000 (14:38 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 19 Jan 2019 09:21:40 +0000 (14:51 +0530)
README.md
nnn.1
src/nnn.c
src/nnn.h

index a6c2d06f793ba3da44ac7ff1b33ead053cb1427b..68a14ae60fab6f6d5d502f868dbbdb2bf5c6245f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ Noice is Not Noice, a noicer fork...
 
 <p align="center"><i>nnn in action! (Thanks Luke Smith for the video!)</i></a></p>
 
-`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 <kbd>?</kbd> 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 5307b2fe31714c5f6d6dc07f1c2818007828e985..c444659a8e69b5cddcc0481f43d62ca433bdd585 100644 (file)
--- 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
index 923e121e1d4f61653f0489208f732d5473698ad2..65f6c432a7ae413a34ebddbf4900bd146fca8bb6 100644 (file)
--- 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);
index 0c4ea74da89b924f03653b3637e24f466cde36f0..9a2930fb4e03d651124a9676aeb8e31d25c31002 100644 (file)
--- 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 */