aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-04-24 10:12:24 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-04-24 18:12:18 +0530
commitbc572df55a35cc738466996abe26339fc5acaeda (patch)
tree3798d449e971b9265a79a901ccc8b7ca37dd5f8d /src
parent752bc67de03d158ece3f0fb43f6f2a3e6b2011b9 (diff)
downloadnnn-bc572df55a35cc738466996abe26339fc5acaeda.tar.gz
NNN_SEL: custom selection file
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 86b09d4..ef1b50a 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -579,8 +579,9 @@ static const char * const messages[] = {
#define NNNLVL 5
#define NNN_PIPE 6
#define NNN_MCLICK 7
-#define NNN_ARCHIVE 8 /* strings end here */
-#define NNN_TRASH 9 /* flags begin here */
+#define NNN_SEL 8
+#define NNN_ARCHIVE 9 /* strings end here */
+#define NNN_TRASH 10 /* flags begin here */
static const char * const env_cfg[] = {
"NNN_OPTS",
@@ -591,6 +592,7 @@ static const char * const env_cfg[] = {
"NNNLVL",
"NNN_PIPE",
"NNN_MCLICK",
+ "NNN_SEL",
"NNN_ARCHIVE",
"NNN_TRASH",
};
@@ -6612,16 +6614,23 @@ static bool setup_config(void)
/* Set selection file path */
if (!cfg.picker) {
- /* Length of "/.config/nnn/.selection" */
- selpath = (char *)malloc(len + 3);
+ char *env_sel = xgetenv(env_cfg[NNN_SEL], NULL);
+ if (env_sel)
+ selpath = xstrdup(env_sel);
+ else
+ /* Length of "/.config/nnn/.selection" */
+ selpath = (char *)malloc(len + 3);
+
if (!selpath) {
xerror();
return FALSE;
}
- r = xstrsncpy(selpath, cfgdir, len + 3);
- xstrsncpy(selpath + r - 1, "/.selection", 12);
- DPRINTF_S(selpath);
+ if (!env_sel) {
+ r = xstrsncpy(selpath, cfgdir, len + 3);
+ xstrsncpy(selpath + r - 1, "/.selection", 12);
+ DPRINTF_S(selpath);
+ }
}
return TRUE;