mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Add 'c' command to change into a destination directory by typing the path
This commit is contained in:
parent
58f897fead
commit
61bc5cd817
3
README
3
README
|
@ -35,8 +35,9 @@ You can navigate the list using the following keybinds (hardcoded):
|
||||||
| l | RIGHT | ^M | open file / directory (see section "File opening")
|
| l | RIGHT | ^M | open file / directory (see section "File opening")
|
||||||
| h | LEFT | ^? | navigate up one directory
|
| h | LEFT | ^? | navigate up one directory
|
||||||
| / | & | | filter output
|
| / | & | | filter output
|
||||||
| q | | | exit program
|
|
||||||
| ! | | | spawn shell in current directory
|
| ! | | | spawn shell in current directory
|
||||||
|
| c | | | type and change into destination directory
|
||||||
|
| q | | | exit program
|
||||||
+------+-------+-------+---------------------------------------------------
|
+------+-------+-------+---------------------------------------------------
|
||||||
|
|
||||||
File opening
|
File opening
|
||||||
|
|
25
noice.c
25
noice.c
|
@ -204,6 +204,7 @@ enum {
|
||||||
SEL_GOIN,
|
SEL_GOIN,
|
||||||
SEL_FLTR,
|
SEL_FLTR,
|
||||||
SEL_SH,
|
SEL_SH,
|
||||||
|
SEL_CD,
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -258,6 +259,8 @@ nextsel(int *cur, int max)
|
||||||
break;
|
break;
|
||||||
case '!':
|
case '!':
|
||||||
return SEL_SH;
|
return SEL_SH;
|
||||||
|
case 'c':
|
||||||
|
return SEL_CD;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -604,6 +607,28 @@ nochange:
|
||||||
if (chdir(ipath) == -1)
|
if (chdir(ipath) == -1)
|
||||||
printwarn();
|
printwarn();
|
||||||
break;
|
break;
|
||||||
|
case SEL_CD:
|
||||||
|
/* Read target dir */
|
||||||
|
printmsg("");
|
||||||
|
move(LINES - 1, 0);
|
||||||
|
printw("chdir: ");
|
||||||
|
tmp = readln();
|
||||||
|
if (tmp == NULL) {
|
||||||
|
printmsg("");
|
||||||
|
goto nochange;
|
||||||
|
}
|
||||||
|
if (testopendir(tmp) == 0) {
|
||||||
|
printwarn();
|
||||||
|
goto nochange;
|
||||||
|
} else {
|
||||||
|
free(path);
|
||||||
|
path = strdup(tmp);
|
||||||
|
free(filter);
|
||||||
|
filter = strdup(ifilter); /* Reset filter */
|
||||||
|
DPRINTF_S(path);
|
||||||
|
cur = 0;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue