Add plugin to take quick notes

This commit is contained in:
Arun Prakash Jana 2019-09-26 19:56:43 +05:30
parent ce8e6a8791
commit d7ce06b10b
No known key found for this signature in database
GPG key ID: A75979F35C080412
6 changed files with 24 additions and 33 deletions

View file

@ -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.

5
nnn.1
View file

@ -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

View 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 |

15
plugins/notes Executable file
View file

@ -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

View file

@ -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;

View file

@ -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 */