mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Add plugin to take quick notes
This commit is contained in:
parent
ce8e6a8791
commit
d7ce06b10b
|
@ -87,7 +87,7 @@ Visit the **[Wiki](https://github.com/jarun/nnn/wiki)** for operational concepts
|
||||||
- Create, rename, duplicate files and directories
|
- Create, rename, duplicate files and directories
|
||||||
- Per-context directory color (default: blue)
|
- Per-context directory color (default: blue)
|
||||||
- Spawn a shell, run apps, run commands, execute file
|
- 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
|
- Shortcut reference a keypress away
|
||||||
- Unicode support
|
- Unicode support
|
||||||
- Follows Linux kernel coding style
|
- 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_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_CONTEXT_COLORS='1234'` | specify per context color [default: '4444' (all blue)] |
|
||||||
| `NNN_SSHFS_OPTS='sshfs -o reconnect,idmap=user'` | specify SSHFS options |
|
| `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_OPENER=mimeopen` | custom file opener |
|
||||||
| `NNN_IDLE_TIMEOUT=300` | idle seconds to lock terminal [default: disabled] |
|
| `NNN_IDLE_TIMEOUT=300` | idle seconds to lock terminal [default: disabled] |
|
||||||
| `NNN_COPIER=copier` | clipboard copier script [default: none] |
|
| `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 du A Apparent du
|
||||||
s Size E Extn t Time modified
|
s Size E Extn t Time modified
|
||||||
MISC
|
MISC
|
||||||
! ^] Shell ^N Note L Lock
|
! ^] Shell = Launcher
|
||||||
R ^V Pick plugin :K xK Run plugin key K
|
R ^V Pick plugin :K xK Run plugin key K
|
||||||
c SSHFS mount u Unmount
|
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.
|
Note: Help & settings, file details and archive listing are shown in the PAGER. Use the PAGER-specific keys in these screens.
|
||||||
|
|
5
nnn.1
5
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.
|
NOTE: The options must be preceded by `sshfs` and comma-separated without any space between them.
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.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.
|
\fBNNN_OPENER:\fR specify a custom file opener.
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
export NNN_OPENER=mimeopen
|
export NNN_OPENER=mimeopen
|
||||||
|
|
|
@ -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|
|
| 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) |
|
| ndiff | sh | vimdiff | Diff for selection (limited to 2 for directories) |
|
||||||
| nmount | sh | pmount, udisks2 | Toggle mount status of a device as normal user |
|
| 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 |
|
| nwal | sh | nitrogen | Set image as wallpaper using nitrogen |
|
||||||
| oldbigfile | sh | find, sort | List large files by access time |
|
| oldbigfile | sh | find, sort | List large files by access time |
|
||||||
| organize | sh | file | Auto-organize files in directories by file type |
|
| organize | sh | file | Auto-organize files in directories by file type |
|
||||||
|
|
15
plugins/notes
Executable file
15
plugins/notes
Executable 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
|
26
src/nnn.c
26
src/nnn.c
|
@ -401,10 +401,9 @@ static const char * const messages[] = {
|
||||||
#define NNN_CONTEXT_COLORS 2
|
#define NNN_CONTEXT_COLORS 2
|
||||||
#define NNN_IDLE_TIMEOUT 3
|
#define NNN_IDLE_TIMEOUT 3
|
||||||
#define NNN_COPIER 4
|
#define NNN_COPIER 4
|
||||||
#define NNN_NOTE 5
|
#define NNNLVL 5 /* strings end here */
|
||||||
#define NNNLVL 6 /* strings end here */
|
#define NNN_USE_EDITOR 6 /* flags begin here */
|
||||||
#define NNN_USE_EDITOR 7 /* flags begin here */
|
#define NNN_TRASH 7
|
||||||
#define NNN_TRASH 8
|
|
||||||
|
|
||||||
static const char * const env_cfg[] = {
|
static const char * const env_cfg[] = {
|
||||||
"NNN_BMS",
|
"NNN_BMS",
|
||||||
|
@ -412,7 +411,6 @@ static const char * const env_cfg[] = {
|
||||||
"NNN_CONTEXT_COLORS",
|
"NNN_CONTEXT_COLORS",
|
||||||
"NNN_IDLE_TIMEOUT",
|
"NNN_IDLE_TIMEOUT",
|
||||||
"NNN_COPIER",
|
"NNN_COPIER",
|
||||||
"NNN_NOTE",
|
|
||||||
"NNNLVL",
|
"NNNLVL",
|
||||||
"NNN_USE_EDITOR",
|
"NNN_USE_EDITOR",
|
||||||
"NNN_TRASH",
|
"NNN_TRASH",
|
||||||
|
@ -2852,10 +2850,10 @@ static bool show_help(const char *path)
|
||||||
"cS du A Apparent du\n"
|
"cS du A Apparent du\n"
|
||||||
"cs Size E Extn t Time modified\n"
|
"cs Size E Extn t Time modified\n"
|
||||||
"1MISC\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"
|
"9R ^V Pick plugin :K xK Run plugin key K\n"
|
||||||
"cc SSHFS mount u Unmount\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();
|
fd = create_tmp_file();
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
|
@ -3994,7 +3992,6 @@ nochange:
|
||||||
case SEL_REDRAW: // fallthrough
|
case SEL_REDRAW: // fallthrough
|
||||||
case SEL_RENAMEALL: // fallthrough
|
case SEL_RENAMEALL: // fallthrough
|
||||||
case SEL_HELP: // fallthrough
|
case SEL_HELP: // fallthrough
|
||||||
case SEL_NOTE: // fallthrough
|
|
||||||
case SEL_LOCK:
|
case SEL_LOCK:
|
||||||
{
|
{
|
||||||
if (ndents)
|
if (ndents)
|
||||||
|
@ -4027,19 +4024,6 @@ nochange:
|
||||||
case SEL_RUNPAGE:
|
case SEL_RUNPAGE:
|
||||||
spawn(pager, dents[cur].name, NULL, path, F_CLI);
|
spawn(pager, dents[cur].name, NULL, path, F_CLI);
|
||||||
break;
|
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 */
|
default: /* SEL_LOCK */
|
||||||
lock_terminal();
|
lock_terminal();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -96,7 +96,6 @@ enum action {
|
||||||
SEL_RUNCMD,
|
SEL_RUNCMD,
|
||||||
SEL_RUNEDIT,
|
SEL_RUNEDIT,
|
||||||
SEL_RUNPAGE,
|
SEL_RUNPAGE,
|
||||||
SEL_NOTE,
|
|
||||||
SEL_LOCK,
|
SEL_LOCK,
|
||||||
SEL_QUITCTX,
|
SEL_QUITCTX,
|
||||||
SEL_QUITCD,
|
SEL_QUITCD,
|
||||||
|
@ -246,8 +245,6 @@ static struct key bindings[] = {
|
||||||
/* Open in EDITOR or PAGER */
|
/* Open in EDITOR or PAGER */
|
||||||
{ 'e', SEL_RUNEDIT },
|
{ 'e', SEL_RUNEDIT },
|
||||||
{ 'p', SEL_RUNPAGE },
|
{ 'p', SEL_RUNPAGE },
|
||||||
/* Open notes file */
|
|
||||||
{ CONTROL('N'), SEL_NOTE },
|
|
||||||
/* Lock screen */
|
/* Lock screen */
|
||||||
{ 'L', SEL_LOCK },
|
{ 'L', SEL_LOCK },
|
||||||
/* Quit a context */
|
/* Quit a context */
|
||||||
|
|
Loading…
Reference in a new issue