mirror of
https://github.com/jarun/nnn.git
synced 2025-02-26 03:01:32 +00:00
Force undetachable edits in EDITOR
This commit is contained in:
parent
9b37c9edb1
commit
ca7405311f
3 changed files with 16 additions and 7 deletions
|
@ -172,6 +172,7 @@ optional args:
|
||||||
-c cli-only opener
|
-c cli-only opener
|
||||||
-d detail mode
|
-d detail mode
|
||||||
-e name load session by name
|
-e name load session by name
|
||||||
|
-E EDITOR for undetached edits
|
||||||
-f run filter as cmd on prompt key
|
-f run filter as cmd on prompt key
|
||||||
-H show hidden files
|
-H show hidden files
|
||||||
-i nav-as-you-type mode
|
-i nav-as-you-type mode
|
||||||
|
|
|
@ -20,7 +20,7 @@ prompt="device name ['l' lists]: "
|
||||||
|
|
||||||
lsblk
|
lsblk
|
||||||
|
|
||||||
printf "\nMake sure you aren't still in the mounted device."
|
printf "\nEnsure you aren't still in the mounted device.\n"
|
||||||
printf "%s" "$prompt"
|
printf "%s" "$prompt"
|
||||||
read -r dev
|
read -r dev
|
||||||
|
|
||||||
|
|
20
src/nnn.c
20
src/nnn.c
|
@ -226,7 +226,7 @@ typedef struct {
|
||||||
uint selmode : 1; /* Set when selecting files */
|
uint selmode : 1; /* Set when selecting files */
|
||||||
uint showdetail : 1; /* Clear to show fewer file info */
|
uint showdetail : 1; /* Clear to show fewer file info */
|
||||||
uint ctxactive : 1; /* Context active or not */
|
uint ctxactive : 1; /* Context active or not */
|
||||||
uint reserved : 5;
|
uint reserved : 4;
|
||||||
/* The following settings are global */
|
/* The following settings are global */
|
||||||
uint curctx : 2; /* Current context number */
|
uint curctx : 2; /* Current context number */
|
||||||
uint dircolor : 1; /* Current status of dir color */
|
uint dircolor : 1; /* Current status of dir color */
|
||||||
|
@ -243,6 +243,7 @@ typedef struct {
|
||||||
uint trash : 1; /* Move removed files to trash */
|
uint trash : 1; /* Move removed files to trash */
|
||||||
uint mtime : 1; /* Use modification time (else access time) */
|
uint mtime : 1; /* Use modification time (else access time) */
|
||||||
uint cliopener : 1; /* All-CLI app opener */
|
uint cliopener : 1; /* All-CLI app opener */
|
||||||
|
uint waitedit : 1; /* For ops that can't be detached, used EDITOR */
|
||||||
} settings;
|
} settings;
|
||||||
|
|
||||||
/* Contexts or workspaces */
|
/* Contexts or workspaces */
|
||||||
|
@ -293,6 +294,7 @@ static settings cfg = {
|
||||||
0, /* trash */
|
0, /* trash */
|
||||||
1, /* mtime */
|
1, /* mtime */
|
||||||
0, /* cliopener */
|
0, /* cliopener */
|
||||||
|
0, /* waitedit */
|
||||||
};
|
};
|
||||||
|
|
||||||
static context g_ctx[CTX_MAX] __attribute__ ((aligned));
|
static context g_ctx[CTX_MAX] __attribute__ ((aligned));
|
||||||
|
@ -307,6 +309,7 @@ static char *pluginstr;
|
||||||
static char *opener;
|
static char *opener;
|
||||||
static char *copier;
|
static char *copier;
|
||||||
static char *editor;
|
static char *editor;
|
||||||
|
static char *enveditor;
|
||||||
static char *pager;
|
static char *pager;
|
||||||
static char *shell;
|
static char *shell;
|
||||||
static char *home;
|
static char *home;
|
||||||
|
@ -1025,7 +1028,7 @@ static bool editselection(void)
|
||||||
seltofile(fd, NULL);
|
seltofile(fd, NULL);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
spawn(editor, g_tmpfpath, NULL, NULL, F_CLI);
|
spawn((cfg.waitedit ? enveditor : editor), g_tmpfpath, NULL, NULL, F_CLI);
|
||||||
|
|
||||||
fd = open(g_tmpfpath, O_RDONLY);
|
fd = open(g_tmpfpath, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
@ -1405,7 +1408,7 @@ static bool cpmv_rename(int choice, const char *path)
|
||||||
snprintf(buf, sizeof(buf), cpmvformatcmd, g_tmpfpath);
|
snprintf(buf, sizeof(buf), cpmvformatcmd, g_tmpfpath);
|
||||||
spawn(utils[UTIL_SH_EXEC], buf, NULL, path, F_CLI);
|
spawn(utils[UTIL_SH_EXEC], buf, NULL, path, F_CLI);
|
||||||
|
|
||||||
spawn(editor, g_tmpfpath, NULL, path, F_CLI);
|
spawn((cfg.waitedit ? enveditor : editor), g_tmpfpath, NULL, path, F_CLI);
|
||||||
|
|
||||||
fd = open(g_tmpfpath, O_RDONLY);
|
fd = open(g_tmpfpath, O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
|
@ -1523,7 +1526,7 @@ static bool batch_rename(const char *path)
|
||||||
if (dir) /* Don't retain dir entries in selection */
|
if (dir) /* Don't retain dir entries in selection */
|
||||||
selbufpos = 0;
|
selbufpos = 0;
|
||||||
|
|
||||||
spawn(editor, g_tmpfpath, NULL, path, F_CLI);
|
spawn((cfg.waitedit ? enveditor : editor), g_tmpfpath, NULL, path, F_CLI);
|
||||||
|
|
||||||
/* Reopen file descriptor to get updated contents */
|
/* Reopen file descriptor to get updated contents */
|
||||||
fd2 = open(g_tmpfpath, O_RDONLY);
|
fd2 = open(g_tmpfpath, O_RDONLY);
|
||||||
|
@ -5308,6 +5311,7 @@ static void usage(void)
|
||||||
" -c cli-only opener\n"
|
" -c cli-only opener\n"
|
||||||
" -d detail mode\n"
|
" -d detail mode\n"
|
||||||
" -e name load session by name\n"
|
" -e name load session by name\n"
|
||||||
|
" -E EDITOR for undetached edits\n"
|
||||||
" -f run filter as cmd on prompt key\n"
|
" -f run filter as cmd on prompt key\n"
|
||||||
" -H show hidden files\n"
|
" -H show hidden files\n"
|
||||||
" -i nav-as-you-type mode\n"
|
" -i nav-as-you-type mode\n"
|
||||||
|
@ -5462,7 +5466,7 @@ int main(int argc, char *argv[])
|
||||||
bool progress = FALSE;
|
bool progress = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "HSKiab:cde:fnop:rstvh")) != -1) {
|
while ((opt = getopt(argc, argv, "HSKiab:cde:Efnop:rstvh")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'S':
|
case 'S':
|
||||||
cfg.blkorder = 1;
|
cfg.blkorder = 1;
|
||||||
|
@ -5487,6 +5491,9 @@ int main(int argc, char *argv[])
|
||||||
case 'e':
|
case 'e':
|
||||||
session = optarg;
|
session = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'E':
|
||||||
|
cfg.waitedit = 1;
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
cfg.filtercmd = 1;
|
cfg.filtercmd = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -5645,7 +5652,8 @@ int main(int argc, char *argv[])
|
||||||
cfg.useeditor = 1;
|
cfg.useeditor = 1;
|
||||||
|
|
||||||
/* Get VISUAL/EDITOR */
|
/* Get VISUAL/EDITOR */
|
||||||
editor = xgetenv(envs[ENV_VISUAL], xgetenv(envs[ENV_EDITOR], "vi"));
|
enveditor = xgetenv(envs[ENV_EDITOR], "vi");
|
||||||
|
editor = xgetenv(envs[ENV_VISUAL], enveditor);
|
||||||
DPRINTF_S(getenv(envs[ENV_VISUAL]));
|
DPRINTF_S(getenv(envs[ENV_VISUAL]));
|
||||||
DPRINTF_S(getenv(envs[ENV_EDITOR]));
|
DPRINTF_S(getenv(envs[ENV_EDITOR]));
|
||||||
DPRINTF_S(editor);
|
DPRINTF_S(editor);
|
||||||
|
|
Loading…
Add table
Reference in a new issue