- [sample scripts](#sample-scripts)
- [dual-pane or multi-pane](#dual-pane-or-multi-pane)
- [change dir color](#change-dir-color)
- - [use cd .....](#use-cd-)
- [integrate patool](#integrate-patool)
- [work faster at rename prompt](#work-faster-at-rename-prompt)
- [set idle timeout](#set-idle-timeout)
- Familiar, easy shortcuts (arrows, `~`, `-`, `&`)
- *Navigate-as-you-type* mode with dir auto-select for the maverick
- Handy bookmarks, start at bookmark, pin and visit directory
- - chdir prompt with tab completion (interprets cd ..... too!)
- Roll-over at edges, page through entries
- Show directories in custom color (default: enabled in blue)
- Sorting
^B Bookmark prompt
b Pin current dir
^V Go to pinned dir
- c cd prompt
d Toggle detail view
D File details
m, M Brief/full media info
Any other value disables colored directories.
-#### use cd .....
-
-To jump to the n<sup>th</sup> level parent, use `n + 1` dots (the first `.` denotes PWD). For example, to jump to the 6<th> parent of the current directory, use 7 dots. If the number of dots would take you *beyond* `/` (which isn't possible), you'll be placed at `/`.
-
#### integrate patool
On systems where `atool` is not available but `patool` is, drop two copies of the Python3 script [natool](https://github.com/jarun/nnn/blob/master/scripts/natool) as `atool` and `apack` somewhere in `$PATH`.
return TRUE;
}
-/*
- * Return number of dots if all chars in a string are dots, else 0
- */
-static int all_dots(const char *path)
-{
- int count = 0;
-
- if (!path)
- return FALSE;
-
- while (*path == '.')
- ++count, ++path;
-
- if (*path)
- return 0;
-
- return count;
-}
-
/* Initialize curses mode */
static void initcurses(void)
{
"d^B Bookmark prompt\n"
"eb Pin current dir\n"
"d^V Go to pinned dir\n"
- "ec cd prompt\n"
"ed Toggle detail view\n"
"eD File details\n"
"bm, M Brief/full media info\n"
static char oldname[NAME_MAX + 1] __attribute__ ((aligned));
char *dir, *tmp, *run = NULL, *env = NULL;
struct stat sb;
- int r, fd, truecd, presel, ncp = 0, copystartid = 0, copyendid = 0;
+ int r, fd, presel, ncp = 0, copystartid = 0, copyendid = 0;
enum action sel = SEL_RUNARG + 1;
bool dir_changed = FALSE;
case SEL_END:
cur = ndents - 1;
break;
- case SEL_CD:
- truecd = 0;
- tmp = xreadline(NULL, "cd: ");
- if (tmp == NULL || tmp[0] == '\0')
- break;
-
- if (tmp[0] == '~') {
- /* Expand ~ to HOME absolute path */
- dir = getenv("HOME");
- if (dir)
- snprintf(newpath, PATH_MAX, "%s%s", dir, tmp + 1);
- else {
- printmsg(messages[STR_NOHOME_ID]);
- goto nochange;
- }
- } else if (tmp[0] == '-' && tmp[1] == '\0') {
- if (lastdir[0] == '\0')
- break;
-
- /* Switch to last visited dir */
- xstrlcpy(newpath, lastdir, PATH_MAX);
- truecd = 1;
- } else if ((r = all_dots(tmp))) {
- if (r == 1)
- /* Always in the current dir */
- break;
-
- /* Show a message if already at / */
- if (istopdir(path)) {
- /* Continue in navigate-as-you-type mode, if enabled */
- if (cfg.filtermode)
- presel = FILTER;
-
- goto nochange;
- }
-
- --r; /* One . for the current dir */
- dir = path;
-
- /* Note: fd is used as a tmp variable here */
- for (fd = 0; fd < r; ++fd) {
- /* Reached / ? */
- if (istopdir(path)) {
- /* Can't cd beyond / */
- break;
- }
-
- dir = xdirname(dir);
- if (access(dir, R_OK) == -1) {
- printwarn();
- goto nochange;
- }
- }
-
- truecd = 1;
-
- /* Save the path in case of cd ..
- * We mark the current dir in parent dir
- */
- if (r == 1) {
- xstrlcpy(oldname, xbasename(path), NAME_MAX + 1);
- truecd = 2;
- }
-
- xstrlcpy(newpath, dir, PATH_MAX);
- } else
- mkpath(path, tmp, newpath, PATH_MAX);
-
- if (!xdiraccess(newpath))
- goto nochange;
-
- if (truecd == 0) {
- /* Probable change in dir */
- /* No-op if it's the same directory */
- if (strcmp(path, newpath) == 0)
- break;
-
- oldname[0] = '\0';
- } else if (truecd == 1)
- /* Sure change in dir */
- oldname[0] = '\0';
-
- /* Save last working directory */
- xstrlcpy(lastdir, path, PATH_MAX);
- dir_changed = TRUE;
-
- /* Save the newly opted dir in path */
- xstrlcpy(path, newpath, PATH_MAX);
-
- /* Reset filter */
- copyfilter();
- DPRINTF_S(path);
- if (cfg.filtermode)
- presel = FILTER;
- goto begin;
case SEL_CDHOME:
dir = getenv("HOME");
if (dir == NULL) {
SEL_PGUP,
SEL_HOME,
SEL_END,
- SEL_CD,
SEL_CDHOME,
SEL_CDBEGIN,
SEL_CDLAST,
{ 'G', SEL_END, "", "" },
{ CONTROL('E'), SEL_END, "", "" },
{ '$', SEL_END, "", "" },
- /* Change dir */
- { 'c', SEL_CD, "", "" },
/* HOME */
{ '~', SEL_CDHOME, "", "" },
/* Initial directory */