README.md | 8 ++++++-- config.def.h | 2 ++ nnn.1 | 17 ++++++----------- nnn.c | 14 ++++++++++++++ diff --git a/README.md b/README.md index 4494281cd26c7af0ee1a521d4da83948b00a416c..199be91be50bfbfcf0e7771b60c5cb96ddd49b88 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,10 @@ - Removed navigation restriction with relative paths (and let permissions handle it) - Sort entries by file size (largest to smallest) - Shortcut to invoke file name copier (set using environment variable `NNN_COPIER`) #### File associations - - Environment variable `NNN_OPENER` to let desktop opener handle it all. E.g.: + - To open the current directory in a desktop file manager, set `NNN_DE_FILE_MANAGER`. E.g.: + + export NNN_DE_FILE_MANAGER=thunar + - Set `NNN_OPENER` to let a desktop opener handle it all. E.g.: export NNN_OPENER=xdg-open export NNN_OPENER=gnome-open @@ -90,7 +93,7 @@ - Associate common audio and video mimes with mpv - Associate PDF files with [zathura](https://pwmt.org/projects/zathura/) - Removed `less` as default file opener (there is no universal standalone opener utility) - You can customize further (see [how to change file associations](#change-file-associations)) - - Environment variable `NNN_FALLBACK_OPENER` is the last line of defense: + - `NNN_FALLBACK_OPENER` is the last line of defense: - If the executable in static file association is missing - If a file type was not handled in static file association - This may be the best option to set your desktop opener to @@ -145,6 +148,7 @@ | `Right`, `Enter`, `l`, `^M` | Open file or enter dir | | `Left`, `Backspace`, `h`, `^H` | Go to parent dir | | `~` | Jump to HOME dir | | `-` | Jump to last visited dir | +| `o` | Open dir in desktop file manager | | `/`, `&` | Filter dir contents | | `c` | Show change dir prompt | | `d` | Toggle detail view | diff --git a/config.def.h b/config.def.h index 2e51675840599adfc5239a5c9b84d1f5063f1200..2acdae904225c15765aa867dfe328729eaa9a20f 100644 --- a/config.def.h +++ b/config.def.h @@ -74,6 +74,8 @@ /* Detailed listing */ { 'd', SEL_DETAIL, "", "" }, /* File details */ { 'D', SEL_STATS, "", "" }, + /* Open dir in desktop file manager */ + { 'o', SEL_DFB, "", "" }, /* Toggle sort by size */ { 's', SEL_FSIZE, "", "" }, /* Sort by total block size including dir contents */ diff --git a/nnn.1 b/nnn.1 index 85acf1177154fb4ea6e740a620e63ec78fc0f6e4..bbaaab95a01dcd0d5ffa5b54e92d86891c9e808a 100644 --- a/nnn.1 +++ b/nnn.1 @@ -42,6 +42,8 @@ .It Ic ~ Change to the HOME directory .It Ic - Change to the last visited directory +.It Ic o +Open directory in desktop file manager .It Ic /, & Change filter (more information below) .It Ic c @@ -90,17 +92,7 @@ is configured by modifying .Pa config.h and recompiling the code. .Pp -Environment variable -.Ar NNN_OPENER -overrides all hard-coded file associations. -.Pp -Hard-coded associations are specified by regexes matching on the currently selected filename. If a match is found the associated program is executed with the filename passed in as the argument. If no match is found the environment variable -.Ar NNN_FALLBACK_OPENER -is invoked, if set. -.Pp -No particular utility is set as the default opener as no standalone universal opener for all mime types exists. -.Pp -See the examples section below for more information. +See the environment and examples sections below for more options and information. .Sh FILTERS Filters support regexes to display only the matched entries in the current directory view. This effectively allows @@ -118,6 +110,9 @@ files. .Sh ENVIRONMENT The SHELL, EDITOR and PAGER environment variables take precedence when dealing with the !, e and p commands respectively. +.Pp +\fBNNN_DE_FILE_MANAGER:\fR set to a desktop file manager to open the current +directory with. .Pp \fBNNN_OPENER:\fR set to your desktop environment's default mime opener to override all custom mime associations. diff --git a/nnn.c b/nnn.c index 318fffe756731cee7385c557d6919730ddbcc89e..f676eb310e94ee0366e7273eaa85dd1ac7ad50cb 100644 --- a/nnn.c +++ b/nnn.c @@ -86,6 +86,7 @@ SEL_LAST, SEL_TOGGLEDOT, SEL_DETAIL, SEL_STATS, + SEL_DFB, SEL_FSIZE, SEL_BSIZE, SEL_MTIME, @@ -122,6 +123,7 @@ static int idle; static char *opener; static char *fallback_opener; static char *copier; +static char *desktop_manager; static off_t blk_size; static size_t fs_free; static int open_max; @@ -916,6 +918,7 @@ [Right], [Enter], l, ^M Open file or enter dir\n\ [Left], [Backspace], h, ^H Go to parent dir\n\ ~ Jump to HOME dir\n\ - Jump to last visited dir\n\ + o Open dir in desktop file manager\n\ /, & Filter dir contents\n\ c Show change dir prompt\n\ d Toggle detail view\n\ @@ -1485,6 +1488,14 @@ show_stats(oldpath, dents[cur].name, &sb); goto begin; } + case SEL_DFB: + if (!desktop_manager) + goto nochange; + + exitcurses(); + spawn(desktop_manager, path, path, 0); + initcurses(); + goto nochange; case SEL_FSIZE: sizeorder = !sizeorder; mtimeorder = 0; @@ -1622,6 +1633,9 @@ opener = getenv("NNN_OPENER"); /* Get the fallback desktop mime opener, if set */ fallback_opener = getenv("NNN_FALLBACK_OPENER"); + + /* Get the desktop file browser, if set */ + desktop_manager = getenv("NNN_DE_FILE_MANAGER"); /* Get the default copier, if set */ copier = getenv("NNN_COPIER");