aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-04-06 06:54:06 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-04-06 06:54:06 +0530
commit4997f047cc8f3b77781cc7a99471641afd8aee6b (patch)
treea10faf57d02caf3b32be8438f5338e900a528247
parent650e51d2e718a1a4f7debf00d5b8bc685bd4fd06 (diff)
downloadnnn-4997f047cc8f3b77781cc7a99471641afd8aee6b.tar.gz
Support only scripts directory
-rw-r--r--README.md13
-rw-r--r--nnn.16
-rw-r--r--src/nnn.c20
3 files changed, 12 insertions, 27 deletions
diff --git a/README.md b/README.md
index 4a03127..1e9726d 100644
--- a/README.md
+++ b/README.md
@@ -107,7 +107,6 @@ Have as many scripts as you want to extend the power of `nnn`! Pick from the [sc
- Per-context directory color (default: blue)
- Spawn a shell in the current directory
- Launch applications, run a command
- - Run custom scripts in the current directory
- Repository of custom scripts
- Run current file as executable
- Change directory at exit (*easy* shell integration)
@@ -264,7 +263,7 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
^W Random s Size t Time modified
MISC
! ^] Spawn SHELL C Execute entry
- R ^V Run/pick script L Lock terminal
+ R ^V Run script L Lock terminal
^P Prompt ^N Note = Launcher
```
@@ -382,7 +381,7 @@ The following indicators are used in the detail view:
| `NNN_CONTEXT_COLORS='1234'` | specify per context color [default: '4444' (all blue)] |
| `NNN_IDLE_TIMEOUT=300` | idle seconds before locking terminal [default: disabled] |
| `NNN_COPIER='copier.sh'` | system clipboard copier script [default: none] |
-| `NNN_SCRIPT=/home/user/scripts[/script.sh]` | path to script dir or a single script |
+| `NNN_SCRIPT_DIR=/home/user/scripts` | absolute path to script dir |
| `NNN_NOTE=/home/user/Dropbox/Public/notes` | path to note file [default: none] |
| `NNN_TMPFILE=/tmp/nnn` | file to write current open dir path to for cd on quit |
| `NNN_USE_EDITOR=1` | Open text files in `$EDITOR` (`$VISUAL`, if defined; fallback vi) |
@@ -404,13 +403,9 @@ To lookup keyboard shortcuts at runtime, press <kbd>?</kbd>.
Copy the scripts of your interest from the [user-scripts](https://github.com/jarun/nnn/tree/master/user-scripts) directory and let `nnn` know the location:
- export NNN_SCRIPT=/absolute/path/to/scripts_dir
+ export NNN_SCRIPT_DIR=/absolute/path/to/scripts_dir
-Use the run/pick script shortcut to jump to the script directory and pick a script. Repeating the same shortcut cancels the operation and puts you back in the original directory.
-
-In case you need only one script:
-
- export NNN_SCRIPT=/absolute/path/to/script
+Use the run script shortcut to jump to the script directory and pick a script. Repeating the same shortcut cancels the operation and puts you back in the original directory.
If you have an interesting script feel free to raise a PR.
diff --git a/nnn.1 b/nnn.1
index 7ecee23..11d44e4 100644
--- a/nnn.1
+++ b/nnn.1
@@ -174,11 +174,9 @@ when dealing with the !, e and p commands respectively. A single combination to
The path is shown in the help and configuration screen.
.Ed
.Pp
-\fBNNN_SCRIPT:\fR \fIabsolute\fR path to a directory to select a script from or a single script to invoke with currently selected file name as argument 1.
+\fBNNN_SCRIPT_DIR:\fR \fIabsolute\fR path to script directory. Selected script is invoked with currently selected file name as argument 1.
.Bd -literal
- export NNN_SCRIPT=/home/user/scripts
- OR
- export NNN_SCRIPT=/usr/local/bin/nscript.sh
+ export NNN_SCRIPT_DIR=/absolute/path/to/scripts_dir
.Ed
.Pp
\fBNNN_NOTE:\fR \fIabsolute\fR path to a note file.
diff --git a/src/nnn.c b/src/nnn.c
index 46a07c3..4a24492 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -357,7 +357,7 @@ static const char * const messages[] = {
#define NNN_CONTEXT_COLORS 2
#define NNN_IDLE_TIMEOUT 3
#define NNN_COPIER 4
-#define NNN_SCRIPT 5
+#define NNN_SCRIPT_DIR 5
#define NNN_NOTE 6
#define NNN_TMPFILE 7
#define NNNLVL 8 /* strings end here */
@@ -377,7 +377,7 @@ static const char * const env_cfg[] = {
"NNN_CONTEXT_COLORS",
"NNN_IDLE_TIMEOUT",
"NNN_COPIER",
- "NNN_SCRIPT",
+ "NNN_SCRIPT_DIR",
"NNN_NOTE",
"NNN_TMPFILE",
"NNNLVL",
@@ -2425,7 +2425,7 @@ static bool show_help(const char *path)
"b^W Random s Size t Time modified\n"
"1MISC\n"
"9! ^] Spawn SHELL C Execute entry\n"
- "9R ^V Run/pick script L Lock terminal\n"
+ "9R ^V Run script L Lock terminal\n"
"b^P Prompt ^N Note = Launcher\n"};
if (g_tmpfpath[0])
@@ -2884,7 +2884,7 @@ static void browse(char *ipath)
struct stat sb;
char *path, *lastdir, *lastname;
char *dir, *tmp;
- char *scriptpath = getenv(env_cfg[NNN_SCRIPT]);
+ char *scriptpath = getenv(env_cfg[NNN_SCRIPT_DIR]);
atexit(dentfree);
@@ -3799,7 +3799,7 @@ nochange:
break;
case SEL_SCRIPT:
if (!scriptpath) {
- printwait("set NNN_SCRIPT", &presel);
+ printwait("set NNN_SCRIPT_DIR", &presel);
goto nochange;
}
@@ -3808,18 +3808,10 @@ nochange:
goto nochange;
}
- /* Regular script file */
- if (S_ISREG(sb.st_mode)) {
- tmp = ndents ? dents[cur].name : NULL;
- spawn(scriptpath, tmp, NULL, path, F_NORMAL);
- break;
- }
-
- /* Must be a directory or a regular file */
+ /* Must be a directory */
if (!S_ISDIR(sb.st_mode))
break;
- /* Script directory */
cfg.runscript ^= 1;
if (!cfg.runscript && rundir[0]) {
/*