Browse Source

Use run a command to launch apps

master
Arun Prakash Jana 6 years ago
parent
commit
cc34b977da
No known key found for this signature in database GPG Key ID: A75979F35C080412
4 changed files with 22 additions and 54 deletions
  1. +10
    -6
      README.md
  2. +5
    -7
      nnn.1
  3. +7
    -38
      src/nnn.c
  4. +0
    -3
      src/nnn.h

+ 10
- 6
README.md View File

@@ -71,6 +71,7 @@ We need contributors. Please visit the ToDo list.
- [(neo)vim plugin](#neovim-plugin) - [(neo)vim plugin](#neovim-plugin)
- [run custom scripts](#run-custom-scripts) - [run custom scripts](#run-custom-scripts)
- [sample scripts](#sample-scripts) - [sample scripts](#sample-scripts)
- [launch applications](#launch-applications)
- [change dir color](#change-dir-color) - [change dir color](#change-dir-color)
- [integrate patool](#integrate-patool) - [integrate patool](#integrate-patool)
- [lftp transfers](#lftp-transfers) - [lftp transfers](#lftp-transfers)
@@ -116,12 +117,11 @@ We need contributors. Please visit the ToDo list.
- Batch rename/move/delete (needs vidir) - Batch rename/move/delete (needs vidir)
- Show directories in custom color (default: blue) - Show directories in custom color (default: blue)
- Spawn a subshell in the current directory - Spawn a subshell in the current directory
- Run a command
- Run a command, launch applications
- Run custom scripts in the current directory - Run custom scripts in the current directory
- Run current file as executable - Run current file as executable
- Change directory at exit (*easy* shell integration) - Change directory at exit (*easy* shell integration)
- Edit file in EDITOR or open in PAGER - Edit file in EDITOR or open in PAGER
- Application launcher
- Terminal locker integration - Terminal locker integration
- Unicode support - Unicode support
- Highly optimized, static analysis integrated code - Highly optimized, static analysis integrated code
@@ -248,9 +248,9 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
^J Disk usage S Apparent du ^J Disk usage S Apparent du
t Modification time s Size t Modification time s Size
MISC MISC
!, ^] Spawn SHELL in dir o Launch app
^S Run a command R Run custom script
C Execute entry L Lock terminal
!, ^] Spawn SHELL in dir C Execute entry
R Run custom script L Lock terminal
^S Run a command
``` ```


Help & settings, file details, media info and archive listing are shown in the PAGER. Please use the PAGER-specific keys in these screens. Help & settings, file details, media info and archive listing are shown in the PAGER. Please use the PAGER-specific keys in these screens.
@@ -353,7 +353,7 @@ Arguments to the `$EDITOR`, `$PAGER` and `$SHELL` should be combined together, e


export EDITOR='vim -xR' export EDITOR='vim -xR'


The option `open with` takes 1 combined argument and `launcher` takes 2.
The option `open with` takes 1 combined argument.


#### Help #### Help


@@ -489,6 +489,10 @@ Press <kbd>R</kbd> to run the script in the current directory. You can also use


xdg-open $(find -type f | fzy) >/dev/null 2>&1 xdg-open $(find -type f | fzy) >/dev/null 2>&1


#### launch applications

Applications can be launched from the _run a command_ prompt. Use `&` to launch GUI applications in the background.

#### change dir color #### change dir color


The default color for directories is blue. Option `-c` accepts color codes from 0 to 7 to use a different color: The default color for directories is blue. Option `-c` accepts color codes from 0 to 7 to use a different color:


+ 5
- 7
nnn.1 View File

@@ -18,7 +18,7 @@
.Op Ar PATH .Op Ar PATH
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
(Noice is Not Noice) is a performance-optimized, feature-packed fork of noice (http://git.2f30.org/noice/) with seamless desktop integration, simplified navigation, \fInavigate-as-you-type\fR mode, disk usage analyzer mode, bookmarks, contexts, application launcher, familiar navigation shortcuts, subshell spawning and much more. It remains a simple and efficient file manager that stays out of your way.
(Noice is Not Noice) is a performance-optimized, feature-packed fork of noice (http://git.2f30.org/noice/) with seamless desktop integration, simplified navigation, \fInavigate-as-you-type\fR mode with auto select, disk usage analyzer mode, bookmarks, contexts, application launcher, familiar navigation shortcuts, subshell spawning and much more. It remains a simple and efficient file manager that stays out of your way.
.Pp .Pp
.Nm .Nm
opens the current working directory by default if opens the current working directory by default if
@@ -145,16 +145,14 @@ MISC
.Bl -tag -width "l, [Right], [Return] or C-mXXXX" -offset indent -compact .Bl -tag -width "l, [Right], [Return] or C-mXXXX" -offset indent -compact
.It Ic \&!, ^] .It Ic \&!, ^]
Spawn SHELL in current directory (fallback sh) Spawn SHELL in current directory (fallback sh)
.It Ic o
Launch an application (takes 2 combined arguments)
.It Ic ^S
Run a command
.It Ic R
Run or choose a custom script
.It Ic C .It Ic C
Execute entry Execute entry
.It Ic R
Run or choose a custom script
.It Ic L .It Ic L
Lock terminal Lock terminal
.It Ic ^S
Run a command
.El .El
.Pp .Pp
Backing up one directory level will set the cursor position at the Backing up one directory level will set the cursor position at the


+ 7
- 38
src/nnn.c View File

@@ -2062,9 +2062,9 @@ static bool show_help(char *path)
"d^J Disk usage S Apparent du\n" "d^J Disk usage S Apparent du\n"
"et Modification time s Size\n" "et Modification time s Size\n"
"1MISC\n" "1MISC\n"
"a!, ^] Spawn SHELL in dir o Launch app\n"
"d^S Run a command R Run custom script\n"
"eC Execute entry L Lock terminal\n"};
"a!, ^] Spawn SHELL in dir C Execute entry\n"
"eR Run custom script L Lock terminal\n"
"d^S Run a command\n"};


if (fd == -1) if (fd == -1)
return FALSE; return FALSE;
@@ -3233,15 +3233,9 @@ nochange:
case SEL_RENAME: case SEL_RENAME:
if (!ndents) if (!ndents)
break; // fallthrough break; // fallthrough
case SEL_LAUNCH: // fallthrough
case SEL_NEW: case SEL_NEW:
{ {
char *ptr = NULL, *ptr1 = NULL, *ptr2 = NULL;

switch (sel) { switch (sel) {
case SEL_LAUNCH:
tmp = xreadline(NULL, "launch: ");
break;
case SEL_ARCHIVE: case SEL_ARCHIVE:
tmp = xreadline(dents[cur].name, "name: "); tmp = xreadline(dents[cur].name, "name: ");
break; break;
@@ -3260,43 +3254,18 @@ nochange:
break; break;


/* Allow only relative, same dir paths */ /* Allow only relative, same dir paths */
if ((sel != SEL_LAUNCH) &&
(tmp[0] == '/' || strcmp(xbasename(tmp), tmp) != 0)) {
if (tmp[0] == '/' || strcmp(xbasename(tmp), tmp) != 0) {
printmsg(messages[STR_INPUT_ID]); printmsg(messages[STR_INPUT_ID]);
goto nochange; goto nochange;
} }


/* Confirm if app is CLI or GUI */ /* Confirm if app is CLI or GUI */
if (sel == SEL_OPEN || sel == SEL_LAUNCH) {
if (sel == SEL_OPEN) {
r = get_input("press 'c' for cli mode"); r = get_input("press 'c' for cli mode");
(r == 'c') ? (r = F_NORMAL) : (r = F_NOWAIT | F_NOTRACE); (r == 'c') ? (r = F_NORMAL) : (r = F_NOWAIT | F_NOTRACE);
} }


switch (sel) { switch (sel) {
case SEL_LAUNCH:
{
uint args = 0;
ptr = tmp;

while (*ptr) {
if (isblank(*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, r);
break;
}
case SEL_ARCHIVE: case SEL_ARCHIVE:
/* newpath is used as temporary buffer */ /* newpath is used as temporary buffer */
if (!getutil(utils[APACK])) { if (!getutil(utils[APACK])) {
@@ -3307,9 +3276,9 @@ nochange:
spawn(utils[APACK], tmp, dents[cur].name, path, F_NORMAL); spawn(utils[APACK], tmp, dents[cur].name, path, F_NORMAL);
break; break;
case SEL_OPEN: case SEL_OPEN:
getprogarg(tmp, &ptr);
getprogarg(tmp, &dir); /* dir used as tmp var */
mkpath(path, dents[cur].name, newpath, PATH_MAX); mkpath(path, dents[cur].name, newpath, PATH_MAX);
spawn(tmp, ptr, newpath, path, r);
spawn(tmp, dir, newpath, path, r);
break; break;
case SEL_RENAME: case SEL_RENAME:
/* Skip renaming to same name */ /* Skip renaming to same name */


+ 0
- 3
src/nnn.h View File

@@ -59,7 +59,6 @@ enum action {
SEL_STATS, SEL_STATS,
SEL_MEDIA, SEL_MEDIA,
SEL_FMEDIA, SEL_FMEDIA,
SEL_LAUNCH,
SEL_ARCHIVE, SEL_ARCHIVE,
SEL_ARCHIVELS, SEL_ARCHIVELS,
SEL_EXTRACT, SEL_EXTRACT,
@@ -167,8 +166,6 @@ static struct key bindings[] = {
{ 'm', SEL_MEDIA }, { 'm', SEL_MEDIA },
/* Show media info full, run is hacked */ /* Show media info full, run is hacked */
{ 'M', SEL_FMEDIA }, { 'M', SEL_FMEDIA },
/* Launch a GUI application */
{ 'o', SEL_LAUNCH },
/* Create archive */ /* Create archive */
{ 'f', SEL_ARCHIVE }, { 'f', SEL_ARCHIVE },
/* List archive */ /* List archive */


Loading…
Cancel
Save