mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Support 'Open with...'
This commit is contained in:
parent
f7399b05f9
commit
7f804ca8f2
|
@ -98,6 +98,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
|
||||||
- Desktop search (default gnome-search-tool, customizable) integration
|
- Desktop search (default gnome-search-tool, customizable) integration
|
||||||
- Mimes
|
- Mimes
|
||||||
- Desktop opener integration
|
- Desktop opener integration
|
||||||
|
- Open file with a custom application
|
||||||
- Optionally open text files in EDITOR (fallback vi)
|
- Optionally open text files in EDITOR (fallback vi)
|
||||||
- Customizable bash script [nlay](https://github.com/jarun/nnn/wiki/all-about-nlay) to handle actions
|
- Customizable bash script [nlay](https://github.com/jarun/nnn/wiki/all-about-nlay) to handle actions
|
||||||
- Information
|
- Information
|
||||||
|
@ -105,6 +106,7 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
|
||||||
- Detailed file information
|
- Detailed file information
|
||||||
- Media information (needs mediainfo or exiftool, if specified)
|
- Media information (needs mediainfo or exiftool, if specified)
|
||||||
- Ordering
|
- Ordering
|
||||||
|
- Numeric order (1, 2, ... 10, 11, ...) for numeric names
|
||||||
- Sort by file name, modification time, size
|
- Sort by file name, modification time, size
|
||||||
- Convenience
|
- Convenience
|
||||||
- Create, rename files and directories
|
- Create, rename files and directories
|
||||||
|
@ -216,6 +218,7 @@ optional arguments:
|
||||||
End, G, $, ^E | Fast entry
|
End, G, $, ^E | Fast entry
|
||||||
→, ↵, l, ^M | Open file or enter dir
|
→, ↵, l, ^M | Open file or enter dir
|
||||||
←, Bksp, h, ^H | Go to parent dir
|
←, Bksp, h, ^H | Go to parent dir
|
||||||
|
^O | Open with...
|
||||||
Insert | Toggle navigate-as-you-type
|
Insert | Toggle navigate-as-you-type
|
||||||
~ | Go HOME
|
~ | Go HOME
|
||||||
& | Go to initial dir
|
& | Go to initial dir
|
||||||
|
|
8
nnn.1
8
nnn.1
|
@ -46,6 +46,8 @@ Move to the last entry
|
||||||
Open file or enter directory
|
Open file or enter directory
|
||||||
.It Ic [Left], [Backspace], h, ^H
|
.It Ic [Left], [Backspace], h, ^H
|
||||||
Back up one directory level
|
Back up one directory level
|
||||||
|
.It Ic ^O
|
||||||
|
Open with a custom application
|
||||||
.It Ic [Insert]
|
.It Ic [Insert]
|
||||||
Toggle navigate-as-you-type mode
|
Toggle navigate-as-you-type mode
|
||||||
.It Ic ~
|
.It Ic ~
|
||||||
|
@ -63,11 +65,11 @@ Toggle hide .dot files
|
||||||
.It Ic b
|
.It Ic b
|
||||||
Show bookmark key prompt
|
Show bookmark key prompt
|
||||||
.It Ic ^B
|
.It Ic ^B
|
||||||
Pin current dir
|
Pin current directory
|
||||||
.It Ic ^V
|
.It Ic ^V
|
||||||
Visit pinned dir
|
Visit pinned directory
|
||||||
.It Ic c
|
.It Ic c
|
||||||
Show change dir prompt
|
Show change directory prompt
|
||||||
.It Ic d
|
.It Ic d
|
||||||
Toggle detail view
|
Toggle detail view
|
||||||
.It Ic D
|
.It Ic D
|
||||||
|
|
21
nnn.c
21
nnn.c
|
@ -1699,6 +1699,7 @@ show_help(char *path)
|
||||||
"2End, G, $, ^E | Last entry\n"
|
"2End, G, $, ^E | Last entry\n"
|
||||||
"4→, ↵, l, ^M | Open file or enter dir\n"
|
"4→, ↵, l, ^M | Open file or enter dir\n"
|
||||||
"1←, Bksp, h, ^H | Go to parent dir\n"
|
"1←, Bksp, h, ^H | Go to parent dir\n"
|
||||||
|
"d^O | Open with...\n"
|
||||||
"9Insert | Toggle navigate-as-you-type\n"
|
"9Insert | Toggle navigate-as-you-type\n"
|
||||||
"e~ | Go HOME\n"
|
"e~ | Go HOME\n"
|
||||||
"e& | Go to initial dir\n"
|
"e& | Go to initial dir\n"
|
||||||
|
@ -2699,8 +2700,12 @@ nochange:
|
||||||
} else if (!copier)
|
} else if (!copier)
|
||||||
printmsg("NNN_COPIER is not set");
|
printmsg("NNN_COPIER is not set");
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
case SEL_OPEN:
|
||||||
|
printprompt("open with: "); // fallthrough
|
||||||
case SEL_NEW:
|
case SEL_NEW:
|
||||||
|
if (sel == SEL_NEW)
|
||||||
printprompt("name: ");
|
printprompt("name: ");
|
||||||
|
|
||||||
tmp = xreadline(NULL);
|
tmp = xreadline(NULL);
|
||||||
clearprompt();
|
clearprompt();
|
||||||
if (tmp == NULL || tmp[0] == '\0')
|
if (tmp == NULL || tmp[0] == '\0')
|
||||||
|
@ -2712,6 +2717,22 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sel == SEL_OPEN) {
|
||||||
|
printprompt("Press 'c' for cli mode");
|
||||||
|
cleartimeout();
|
||||||
|
r = getch();
|
||||||
|
settimeout();
|
||||||
|
if (r == 'c')
|
||||||
|
r = F_NORMAL;
|
||||||
|
else
|
||||||
|
r = F_NOWAIT;
|
||||||
|
|
||||||
|
mkpath(path, dents[cur].name, newpath, PATH_MAX);
|
||||||
|
spawn(tmp, newpath, NULL, path, r);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Open the descriptor to currently open directory */
|
/* Open the descriptor to currently open directory */
|
||||||
fd = open(path, O_RDONLY | O_DIRECTORY);
|
fd = open(path, O_RDONLY | O_DIRECTORY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
|
3
nnn.h
3
nnn.h
|
@ -34,6 +34,7 @@ enum action {
|
||||||
SEL_MTIME,
|
SEL_MTIME,
|
||||||
SEL_REDRAW,
|
SEL_REDRAW,
|
||||||
SEL_COPY,
|
SEL_COPY,
|
||||||
|
SEL_OPEN,
|
||||||
SEL_NEW,
|
SEL_NEW,
|
||||||
SEL_RENAME,
|
SEL_RENAME,
|
||||||
SEL_HELP,
|
SEL_HELP,
|
||||||
|
@ -143,6 +144,8 @@ static struct key bindings[] = {
|
||||||
{ KEY_F(5), SEL_REDRAW, "", "" }, /* Undocumented */
|
{ KEY_F(5), SEL_REDRAW, "", "" }, /* Undocumented */
|
||||||
/* Copy currently selected file path */
|
/* Copy currently selected file path */
|
||||||
{ CONTROL('K'), SEL_COPY, "", "" },
|
{ CONTROL('K'), SEL_COPY, "", "" },
|
||||||
|
/* Open in a custom application */
|
||||||
|
{ CONTROL('O'), SEL_OPEN, "", "" },
|
||||||
/* Create a new file */
|
/* Create a new file */
|
||||||
{ 'n', SEL_NEW, "", "" },
|
{ 'n', SEL_NEW, "", "" },
|
||||||
/* Show rename prompt */
|
/* Show rename prompt */
|
||||||
|
|
Loading…
Reference in a new issue