Code reformat

This commit is contained in:
Arun Prakash Jana 2019-01-20 23:51:45 +05:30
parent 1958b7ddf7
commit a8544f2842
No known key found for this signature in database
GPG Key ID: A75979F35C080412
3 changed files with 153 additions and 152 deletions

View File

@ -213,36 +213,36 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
``` ```
NAVIGATION NAVIGATION
↑, k, ^P Up PgUp, ^U Scroll up ↑, k, ^P Up PgUp, ^U Scroll up
↓, j, ^N Down PgDn, ^D Scroll down ↓, j, ^N Down PgDn, ^D Scroll down
←, h, ^H Parent dir ~ Go HOME ←, h, ^H Parent dir ~ Go HOME
↵, →, l, ^M Open file/dir & Start dir ↵, →, l, ^M Open file/dir & Start dir
Home, g, ^A First entry - Last visited dir Home, g, ^A First entry - Last visited dir
End, G, ^E Last entry . Toggle show hidden End, G, ^E Last entry . Toggle show hidden
/ Filter Ins, ^T Toggle nav-as-you-type / Filter Ins, ^T Toggle nav-as-you-type
b Pin current dir ^W Go to pinned dir b Pin current dir ^W Go to pinned dir
Tab, ^I Next context d Toggle detail view Tab, ^I Next context d Toggle detail view
`, ^/ Leader key N, LeadN Go to/create context N `, ^/ Leader key N, LeadN Go to/create context N
Esc Exit prompt ^L Redraw/clear prompt Esc Exit prompt ^L Redraw/clear prompt
^G Quit and cd q Quit context ^G Quit and cd q Quit context
Q, ^Q Quit ? Help, config Q, ^Q Quit ? Help, config
FILES FILES
^O Open with... n Create new/link ^O Open with... n Create new/link
D File details ^R Rename entry D File details ^R Rename entry
⎵, ^K Copy entry path r Open dir in vidir ⎵, ^K Copy entry path r Open dir in vidir
Y, ^Y Toggle selection y List selection Y, ^Y Toggle selection y List selection
P Copy selection X Delete selection P Copy selection X Delete selection
V Move selection ^X Delete entry V Move selection ^X Delete entry
f Archive entry F List archive f Archive entry F List archive
^F Extract archive m, M Brief/full media info ^F Extract archive m, M Brief/full media info
e Edit in EDITOR p Open in PAGER e Edit in EDITOR p Open in PAGER
ORDER TOGGLES ORDER TOGGLES
^J Disk usage S Apparent du ^J Disk usage S Apparent du
t Modification time s Size t Modification time s Size
MISC MISC
!, ^] Spawn SHELL in dir C Execute entry !, ^] Spawn SHELL in dir C Execute entry
R, ^V Run custom script L Lock terminal R, ^V Run custom script L Lock terminal
^S Run a command N Take note ^S Run a command N Take note
``` ```
Help & settings, file details, media info and archive listing are shown in the PAGER. Please use the PAGER-specific keys in these screens. Help & settings, file details, media info and archive listing are shown in the PAGER. Please use the PAGER-specific keys in these screens.
@ -377,20 +377,20 @@ The option `open with` takes 1 combined argument.
| Example `export` | Description | | Example `export` | Description |
| --- | --- | | --- | --- |
| `NNN_OPENER=mimeopen` | custom file opener |
| `NNN_BMS='d:~/Documents;D:~/Docs archive/'` | specify bookmarks (max 10) | | `NNN_BMS='d:~/Documents;D:~/Docs archive/'` | specify bookmarks (max 10) |
| `NNN_USE_EDITOR=1` | Open text files in `$EDITOR` (overridden by `$VISUAL`, fallback vi) | | `NNN_OPENER=mimeopen` | custom file opener |
| `NNN_CONTEXT_COLORS='1234'` | specify per context color [default: '4444' (all blue)] | | `NNN_CONTEXT_COLORS='1234'` | specify per context color [default: '4444' (all blue)] |
| `NNN_IDLE_TIMEOUT=300` | idle time to lock terminal [default: disabled] | | `NNN_IDLE_TIMEOUT=300` | idle time to lock terminal [default: disabled] |
| `NNN_COPIER='copier.sh'` | system clipboard copier script [default: none] | | `NNN_COPIER='copier.sh'` | system clipboard copier script [default: none] |
| `NNN_SCRIPT=/home/user/scripts[/script.sh]` | path to script dir or a single script | | `NNN_SCRIPT=/home/user/scripts[/script.sh]` | path to script dir or a single script |
| `NNN_NOTE=/home/user/Dropbox/Public/notes` | path to note file [default: none] | | `NNN_NOTE=/home/user/Dropbox/Public/notes` | path to note file [default: none] |
| `NNN_SHOW_HIDDEN=1` | show hidden (dot) files [default: do not show hidden if not root ] | | `NNN_TMPFILE=/tmp/nnn` | file to write current open dir path to for cd on quit |
| `NNN_USE_EDITOR=1` | Open text files in `$EDITOR` (`$VISUAL`, if defined; fallback vi) |
| `NNN_SHOW_HIDDEN=1` | show hidden (.) files [default: do not show hidden if not root ] |
| `NNN_NO_AUTOSELECT=1` | do not auto-select matching dir in _nav-as-you-type` mode | | `NNN_NO_AUTOSELECT=1` | do not auto-select matching dir in _nav-as-you-type` mode |
| `NNN_RESTRICT_NAV_OPEN=1` | open files on <kbd></kbd>, not <kbd></kbd> or <kbd>l</kbd> | | `NNN_RESTRICT_NAV_OPEN=1` | open files on <kbd></kbd>, not <kbd></kbd> or <kbd>l</kbd> |
| `NNN_RESTRICT_0B=1` | do not open 0-byte files | | `NNN_RESTRICT_0B=1` | do not open 0-byte files |
| `NNN_PLAIN_FILTER=1` | use substring match in filer mode [default: regex] | | `NNN_PLAIN_FILTER=1` | use substring match in filer mode [default: regex] |
| `NNN_TMPFILE=/tmp/nnn` | file to write current open dir path to for cd on quit |
#### Help #### Help

26
nnn.1
View File

@ -259,11 +259,6 @@ To list the file paths copied to memory press \fIy\fR.
The SHELL, EDITOR (VISUAL, if defined) and PAGER environment variables take precedence The SHELL, EDITOR (VISUAL, if defined) and PAGER environment variables take precedence
when dealing with the !, e and p commands respectively. A single combination to arguments is supported for SHELL and PAGER. when dealing with the !, e and p commands respectively. A single combination to arguments is supported for SHELL and PAGER.
.Pp .Pp
\fBNNN_OPENER:\fR specify a custom file opener.
.Bd -literal
export NNN_OPENER=mimeopen
.Ed
.Pp
\fBNNN_BMS:\fR bookmark string as \fIkey_char:location\fR pairs (max 10) separated by \fBNNN_BMS:\fR bookmark string as \fIkey_char:location\fR pairs (max 10) separated by
\fI;\fR: \fI;\fR:
.Bd -literal .Bd -literal
@ -272,10 +267,9 @@ when dealing with the !, e and p commands respectively. A single combination to
NOTE: Bookmark keys should be single-character to use them in combination with the Leader key. NOTE: Bookmark keys should be single-character to use them in combination with the Leader key.
.Ed .Ed
.Pp .Pp
\fBNNN_USE_EDITOR:\fR use EDITOR (VISUAL takes preference, preferably CLI, fallback vi) to handle text \fBNNN_OPENER:\fR specify a custom file opener.
files.
.Bd -literal .Bd -literal
export NNN_USE_EDITOR=1 export NNN_OPENER=mimeopen
.Ed .Ed
.Pp .Pp
\fBNNN_CONTEXT_COLORS:\fR string of color codes for each context, e.g.: \fBNNN_CONTEXT_COLORS:\fR string of color codes for each context, e.g.:
@ -306,6 +300,17 @@ files.
export NNN_NOTE='/home/user/.mynotes' export NNN_NOTE='/home/user/.mynotes'
.Ed .Ed
.Pp .Pp
\fBNNN_TMPFILE:\fR when cd on quit is pressed, the absolute path of the current open directory is written to this file. A wrapper script can read this file and cd into it once the program quits.
.Bd -literal
export NNN_TMPFILE=/tmp/nnn
.Ed
.Pp
\fBNNN_USE_EDITOR:\fR use EDITOR (VISUAL takes preference, preferably CLI, fallback vi) to handle text
files.
.Bd -literal
export NNN_USE_EDITOR=1
.Ed
.Pp
\fBNNN_SHOW_HIDDEN:\fR show hidden files. \fBNNN_SHOW_HIDDEN:\fR show hidden files.
.Bd -literal .Bd -literal
export NNN_SHOW_HIDDEN=1 export NNN_SHOW_HIDDEN=1
@ -330,11 +335,6 @@ files.
.Bd -literal .Bd -literal
export NNN_PLAIN_FILTER=1 export NNN_PLAIN_FILTER=1
.Ed .Ed
.Pp
\fBNNN_TMPFILE:\fR when cd on quit is pressed, the absolute path of the current open directory is written to this file. A wrapper script can read this file and cd into it once the program quits.
.Bd -literal
export NNN_TMPFILE=/tmp/nnn
.Ed
.Sh KNOWN ISSUES .Sh KNOWN ISSUES
If you are using urxvt you might have to set backspace key to DEC. If you are using urxvt you might have to set backspace key to DEC.
.Sh AUTHORS .Sh AUTHORS

217
src/nnn.c
View File

@ -160,7 +160,7 @@ disabledbg()
/* Macro definitions */ /* Macro definitions */
#define VERSION "2.2" #define VERSION "2.2"
#define GENERAL_INFO "License: BSD 2-Clause\nWebpage: https://github.com/jarun/nnn" #define GENERAL_INFO "BSD 2-Clause\nhttps://github.com/jarun/nnn"
#define LEN(x) (sizeof(x) / sizeof(*(x))) #define LEN(x) (sizeof(x) / sizeof(*(x)))
#undef MIN #undef MIN
@ -404,36 +404,53 @@ static const char * const messages[] = {
}; };
/* Supported config env vars */ /* Supported config env vars */
#define NNN_OPENER 0 #define NNN_BMS 0
#define NNN_BMS 1 #define NNN_OPENER 1
#define NNN_USE_EDITOR 2 #define NNN_CONTEXT_COLORS 2
#define NNN_CONTEXT_COLORS 3 #define NNN_IDLE_TIMEOUT 3
#define NNN_IDLE_TIMEOUT 4 #define NNN_COPIER 4
#define NNN_COPIER 5 #define NNN_SCRIPT 5
#define NNN_SCRIPT 6 #define NNN_NOTE 6
#define NNN_NOTE 7 #define NNN_TMPFILE 7
#define NNN_SHOW_HIDDEN 8 #define NNN_USE_EDITOR 8
#define NNN_NO_AUTOSELECT 9 #define NNN_SHOW_HIDDEN 9
#define NNN_RESTRICT_NAV_OPEN 10 #define NNN_NO_AUTOSELECT 10
#define NNN_RESTRICT_0B 11 #define NNN_RESTRICT_NAV_OPEN 11
#define NNN_PLAIN_FILTER 12 #define NNN_RESTRICT_0B 12
#define NNN_TMPFILE 13 #define NNN_PLAIN_FILTER 13
static const char * const envs[] = { static const char * const env_cfg[] = {
"NNN_OPENER",
"NNN_BMS", "NNN_BMS",
"NNN_USE_EDITOR", "NNN_OPENER",
"NNN_CONTEXT_COLORS", "NNN_CONTEXT_COLORS",
"NNN_IDLE_TIMEOUT", "NNN_IDLE_TIMEOUT",
"NNN_COPIER", "NNN_COPIER",
"NNN_SCRIPT", "NNN_SCRIPT",
"NNN_NOTE", "NNN_NOTE",
"NNN_TMPFILE",
"NNN_USE_EDITOR",
"NNN_SHOW_HIDDEN", "NNN_SHOW_HIDDEN",
"NNN_NO_AUTOSELECT", "NNN_NO_AUTOSELECT",
"NNN_RESTRICT_NAV_OPEN", "NNN_RESTRICT_NAV_OPEN",
"NNN_RESTRICT_0B", "NNN_RESTRICT_0B",
"NNN_PLAIN_FILTER", "NNN_PLAIN_FILTER",
"NNN_TMPFILE", };
/* Required env vars */
#define PWD 0
#define SHELL 1
#define SHLVL 2
#define VISUAL 3
#define EDITOR 4
#define PAGER 5
static const char * const envs[] = {
"PWD",
"SHELL",
"SHLVL",
"VISUAL",
"EDITOR",
"PAGER",
}; };
/* Forward declarations */ /* Forward declarations */
@ -880,7 +897,7 @@ static void spawn(const char *file, const char *arg1, const char *arg2, const ch
if (dir != NULL) if (dir != NULL)
status = chdir(dir); status = chdir(dir);
shlvl = getenv("SHLVL"); shlvl = getenv(envs[SHLVL]);
/* Show a marker (to indicate nnn spawned shell) */ /* Show a marker (to indicate nnn spawned shell) */
if (flag & F_MARKER && shlvl != NULL) { if (flag & F_MARKER && shlvl != NULL) {
@ -1573,7 +1590,7 @@ static int xlink(char *suffix, char *path, char *buf, int type)
static bool parsebmstr() static bool parsebmstr()
{ {
int i = 0; int i = 0;
char *bms = getenv(envs[NNN_BMS]); char *bms = getenv(env_cfg[NNN_BMS]);
if (!bms) if (!bms)
return TRUE; return TRUE;
@ -2168,39 +2185,40 @@ static bool show_help(char *path)
int i = 0, fd = mkstemp(g_tmpfpath); int i = 0, fd = mkstemp(g_tmpfpath);
char *start, *end; char *start, *end;
static char helpstr[] = { static char helpstr[] = {
"0\n" "0\n"
"1NAVIGATION\n" "1NAVIGATION\n"
"7↑, k, ^P Up PgUp, ^U Scroll up\n" "5↑, k, ^P Up PgUp, ^U Scroll up\n"
"7↓, j, ^N Down PgDn, ^D Scroll down\n" "5↓, j, ^N Down PgDn, ^D Scroll down\n"
"7←, h, ^H Parent dir ~ Go HOME\n" "5←, h, ^H Parent dir ~ Go HOME\n"
"4↵, →, l, ^M Open file/dir & Start dir\n" "2↵, →, l, ^M Open file/dir & Start dir\n"
"4Home, g, ^A First entry - Last visited dir\n" "2Home, g, ^A First entry - Last visited dir\n"
"5End, G, ^E Last entry . Toggle show hidden\n" "3End, G, ^E Last entry . Toggle show hidden\n"
"e/ Filter Ins, ^T Toggle nav-as-you-type\n" "c/ Filter Ins, ^T Toggle nav-as-you-type\n"
"eb Pin current dir ^W Go to pinned dir\n" "cb Pin current dir ^W Go to pinned dir\n"
"8Tab, ^I Next context d Toggle detail view\n" "6Tab, ^I Next context d Toggle detail view\n"
"a`, ^/ Leader key N, LeadN Go to/create context N\n" "8`, ^/ Leader key N, LeadN Go to/create context N\n"
"cEsc Exit prompt ^L Redraw/clear prompt\n" "aEsc Exit prompt ^L Redraw/clear prompt\n"
"d^G Quit and cd q Quit context\n" "b^G Quit and cd q Quit context\n"
"aQ, ^Q Quit ? Help, config\n" "8Q, ^Q Quit ? Help, config\n"
"1FILES\n" "1FILES\n"
"d^O Open with... n Create new/link\n" "b^O Open with... n Create new/link\n"
"eD File details ^R Rename entry\n" "cD File details ^R Rename entry\n"
"a⎵, ^K Copy entry path r Open dir in vidir\n" "8⎵, ^K Copy entry path r Open dir in vidir\n"
"aY, ^Y Toggle selection y List selection\n" "8Y, ^Y Toggle selection y List selection\n"
"eP Copy selection X Delete selection\n" "cP Copy selection X Delete selection\n"
"eV Move selection ^X Delete entry\n" "cV Move selection ^X Delete entry\n"
"ef Archive entry F List archive\n" "cf Archive entry F List archive\n"
"d^F Extract archive m, M Brief/full media info\n" "b^F Extract archive m, M Brief/full media info\n"
"ee Edit in EDITOR p Open in PAGER\n" "ce Edit in EDITOR p Open in PAGER\n"
"1ORDER TOGGLES\n" "1ORDER TOGGLES\n"
"d^J Disk usage S Apparent du\n" "b^J Disk usage S Apparent du\n"
"et Modification time s Size\n" "ct Modification time s Size\n"
"1MISC\n" "1MISC\n"
"a!, ^] Spawn SHELL in dir C Execute entry\n" "8!, ^] Spawn SHELL in dir C Execute entry\n"
"aR, ^V Run custom script L Lock terminal\n" "8R, ^V Run custom script L Lock terminal\n"
"d^S Run a command N Take note\n"}; "b^S Run a command N Take note\n"};
if (fd == -1) if (fd == -1)
return FALSE; return FALSE;
@ -2222,7 +2240,7 @@ static bool show_help(char *path)
dprintf(fd, "\nVOLUME: %s of ", coolsize(get_fs_info(path, FREE))); dprintf(fd, "\nVOLUME: %s of ", coolsize(get_fs_info(path, FREE)));
dprintf(fd, "%s free\n\n", coolsize(get_fs_info(path, CAPACITY))); dprintf(fd, "%s free\n\n", coolsize(get_fs_info(path, CAPACITY)));
if (getenv(envs[NNN_BMS])) { if (getenv(env_cfg[NNN_BMS])) {
dprintf(fd, "BOOKMARKS\n"); dprintf(fd, "BOOKMARKS\n");
for (; i < BM_MAX; ++i) for (; i < BM_MAX; ++i)
if (bookmark[i].key) if (bookmark[i].key)
@ -2232,55 +2250,38 @@ static bool show_help(char *path)
dprintf(fd, "\n"); dprintf(fd, "\n");
} }
dprintf(fd, "%s: %s\n", envs[NNN_OPENER], opener); for (i = NNN_OPENER; i <= NNN_TMPFILE; ++i) {
if (cfg.useeditor) start = getenv(env_cfg[i]);
dprintf(fd, "%s: 1\n", envs[NNN_USE_EDITOR]); if (start)
start = getenv(envs[NNN_CONTEXT_COLORS]); dprintf(fd, "%s: %s\n", env_cfg[i], start);
if (start) }
dprintf(fd, "%s: %s\n", envs[NNN_CONTEXT_COLORS], start);
if (idletimeout)
dprintf(fd, "%s: %d secs\n", envs[NNN_IDLE_TIMEOUT], idletimeout);
if (copier)
dprintf(fd, "%s: %s\n", envs[NNN_COPIER], copier);
if (g_cppath[0]) if (g_cppath[0])
dprintf(fd, "COPY FILE: %s\n", g_cppath); dprintf(fd, "COPY FILE: %s\n", g_cppath);
if (scriptpath)
dprintf(fd, "%s: %s\n", envs[NNN_SCRIPT], scriptpath); for (i = NNN_USE_EDITOR; i <= NNN_PLAIN_FILTER; ++i) {
start = getenv(envs[NNN_NOTE]); if (getenv(env_cfg[i]))
if (start) dprintf(fd, "%s: 1\n", env_cfg[i]);
dprintf(fd, "%s: %s\n", envs[NNN_NOTE], start); }
if (getenv("NNN_SHOW_HIDDEN"))
dprintf(fd, "%s: 1\n", envs[NNN_SHOW_HIDDEN]);
if (cfg.autoselect)
dprintf(fd, "%s: 1\n", envs[NNN_NO_AUTOSELECT]);
if (cfg.nonavopen)
dprintf(fd, "%s: 1\n", envs[NNN_RESTRICT_NAV_OPEN]);
if (cfg.restrict0b)
dprintf(fd, "%s: 1\n", envs[NNN_RESTRICT_0B]);
if (!cfg.filter_re)
dprintf(fd, "%s: 1\n", envs[NNN_PLAIN_FILTER]);
start = getenv(envs[NNN_TMPFILE]);
if (start)
dprintf(fd, "%s: %s\n", envs[NNN_TMPFILE], start);
dprintf(fd, "\n"); dprintf(fd, "\n");
start = getenv("PWD"); start = getenv(envs[PWD]);
if (start) if (start)
dprintf(fd, "PWD: %s\n", start); dprintf(fd, "%s: %s\n", envs[PWD], start);
if (getenv("SHELL")) if (getenv(envs[SHELL]))
dprintf(fd, "SHELL: %s %s\n", shell, shell_arg); dprintf(fd, "%s: %s %s\n", envs[SHELL], shell, shell_arg);
start = getenv("SHLVL"); start = getenv(envs[SHLVL]);
if (start) if (start)
dprintf(fd, "SHLVL: %s\n", start); dprintf(fd, "%s: %s\n", envs[SHLVL], start);
if (getenv("VISUAL")) if (getenv(envs[VISUAL]))
dprintf(fd, "VISUAL: %s\n", editor); dprintf(fd, "%s: %s\n", envs[VISUAL], editor);
else if (getenv("EDITOR")) else if (getenv(envs[EDITOR]))
dprintf(fd, "EDITOR: %s\n", editor); dprintf(fd, "%s: %s\n", envs[EDITOR], editor);
if (getenv("PAGER")) if (getenv(envs[PAGER]))
dprintf(fd, "PAGER: %s %s\n", pager, pager_arg); dprintf(fd, "%s: %s %s\n", envs[PAGER], pager, pager_arg);
dprintf(fd, "\nVersion: %s\n%s\n", VERSION, GENERAL_INFO); dprintf(fd, "\nv%s\n%s\n", VERSION, GENERAL_INFO);
close(fd); close(fd);
spawn(pager, pager_arg, g_tmpfpath, NULL, F_NORMAL); spawn(pager, pager_arg, g_tmpfpath, NULL, F_NORMAL);
@ -3208,7 +3209,7 @@ nochange:
spawn(pager, pager_arg, dents[cur].name, path, F_NORMAL); spawn(pager, pager_arg, dents[cur].name, path, F_NORMAL);
break; break;
case SEL_NOTE: case SEL_NOTE:
tmp = getenv(envs[NNN_NOTE]); tmp = getenv(env_cfg[NNN_NOTE]);
if (!tmp) { if (!tmp) {
printmsg("set NNN_NOTE"); printmsg("set NNN_NOTE");
goto nochange; goto nochange;
@ -3682,7 +3683,7 @@ nochange:
return; return;
} }
tmp = getenv(envs[NNN_TMPFILE]); tmp = getenv(env_cfg[NNN_TMPFILE]);
if (!tmp) { if (!tmp) {
printmsg("set NNN_TMPFILE"); printmsg("set NNN_TMPFILE");
goto nochange; goto nochange;
@ -3750,7 +3751,7 @@ static void usage(void)
" -S disk usage mode\n" " -S disk usage mode\n"
" -v show version\n" " -v show version\n"
" -h show help\n\n" " -h show help\n\n"
"Version: %s\n%s\n", VERSION, GENERAL_INFO); "v%s\n%s\n", VERSION, GENERAL_INFO);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -3815,7 +3816,7 @@ int main(int argc, char *argv[])
/* Get the context colors; copier used as tmp var */ /* Get the context colors; copier used as tmp var */
if (cfg.showcolor) { if (cfg.showcolor) {
copier = xgetenv(envs[NNN_CONTEXT_COLORS], "4444"); copier = xgetenv(env_cfg[NNN_CONTEXT_COLORS], "4444");
opt = 0; opt = 0;
while (*copier && opt < CTX_MAX) { while (*copier && opt < CTX_MAX) {
if (*copier < '0' || *copier > '7') { if (*copier < '0' || *copier > '7') {
@ -3836,7 +3837,7 @@ int main(int argc, char *argv[])
/* Parse bookmarks string */ /* Parse bookmarks string */
if (!parsebmstr()) { if (!parsebmstr()) {
fprintf(stderr, "%s: 1 char per key\n", envs[NNN_BMS]); fprintf(stderr, "%s: 1 char per key\n", env_cfg[NNN_BMS]);
return 1; return 1;
} }
@ -3863,26 +3864,26 @@ int main(int argc, char *argv[])
/* Increase current open file descriptor limit */ /* Increase current open file descriptor limit */
open_max = max_openfds(); open_max = max_openfds();
if (getuid() == 0 || getenv(envs[NNN_SHOW_HIDDEN])) if (getuid() == 0 || getenv(env_cfg[NNN_SHOW_HIDDEN]))
cfg.showhidden = 1; cfg.showhidden = 1;
/* Edit text in EDITOR, if opted */ /* Edit text in EDITOR, if opted */
if (getenv(envs[NNN_USE_EDITOR])) if (getenv(env_cfg[NNN_USE_EDITOR]))
cfg.useeditor = 1; cfg.useeditor = 1;
/* Get VISUAL/EDITOR */ /* Get VISUAL/EDITOR */
editor = xgetenv("VISUAL", xgetenv("EDITOR", "vi")); editor = xgetenv(envs[VISUAL], xgetenv(envs[EDITOR], "vi"));
/* Get PAGER */ /* Get PAGER */
pager = xgetenv("PAGER", "less"); pager = xgetenv(envs[PAGER], "less");
getprogarg(pager, &pager_arg); getprogarg(pager, &pager_arg);
/* Get SHELL */ /* Get SHELL */
shell = xgetenv("SHELL", "sh"); shell = xgetenv(envs[SHELL], "sh");
getprogarg(shell, &shell_arg); getprogarg(shell, &shell_arg);
/* Setup script execution */ /* Setup script execution */
scriptpath = getenv(envs[NNN_SCRIPT]); scriptpath = getenv(env_cfg[NNN_SCRIPT]);
#ifdef LINUX_INOTIFY #ifdef LINUX_INOTIFY
/* Initialize inotify */ /* Initialize inotify */
@ -3900,17 +3901,17 @@ int main(int argc, char *argv[])
#endif #endif
/* Get custom opener, if set */ /* Get custom opener, if set */
opener = xgetenv(envs[NNN_OPENER], utils[OPENER]); opener = xgetenv(env_cfg[NNN_OPENER], utils[OPENER]);
/* Get locker wait time, if set; copier used as tmp var */ /* Get locker wait time, if set; copier used as tmp var */
copier = getenv(envs[NNN_IDLE_TIMEOUT]); copier = getenv(env_cfg[NNN_IDLE_TIMEOUT]);
if (copier) { if (copier) {
opt = atoi(copier); opt = atoi(copier);
idletimeout = opt * ((opt > 0) - (opt < 0)); idletimeout = opt * ((opt > 0) - (opt < 0));
} }
/* Get the clipboard copier, if set */ /* Get the clipboard copier, if set */
copier = getenv(envs[NNN_COPIER]); copier = getenv(env_cfg[NNN_COPIER]);
if (getenv("HOME")) if (getenv("HOME"))
g_tmpfplen = xstrlcpy(g_tmpfpath, getenv("HOME"), HOME_LEN_MAX); g_tmpfplen = xstrlcpy(g_tmpfpath, getenv("HOME"), HOME_LEN_MAX);
@ -3925,19 +3926,19 @@ int main(int argc, char *argv[])
} }
/* Disable auto-select if opted */ /* Disable auto-select if opted */
if (getenv(envs[NNN_NO_AUTOSELECT])) if (getenv(env_cfg[NNN_NO_AUTOSELECT]))
cfg.autoselect = 0; cfg.autoselect = 0;
/* Disable opening files on right arrow and `l` */ /* Disable opening files on right arrow and `l` */
if (getenv(envs[NNN_RESTRICT_NAV_OPEN])) if (getenv(env_cfg[NNN_RESTRICT_NAV_OPEN]))
cfg.nonavopen = 1; cfg.nonavopen = 1;
/* Restrict opening of 0-byte files */ /* Restrict opening of 0-byte files */
if (getenv(envs[NNN_RESTRICT_0B])) if (getenv(env_cfg[NNN_RESTRICT_0B]))
cfg.restrict0b = 1; cfg.restrict0b = 1;
/* Use string-comparison in filter mode */ /* Use string-comparison in filter mode */
if (getenv(envs[NNN_PLAIN_FILTER])) { if (getenv(env_cfg[NNN_PLAIN_FILTER])) {
cfg.filter_re = 0; cfg.filter_re = 0;
filterfn = &visible_str; filterfn = &visible_str;
} }