mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Support open current dir in desktop file manager
This commit is contained in:
parent
15a0e779a2
commit
9702abdd81
|
@ -79,7 +79,10 @@ I chose to fork because:
|
||||||
- Sort entries by file size (largest to smallest)
|
- Sort entries by file size (largest to smallest)
|
||||||
- Shortcut to invoke file name copier (set using environment variable `NNN_COPIER`)
|
- Shortcut to invoke file name copier (set using environment variable `NNN_COPIER`)
|
||||||
#### File associations
|
#### 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=xdg-open
|
||||||
export NNN_OPENER=gnome-open
|
export NNN_OPENER=gnome-open
|
||||||
|
@ -90,7 +93,7 @@ I chose to fork because:
|
||||||
- Associate PDF files with [zathura](https://pwmt.org/projects/zathura/)
|
- Associate PDF files with [zathura](https://pwmt.org/projects/zathura/)
|
||||||
- Removed `less` as default file opener (there is no universal standalone opener utility)
|
- 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))
|
- 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 the executable in static file association is missing
|
||||||
- If a file type was not handled in static file association
|
- If a file type was not handled in static file association
|
||||||
- This may be the best option to set your desktop opener to
|
- This may be the best option to set your desktop opener to
|
||||||
|
@ -145,6 +148,7 @@ Start nnn (default: current directory):
|
||||||
| `Left`, `Backspace`, `h`, `^H` | Go to parent dir |
|
| `Left`, `Backspace`, `h`, `^H` | Go to parent dir |
|
||||||
| `~` | Jump to HOME dir |
|
| `~` | Jump to HOME dir |
|
||||||
| `-` | Jump to last visited dir |
|
| `-` | Jump to last visited dir |
|
||||||
|
| `o` | Open dir in desktop file manager |
|
||||||
| `/`, `&` | Filter dir contents |
|
| `/`, `&` | Filter dir contents |
|
||||||
| `c` | Show change dir prompt |
|
| `c` | Show change dir prompt |
|
||||||
| `d` | Toggle detail view |
|
| `d` | Toggle detail view |
|
||||||
|
|
|
@ -74,6 +74,8 @@ struct key bindings[] = {
|
||||||
{ 'd', SEL_DETAIL, "", "" },
|
{ 'd', SEL_DETAIL, "", "" },
|
||||||
/* File details */
|
/* File details */
|
||||||
{ 'D', SEL_STATS, "", "" },
|
{ 'D', SEL_STATS, "", "" },
|
||||||
|
/* Open dir in desktop file manager */
|
||||||
|
{ 'o', SEL_DFB, "", "" },
|
||||||
/* Toggle sort by size */
|
/* Toggle sort by size */
|
||||||
{ 's', SEL_FSIZE, "", "" },
|
{ 's', SEL_FSIZE, "", "" },
|
||||||
/* Sort by total block size including dir contents */
|
/* Sort by total block size including dir contents */
|
||||||
|
|
17
nnn.1
17
nnn.1
|
@ -42,6 +42,8 @@ Back up one directory level
|
||||||
Change to the HOME directory
|
Change to the HOME directory
|
||||||
.It Ic -
|
.It Ic -
|
||||||
Change to the last visited directory
|
Change to the last visited directory
|
||||||
|
.It Ic o
|
||||||
|
Open directory in desktop file manager
|
||||||
.It Ic /, &
|
.It Ic /, &
|
||||||
Change filter (more information below)
|
Change filter (more information below)
|
||||||
.It Ic c
|
.It Ic c
|
||||||
|
@ -90,17 +92,7 @@ is configured by modifying
|
||||||
.Pa config.h
|
.Pa config.h
|
||||||
and recompiling the code.
|
and recompiling the code.
|
||||||
.Pp
|
.Pp
|
||||||
Environment variable
|
See the environment and examples sections below for more options and information.
|
||||||
.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.
|
|
||||||
.Sh FILTERS
|
.Sh FILTERS
|
||||||
Filters support regexes to display only the matched
|
Filters support regexes to display only the matched
|
||||||
entries in the current directory view. This effectively allows
|
entries in the current directory view. This effectively allows
|
||||||
|
@ -119,6 +111,9 @@ files.
|
||||||
The SHELL, EDITOR and PAGER environment variables take precedence
|
The SHELL, EDITOR and PAGER environment variables take precedence
|
||||||
when dealing with the !, e and p commands respectively.
|
when dealing with the !, e and p commands respectively.
|
||||||
.Pp
|
.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
|
\fBNNN_OPENER:\fR set to your desktop environment's default
|
||||||
mime opener to override all custom mime associations.
|
mime opener to override all custom mime associations.
|
||||||
.br
|
.br
|
||||||
|
|
14
nnn.c
14
nnn.c
|
@ -86,6 +86,7 @@ enum action {
|
||||||
SEL_TOGGLEDOT,
|
SEL_TOGGLEDOT,
|
||||||
SEL_DETAIL,
|
SEL_DETAIL,
|
||||||
SEL_STATS,
|
SEL_STATS,
|
||||||
|
SEL_DFB,
|
||||||
SEL_FSIZE,
|
SEL_FSIZE,
|
||||||
SEL_BSIZE,
|
SEL_BSIZE,
|
||||||
SEL_MTIME,
|
SEL_MTIME,
|
||||||
|
@ -122,6 +123,7 @@ static int idle;
|
||||||
static char *opener;
|
static char *opener;
|
||||||
static char *fallback_opener;
|
static char *fallback_opener;
|
||||||
static char *copier;
|
static char *copier;
|
||||||
|
static char *desktop_manager;
|
||||||
static off_t blk_size;
|
static off_t blk_size;
|
||||||
static size_t fs_free;
|
static size_t fs_free;
|
||||||
static int open_max;
|
static int open_max;
|
||||||
|
@ -916,6 +918,7 @@ show_help(void)
|
||||||
[Left], [Backspace], h, ^H Go to parent dir\n\
|
[Left], [Backspace], h, ^H Go to parent dir\n\
|
||||||
~ Jump to HOME dir\n\
|
~ Jump to HOME dir\n\
|
||||||
- Jump to last visited dir\n\
|
- Jump to last visited dir\n\
|
||||||
|
o Open dir in desktop file manager\n\
|
||||||
/, & Filter dir contents\n\
|
/, & Filter dir contents\n\
|
||||||
c Show change dir prompt\n\
|
c Show change dir prompt\n\
|
||||||
d Toggle detail view\n\
|
d Toggle detail view\n\
|
||||||
|
@ -1485,6 +1488,14 @@ nochange:
|
||||||
|
|
||||||
goto begin;
|
goto begin;
|
||||||
}
|
}
|
||||||
|
case SEL_DFB:
|
||||||
|
if (!desktop_manager)
|
||||||
|
goto nochange;
|
||||||
|
|
||||||
|
exitcurses();
|
||||||
|
spawn(desktop_manager, path, path, 0);
|
||||||
|
initcurses();
|
||||||
|
goto nochange;
|
||||||
case SEL_FSIZE:
|
case SEL_FSIZE:
|
||||||
sizeorder = !sizeorder;
|
sizeorder = !sizeorder;
|
||||||
mtimeorder = 0;
|
mtimeorder = 0;
|
||||||
|
@ -1623,6 +1634,9 @@ main(int argc, char *argv[])
|
||||||
/* Get the fallback desktop mime opener, if set */
|
/* Get the fallback desktop mime opener, if set */
|
||||||
fallback_opener = getenv("NNN_FALLBACK_OPENER");
|
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 */
|
/* Get the default copier, if set */
|
||||||
copier = getenv("NNN_COPIER");
|
copier = getenv("NNN_COPIER");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue