README.md | 3 +++ nnn.1 | 8 +++++--- nnn.c | 25 +++++++++++++++++++++++-- nnn.h | 3 +++ diff --git a/README.md b/README.md index 2c69bcd6967a4054dce1fea9ed830ae443dde71d..b5187f1220e4adc25a8736ca6df17e29dd1a03f7 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ - Filter directory contents with *search-as-you-type* - Desktop search (default gnome-search-tool, customizable) integration - Mimes - Desktop opener integration + - Open file with a custom application - Optionally open text files in EDITOR (fallback vi) - Customizable bash script [nlay](https://github.com/jarun/nnn/wiki/all-about-nlay) to handle actions - Information @@ -105,6 +106,7 @@ - Basic and detail view - Detailed file information - Media information (needs mediainfo or exiftool, if specified) - Ordering + - Numeric order (1, 2, ... 10, 11, ...) for numeric names - Sort by file name, modification time, size - Convenience - Create, rename files and directories @@ -216,6 +218,7 @@ Home, g, ^, ^A | First entry End, G, $, ^E | Fast entry →, ↵, l, ^M | Open file or enter dir ←, Bksp, h, ^H | Go to parent dir + ^O | Open with... Insert | Toggle navigate-as-you-type ~ | Go HOME & | Go to initial dir diff --git a/nnn.1 b/nnn.1 index 3fff18dc3fab72c26534ed01e887366cd3a01776..3407c09760fd7b18245600d4d505ca7de3076439 100644 --- a/nnn.1 +++ b/nnn.1 @@ -46,6 +46,8 @@ .It Ic [Right], [Enter], l, ^M Open file or enter directory .It Ic [Left], [Backspace], h, ^H Back up one directory level +.It Ic ^O +Open with a custom application .It Ic [Insert] Toggle navigate-as-you-type mode .It Ic ~ @@ -63,11 +65,11 @@ Toggle hide .dot files .It Ic b Show bookmark key prompt .It Ic ^B -Pin current dir +Pin current directory .It Ic ^V -Visit pinned dir +Visit pinned directory .It Ic c -Show change dir prompt +Show change directory prompt .It Ic d Toggle detail view .It Ic D diff --git a/nnn.c b/nnn.c index 0fe586616174f5d9bb7d760d841ee163acc470cc..7e9e1dd191d52ad5adea4778c699f51c468b859f 100644 --- a/nnn.c +++ b/nnn.c @@ -1699,6 +1699,7 @@ "1Home, g, ^, ^A | First entry\n" "2End, G, $, ^E | Last entry\n" "4→, ↵, l, ^M | Open file or enter dir\n" "1←, Bksp, h, ^H | Go to parent dir\n" + "d^O | Open with...\n" "9Insert | Toggle navigate-as-you-type\n" "e~ | Go HOME\n" "e& | Go to initial dir\n" @@ -1714,7 +1715,7 @@ "ed | Toggle detail view\n" "eD | File details\n" "em | Brief media info\n" "eM | Full media info\n" - "en | Create new\n" + "en | Create new\n" "d^R | Rename entry\n" "es | Toggle sort by size\n" "eS | Toggle du mode\n" @@ -2699,8 +2700,12 @@ printmsg(newpath); } else if (!copier) printmsg("NNN_COPIER is not set"); goto nochange; + case SEL_OPEN: + printprompt("open with: "); // fallthrough case SEL_NEW: - printprompt("name: "); + if (sel == SEL_NEW) + printprompt("name: "); + tmp = xreadline(NULL); clearprompt(); if (tmp == NULL || tmp[0] == '\0') @@ -2710,6 +2715,22 @@ /* Allow only relative, same dir paths */ if (tmp[0] == '/' || xstrcmp(xbasename(tmp), tmp) != 0) { printmsg(STR_INPUT); 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 */ diff --git a/nnn.h b/nnn.h index 6bf6477cdaff5e870e2f86738f8ffe433f98ea48..fde2f3946ba83aed7dea2004c5d03400461ab01d 100644 --- a/nnn.h +++ b/nnn.h @@ -34,6 +34,7 @@ SEL_BSIZE, SEL_MTIME, SEL_REDRAW, SEL_COPY, + SEL_OPEN, SEL_NEW, SEL_RENAME, SEL_HELP, @@ -143,6 +144,8 @@ { CONTROL('L'), SEL_REDRAW, "", "" }, { KEY_F(5), SEL_REDRAW, "", "" }, /* Undocumented */ /* Copy currently selected file path */ { CONTROL('K'), SEL_COPY, "", "" }, + /* Open in a custom application */ + { CONTROL('O'), SEL_OPEN, "", "" }, /* Create a new file */ { 'n', SEL_NEW, "", "" }, /* Show rename prompt */