]> Sergey Matveev's repositories - nnn.git/commitdiff
Add plugin to take quick notes
authorArun Prakash Jana <engineerarun@gmail.com>
Thu, 26 Sep 2019 14:26:43 +0000 (19:56 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Thu, 26 Sep 2019 14:26:43 +0000 (19:56 +0530)
README.md
nnn.1
plugins/README.md
plugins/notes [new file with mode: 0755]
src/nnn.c
src/nnn.h

index 06f25b757932fdda5963d3c18b811824c7a8f131..68eb2ac92afa507e3a24f6f0033731159ab8f270 100644 (file)
--- a/README.md
+++ b/README.md
@@ -87,7 +87,7 @@ Visit the **[Wiki](https://github.com/jarun/nnn/wiki)** for operational concepts
   - Create, rename, duplicate files and directories
   - Per-context directory color (default: blue)
   - Spawn a shell, run apps, run commands, execute file
-  - Take quick notes, lock terminal (needs a locker)
+  - Lock terminal (needs a locker)
   - Shortcut reference a keypress away
 - Unicode support
 - Follows Linux kernel coding style
@@ -179,7 +179,6 @@ Option completion scripts for Bash, Fish and Zsh can be found in respective subd
 | `NNN_USE_EDITOR=1` | open text files in `$VISUAL` (else `$EDITOR`, fallback vi) |
 | `NNN_CONTEXT_COLORS='1234'` | specify per context color [default: '4444' (all blue)] |
 | `NNN_SSHFS_OPTS='sshfs -o reconnect,idmap=user'` | specify SSHFS options |
-| `NNN_NOTE='/home/user/Dropbox/notes'` | absolute path to note file [default: none] |
 | `NNN_OPENER=mimeopen` | custom file opener |
 | `NNN_IDLE_TIMEOUT=300` | idle seconds to lock terminal [default: disabled] |
 | `NNN_COPIER=copier` | clipboard copier script [default: none] |
@@ -246,10 +245,10 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
             S  du                A  Apparent du
             s  Size    E  Extn   t  Time modified
  MISC
-         ! ^]  Shell   ^N  Note  L  Lock
+         ! ^]  Shell             =  Launcher
          R ^V  Pick plugin   :K xK  Run plugin key K
             c  SSHFS mount       u  Unmount
-           ^P  Prompt/run expr   =  Launcher
+           ^P  Prompt/run expr   L  Lock
 ```
 
 Note: Help & settings, file details and archive listing are shown in the PAGER. Use the PAGER-specific keys in these screens.
diff --git a/nnn.1 b/nnn.1
index a0fdfac96550f90557971ea327fa1ed0c48375c4..d74b84865f28b16431b6adbdfda80844d9de41b9 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -182,11 +182,6 @@ when dealing with the !, e and p commands respectively. A single combination to
     NOTE: The options must be preceded by `sshfs` and comma-separated without any space between them.
 .Ed
 .Pp
-\fBNNN_NOTE:\fR \fIabsolute\fR path to a note file.
-.Bd -literal
-    export NNN_NOTE='/home/user/.mynotes'
-.Ed
-.Pp
 \fBNNN_OPENER:\fR specify a custom file opener.
 .Bd -literal
     export NNN_OPENER=mimeopen
index 3ddbcf89d93582053cee66c4f8b377fa079f9751..ace537504b20e05f998537077fd87d0e774fd76f 100644 (file)
@@ -19,6 +19,7 @@ The currently available plugins are listed below.
 | mocplay | sh | [moc](http://moc.daper.net/) | Appends (and plays, see script) selection/dir/file in moc|
 | ndiff | sh | vimdiff | Diff for selection (limited to 2 for directories) |
 | nmount | sh | pmount, udisks2 | Toggle mount status of a device as normal user |
+| notes | sh | - | Open a quick notes file/dir in `$EDITOR` |
 | nwal | sh | nitrogen | Set image as wallpaper using nitrogen |
 | oldbigfile | sh | find, sort | List large files by access time |
 | organize | sh | file | Auto-organize files in directories by file type |
diff --git a/plugins/notes b/plugins/notes
new file mode 100755 (executable)
index 0000000..02b9a0f
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/env sh
+
+# Description: Open a quick notes file or directory in $EDITOR
+#
+# Details: Set the variable NOTE to the path to your quick notes file
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+NOTE=
+# NOTE=~/Dropbox/Notes/synced_note
+
+if [ ! -z "$NOTE" ]; then
+   $EDITOR "$NOTE"
+fi
index ea2aa7f418ac46161df50eb38be686955dab386a..a7d678b4bda78bb505cb6cdd51b9f92c9992edcb 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -401,10 +401,9 @@ static const char * const messages[] = {
 #define NNN_CONTEXT_COLORS 2
 #define NNN_IDLE_TIMEOUT 3
 #define NNN_COPIER 4
-#define NNN_NOTE 5
-#define NNNLVL 6 /* strings end here */
-#define NNN_USE_EDITOR 7 /* flags begin here */
-#define NNN_TRASH 8
+#define NNNLVL 5 /* strings end here */
+#define NNN_USE_EDITOR 6 /* flags begin here */
+#define NNN_TRASH 7
 
 static const char * const env_cfg[] = {
        "NNN_BMS",
@@ -412,7 +411,6 @@ static const char * const env_cfg[] = {
        "NNN_CONTEXT_COLORS",
        "NNN_IDLE_TIMEOUT",
        "NNN_COPIER",
-       "NNN_NOTE",
        "NNNLVL",
        "NNN_USE_EDITOR",
        "NNN_TRASH",
@@ -2852,10 +2850,10 @@ static bool show_help(const char *path)
                  "cS  du                A  Apparent du\n"
                  "cs  Size     E  Extn  t  Time modified\n"
                "1MISC\n"
-              "9! ^]  Shell   ^N  Note  L  Lock   \n"
+              "9! ^]  Shell             =  Launcher\n"
               "9R ^V  Pick plugin   :K xK  Run plugin key K\n"
                  "cc  SSHFS mount       u  Unmount\n"
-                "b^P  Prompt/run expr   =  Launcher\n"};
+                "b^P  Prompt/run expr   L  Lock\n"};
 
        fd = create_tmp_file();
        if (fd == -1)
@@ -3994,7 +3992,6 @@ nochange:
                case SEL_REDRAW: // fallthrough
                case SEL_RENAMEALL: // fallthrough
                case SEL_HELP: // fallthrough
-               case SEL_NOTE: // fallthrough
                case SEL_LOCK:
                {
                        if (ndents)
@@ -4027,19 +4024,6 @@ nochange:
                        case SEL_RUNPAGE:
                                spawn(pager, dents[cur].name, NULL, path, F_CLI);
                                break;
-                       case SEL_NOTE:
-                       {
-                               static char *notepath;
-
-                               notepath = notepath ? notepath : getenv(env_cfg[NNN_NOTE]);
-                               if (!notepath) {
-                                       printwait("set NNN_NOTE", &presel);
-                                       goto nochange;
-                               }
-
-                               spawn(editor, notepath, NULL, path, F_CLI);
-                               break;
-                       }
                        default: /* SEL_LOCK */
                                lock_terminal();
                                break;
index c65d5627994cf9a088f5285d2b75cfa6a4999a8a..8720efc1038692745933506bda091da3ebe8598f 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -96,7 +96,6 @@ enum action {
        SEL_RUNCMD,
        SEL_RUNEDIT,
        SEL_RUNPAGE,
-       SEL_NOTE,
        SEL_LOCK,
        SEL_QUITCTX,
        SEL_QUITCD,
@@ -246,8 +245,6 @@ static struct key bindings[] = {
        /* Open in EDITOR or PAGER */
        { 'e',            SEL_RUNEDIT },
        { 'p',            SEL_RUNPAGE },
-       /* Open notes file */
-       { CONTROL('N'),   SEL_NOTE },
        /* Lock screen */
        { 'L',            SEL_LOCK },
        /* Quit a context */