mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Support jump to initial directory
This change remaps the & key. However, / is more relevant for filter and & makes more sense wrt. address.
This commit is contained in:
parent
c9dafb297b
commit
b4166192e6
|
@ -139,9 +139,10 @@ nnn needs libreadline, libncursesw (on Linux or ncurses on OS X) and standard li
|
||||||
| `Right`, `Enter`, `l`, `^M` | Open file or enter dir |
|
| `Right`, `Enter`, `l`, `^M` | Open file or enter dir |
|
||||||
| `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 initial dir |
|
||||||
| `-` | Jump to last visited dir |
|
| `-` | Jump to last visited dir |
|
||||||
| `o` | Open dir in `NNN_DE_FILE_MANAGER` |
|
| `o` | Open dir in `NNN_DE_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 |
|
||||||
| `D` | Toggle current file details screen |
|
| `D` | Toggle current file details screen |
|
||||||
|
|
|
@ -35,7 +35,6 @@ static struct key bindings[] = {
|
||||||
{ 'l', SEL_GOIN, "", "" },
|
{ 'l', SEL_GOIN, "", "" },
|
||||||
/* Filter */
|
/* Filter */
|
||||||
{ '/', SEL_FLTR, "", "" },
|
{ '/', SEL_FLTR, "", "" },
|
||||||
{ '&', SEL_FLTR, "", "" },
|
|
||||||
/* Next */
|
/* Next */
|
||||||
{ 'j', SEL_NEXT, "", "" },
|
{ 'j', SEL_NEXT, "", "" },
|
||||||
{ KEY_DOWN, SEL_NEXT, "", "" },
|
{ KEY_DOWN, SEL_NEXT, "", "" },
|
||||||
|
@ -50,12 +49,12 @@ static struct key bindings[] = {
|
||||||
/* Page up */
|
/* Page up */
|
||||||
{ KEY_PPAGE, SEL_PGUP, "", "" },
|
{ KEY_PPAGE, SEL_PGUP, "", "" },
|
||||||
{ CONTROL('U'), SEL_PGUP, "", "" },
|
{ CONTROL('U'), SEL_PGUP, "", "" },
|
||||||
/* Home */
|
/* First entry */
|
||||||
{ KEY_HOME, SEL_HOME, "", "" },
|
{ KEY_HOME, SEL_HOME, "", "" },
|
||||||
{ 'g', SEL_HOME, "", "" },
|
{ 'g', SEL_HOME, "", "" },
|
||||||
{ CONTROL('A'), SEL_HOME, "", "" },
|
{ CONTROL('A'), SEL_HOME, "", "" },
|
||||||
{ '^', SEL_HOME, "", "" },
|
{ '^', SEL_HOME, "", "" },
|
||||||
/* End */
|
/* Last entry */
|
||||||
{ KEY_END, SEL_END, "", "" },
|
{ KEY_END, SEL_END, "", "" },
|
||||||
{ 'G', SEL_END, "", "" },
|
{ 'G', SEL_END, "", "" },
|
||||||
{ CONTROL('E'), SEL_END, "", "" },
|
{ CONTROL('E'), SEL_END, "", "" },
|
||||||
|
@ -64,6 +63,8 @@ static struct key bindings[] = {
|
||||||
{ 'c', SEL_CD, "", "" },
|
{ 'c', SEL_CD, "", "" },
|
||||||
/* HOME */
|
/* HOME */
|
||||||
{ '~', SEL_CDHOME, "", "" },
|
{ '~', SEL_CDHOME, "", "" },
|
||||||
|
/* Initial directory */
|
||||||
|
{ '&', SEL_CDBEGIN, "", "" },
|
||||||
/* Last visited dir */
|
/* Last visited dir */
|
||||||
{ '-', SEL_LAST, "", "" },
|
{ '-', SEL_LAST, "", "" },
|
||||||
/* Toggle hide .dot files */
|
/* Toggle hide .dot files */
|
||||||
|
|
3
nlay
3
nlay
|
@ -14,7 +14,8 @@
|
||||||
#
|
#
|
||||||
# The bg setting depends on personal preference and type of app, e.g.,
|
# The bg setting depends on personal preference and type of app, e.g.,
|
||||||
# I would start vim (CLI) in the foreground but Sublime Text (GUI) in the
|
# I would start vim (CLI) in the foreground but Sublime Text (GUI) in the
|
||||||
# background.
|
# background. I also prefer mpv running in the background without disturbing
|
||||||
|
# my ongoing activity in nnn by blocking navigation.
|
||||||
#
|
#
|
||||||
# Check (and TOGGLE as you wish) the default bg settings.
|
# Check (and TOGGLE as you wish) the default bg settings.
|
||||||
#
|
#
|
||||||
|
|
4
nnn.1
4
nnn.1
|
@ -43,11 +43,13 @@ Open file or enter directory
|
||||||
Back up one directory level
|
Back up one directory level
|
||||||
.It Ic ~
|
.It Ic ~
|
||||||
Change to the HOME directory
|
Change to the HOME directory
|
||||||
|
.It Ic &
|
||||||
|
Change to initial directory
|
||||||
.It Ic -
|
.It Ic -
|
||||||
Change to the last visited directory
|
Change to the last visited directory
|
||||||
.It Ic o
|
.It Ic o
|
||||||
Open directory in NNN_DE_FILE_MANAGER
|
Open directory in NNN_DE_FILE_MANAGER
|
||||||
.It Ic /, &
|
.It Ic /
|
||||||
Change filter (more information below)
|
Change filter (more information below)
|
||||||
.It Ic c
|
.It Ic c
|
||||||
Change into the given directory
|
Change into the given directory
|
||||||
|
|
18
nnn.c
18
nnn.c
|
@ -86,6 +86,7 @@ enum action {
|
||||||
SEL_END,
|
SEL_END,
|
||||||
SEL_CD,
|
SEL_CD,
|
||||||
SEL_CDHOME,
|
SEL_CDHOME,
|
||||||
|
SEL_CDBEGIN,
|
||||||
SEL_LAST,
|
SEL_LAST,
|
||||||
SEL_TOGGLEDOT,
|
SEL_TOGGLEDOT,
|
||||||
SEL_DETAIL,
|
SEL_DETAIL,
|
||||||
|
@ -946,9 +947,10 @@ show_help(void)
|
||||||
[Right], [Enter], l, ^M Open file or enter dir\n\
|
[Right], [Enter], l, ^M Open file or enter dir\n\
|
||||||
[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 initial dir\n\
|
||||||
- Jump to last visited dir\n\
|
- Jump to last visited dir\n\
|
||||||
o Open dir in NNN_DE_FILE_MANAGER\n\
|
o Open dir in NNN_DE_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\
|
||||||
D Toggle current file details screen\n\
|
D Toggle current file details screen\n\
|
||||||
|
@ -1554,6 +1556,20 @@ nochange:
|
||||||
xstrlcpy(fltr, ifilter, sizeof(fltr));
|
xstrlcpy(fltr, ifilter, sizeof(fltr));
|
||||||
DPRINTF_S(path);
|
DPRINTF_S(path);
|
||||||
goto begin;
|
goto begin;
|
||||||
|
case SEL_CDBEGIN:
|
||||||
|
if (canopendir(ipath) == 0) {
|
||||||
|
printwarn();
|
||||||
|
goto nochange;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save last working directory */
|
||||||
|
xstrlcpy(lastdir, path, sizeof(lastdir));
|
||||||
|
|
||||||
|
xstrlcpy(path, ipath, sizeof(path));
|
||||||
|
/* Reset filter */
|
||||||
|
xstrlcpy(fltr, ifilter, sizeof(fltr));
|
||||||
|
DPRINTF_S(path);
|
||||||
|
goto begin;
|
||||||
case SEL_LAST:
|
case SEL_LAST:
|
||||||
xstrlcpy(newpath, lastdir, sizeof(newpath));
|
xstrlcpy(newpath, lastdir, sizeof(newpath));
|
||||||
xstrlcpy(lastdir, path, sizeof(lastdir));
|
xstrlcpy(lastdir, path, sizeof(lastdir));
|
||||||
|
|
Loading…
Reference in a new issue