aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-11-08 11:06:57 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-11-08 11:06:57 +0530
commit729c13b162a18b473d0988c3f8bbe4471dcfc1b3 (patch)
tree91633daecd40b85d2cf9006b3360edef66ee059d
parent99a9d63ee7cd15ea5eac1c29c2bddae2141b5044 (diff)
downloadnnn-729c13b162a18b473d0988c3f8bbe4471dcfc1b3.tar.gz
Support up to 2 args for launcher
-rw-r--r--README.md2
-rw-r--r--nnn.c27
2 files changed, 23 insertions, 6 deletions
diff --git a/README.md b/README.md
index de27487..0cd1473 100644
--- a/README.md
+++ b/README.md
@@ -107,7 +107,7 @@ Have fun with it! Missing a feature? Want to contribute? Head to the rolling [To
- Copy absolute file paths with quotes
- Change directory at exit (*easy* shell integration)
- Open any file in EDITOR (fallback vi) or PAGER (fallback less)
- - GUI app launcher
+ - GUI app launcher (maximum 2 space-separated arguments)
- Terminal screensaver/locker integration
- Unicode support
- Highly optimized code, minimal resource usage
diff --git a/nnn.c b/nnn.c
index f03abb0..66c9d16 100644
--- a/nnn.c
+++ b/nnn.c
@@ -2046,9 +2046,6 @@ static int show_help(char *path)
return 0;
}
-static int sum_bsizes(const char */*fpath*/, const struct stat *sb,
- int typeflag, struct FTW */*ftwbuf*/);
-
static int sum_bsizes(const char *fpath, const struct stat *sb,
int typeflag, struct FTW *ftwbuf)
{
@@ -2984,7 +2981,8 @@ nochange:
break;
/* Allow only relative, same dir paths */
- if (tmp[0] == '/' || strcmp(xbasename(tmp), tmp) != 0) {
+ if ((sel != SEL_LAUNCH) &&
+ (tmp[0] == '/' || strcmp(xbasename(tmp), tmp) != 0)) {
printmsg(messages[STR_INPUT_ID]);
goto nochange;
}
@@ -3005,7 +3003,26 @@ nochange:
}
if (sel == SEL_LAUNCH) {
- spawn(tmp, NULL, NULL, path, F_NOWAIT | F_NOTRACE);
+ uint args = 0;
+ char *ptr = tmp, *ptr1 = NULL, *ptr2 = NULL;
+
+ while (*ptr) {
+ if (*ptr == ' ') {
+ *ptr = '\0';
+ if (args == 0)
+ ptr1 = ptr + 1;
+ else if (args == 1)
+ ptr2 = ptr + 1;
+ else
+ break;
+
+ ++args;
+ }
+
+ ++ptr;
+ }
+
+ spawn(tmp, ptr1, ptr2, path, F_NOWAIT | F_NOTRACE);
break;
}