| trash-cli | optional | trash files (default action: delete) |
| vlock (Linux), bashlock (macOS), lock(1) (BSD) | optional | terminal locker (fallback: [cmatrix](https://github.com/abishekvashok/cmatrix)) |
| advcpmv (Linux) ([integration](https://github.com/jarun/nnn/wiki/Advanced-use-cases#show-cp-mv-progress)) | optional | copy, move progress |
+| fortune | optional | random quotes in help screen |
| `$VISUAL` (else `$EDITOR`), `$PAGER`, `$SHELL` | optional | fallback vi, less, sh |
#### From a package manager
return spawn("which", util, NULL, NULL, F_NORMAL | F_NOTRACE) == 0;
}
+static void pipetofd(char *cmd, int fd)
+{
+ FILE *fp = popen(cmd, "r");
+
+ if (fp) {
+ while (fgets(g_buf, CMD_LEN_MAX - 1, fp))
+ dprintf(fd, "%s", g_buf);
+ pclose(fp);
+ }
+}
+
/*
* Follows the stat(1) output closely
*/
int fd;
char *p, *begin = g_buf;
size_t r;
- FILE *fp;
fd = create_tmp_file();
if (fd == -1)
g_buf[r - 1] = '\0';
DPRINTF_S(g_buf);
- fp = popen(g_buf, "r");
- if (fp) {
- while (fgets(g_buf, CMD_LEN_MAX - 1, fp))
- dprintf(fd, "%s", g_buf);
- pclose(fp);
- }
+ pipetofd(g_buf, fd);
if (S_ISREG(sb->st_mode)) {
/* Show file(1) output */
if (fd == -1)
return;
+ if (getutil("fortune"))
+ pipetofd("fortune -s", fd);
+
start = end = helpstr;
while (*end) {
if (*end == '\n') {
break;
case SEL_NEW:
r = get_input("create 'f'(ile) / 'd'(ir) / 's'(ym) / 'h'(ard)?");
- if (r == 'f' || r == 'd') {
+ if (r == 'f' || r == 'd')
tmp = xreadline(NULL, "name: ");
- } else if (r == 's' || r == 'h') {
+ else if (r == 's' || r == 'h')
tmp = xreadline(NULL, "link suffix [@ for none]: ");
- } else
+ else
tmp = NULL;
break;
default: /* SEL_RENAME */
if (r == 'f') {
r = openat(fd, tmp, O_CREAT, 0666);
close(r);
- } else if (r == 'd') {
+ } else if (r == 'd')
r = mkdirat(fd, tmp, 0777);
- } else if (r == 's' || r == 'h') {
+ else if (r == 's' || r == 'h') {
if (tmp[0] == '@' && tmp[1] == '\0')
tmp[0] = '\0';
r = xlink(tmp, path, newpath, &presel, r);