aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-04-25 23:19:47 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-04-25 23:20:04 +0530
commit0fd6a392db55847bb5fa83436a10d6861693c91d (patch)
treeda4c29a72db613d34ea559ee2db0b2c394f8effb
parentcbd38ef8fee82e1c09b032f7bd9e226ed4423c36 (diff)
downloadnnn-0fd6a392db55847bb5fa83436a10d6861693c91d.tar.gz
Honour EDITOR and PAGER everywhere
-rw-r--r--README.md2
-rw-r--r--nnn.c15
2 files changed, 9 insertions, 8 deletions
diff --git a/README.md b/README.md
index 38c99f8..2d72954 100644
--- a/README.md
+++ b/README.md
@@ -204,7 +204,7 @@ nnn is designed to play files using multiple strategies (in order of decreasing
- [zathura](https://pwmt.org/projects/zathura/) - pdf
- vim - plain text
- to add, remove recognized extensions in nnn, see [how to change file associations](#change-file-associations)
- - If a file without any extension is a plain text file, it is opened in vi
+ - If a file without any extension is a plain text file, it is opened in EDITOR (fallback vi)
- Set `NNN_FALLBACK_OPENER` as the fallback opener. E.g.:
export NNN_FALLBACK_OPENER=xdg-open
diff --git a/nnn.c b/nnn.c
index 031ffe2..49edbe6 100644
--- a/nnn.c
+++ b/nnn.c
@@ -930,7 +930,7 @@ show_stats(char* fpath, char* fname, struct stat *sb)
dprintf(fd, "\n\n");
close(fd);
- sprintf(buf, "cat %s | less", tmp);
+ sprintf(buf, "cat %s | %s", tmp, xgetenv("PAGER", "less"));
fd = system(buf);
unlink(tmp);
@@ -947,9 +947,9 @@ show_mediainfo(const char* fpath, int full)
return -1;
if (full)
- sprintf(buf, "mediainfo -f \"%s\" 2>&1 | less", fpath);
+ sprintf(buf, "mediainfo -f \"%s\" 2>&1 | %s", fpath, xgetenv("PAGER", "less"));
else
- sprintf(buf, "mediainfo \"%s\" 2>&1 | less", fpath);
+ sprintf(buf, "mediainfo \"%s\" 2>&1 | %s", fpath, xgetenv("PAGER", "less"));
return system(buf);
}
@@ -957,7 +957,7 @@ show_mediainfo(const char* fpath, int full)
static int
show_help(void)
{
- char helpstr[] = ("echo \"\
+ char helpstr[2048] = ("echo \"\
Key | Function\n\
-+-\n\
Up, k, ^P | Previous entry\n\
@@ -990,9 +990,9 @@ show_help(void)
^L | Force a redraw\n\
? | Toggle help screen\n\
q | Quit\n\
- Q | Quit and change directory\n\n\" | less");
+ Q | Quit and change directory\n\n\" | ");
- return system(helpstr);
+ return system(strcat(helpstr, xgetenv("PAGER", "less")));
}
static int
@@ -1404,7 +1404,8 @@ nochange:
if (strstr(cmd, "ASCII text") != NULL) {
exitcurses();
- spawn("vi", newpath, NULL, 0);
+ run = xgetenv("EDITOR", "vi");
+ spawn(run, newpath, NULL, 0);
initcurses();
continue;
} else if (fb_opener) {