aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/README.md5
-rwxr-xr-xplugins/getplugs15
-rwxr-xr-xplugins/launch42
-rwxr-xr-xplugins/nuke15
4 files changed, 59 insertions, 18 deletions
diff --git a/plugins/README.md b/plugins/README.md
index 094238b..1906df7 100644
--- a/plugins/README.md
+++ b/plugins/README.md
@@ -20,7 +20,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
| diffs | Diff for selection (limited to 2 for directories) | sh | vimdiff |
| dragdrop | Drag/drop files from/into nnn | sh | [dragon](https://github.com/mwh/dragon) |
| exetoggle | Toggle executable status of hovered file | sh | chmod |
-| fzcd | Change to the directory of a fuzzy-selected file/dir | sh | fzy/fzf<br>(optional fd) |
+| fzcd | Change to the directory of a fuzzy-selected file/dir | sh | fzf/fzy<br>(optional fd) |
| fzhist | Fuzzy-select a cmd from history, edit in `$EDITOR` and run | sh | fzy |
| fzopen | Fuzzy find a file in dir subtree and edit or open | sh | fzy, xdg-open |
| getplugs | Update plugins | sh | curl |
@@ -33,6 +33,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
| imgviu | View an image or images in dir in `$PAGER` | sh | [viu](https://github.com/atanunq/viu), less |
| ipinfo | Fetch external IP address and whois information | sh | curl, whois |
| kdeconnect | Send selected files to an Android device | sh | kdeconnect-cli |
+| launch | GUI application launcher | sh | fzf/fzy |
| mediainf | Show media information | sh | mediainfo |
| moclyrics | Show lyrics of the track playing in moc | sh | [ddgr](https://github.com/jarun/ddgr), [moc](http://moc.daper.net/) |
| mocplay | Append (and/or play) selection/dir/file in moc | sh | [moc](http://moc.daper.net/) |
@@ -65,8 +66,6 @@ The following command installs all plugins:
Plugins are installed to `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins`. You can run the `getplugs` plugin later to update the plugins. It backs up earlier plugins.
-**NOTE:** `getplugs` also downloads the launcher `nlaunch` and tries to place it at `/usr/local/bin/` using `sudo`. If it fails you have to place `nlauch` manually somewhere in your `$PATH`.
-
## Executing plugins
**Method 1:** Directly with <kbd>:key</kbd>:
diff --git a/plugins/getplugs b/plugins/getplugs
index ff40360..169c4aa 100755
--- a/plugins/getplugs
+++ b/plugins/getplugs
@@ -31,13 +31,13 @@ prompt () {
fi
}
-if [ "$(is_cmd_exists sudo)" -eq "0" ]; then
- sucmd=sudo
-elif [ "$(is_cmd_exists doas)" -eq "0" ]; then
- sucmd=doas
-else
- sucmd=: # noop
-fi
+# if [ "$(is_cmd_exists sudo)" -eq "0" ]; then
+# sucmd=sudo
+# elif [ "$(is_cmd_exists doas)" -eq "0" ]; then
+# sucmd=doas
+# else
+# sucmd=: # noop
+# fi
# backup any earlier plugins
if [ -d "$PLUGIN_DIR" ]; then
@@ -65,5 +65,4 @@ for f in $(find . -maxdepth 1 \( ! -iname "." ! -iname "*.md" \)); do
done
cd ../.. || exit 1
-$sucmd mv -vf nnn-master/misc/nlaunch/nlaunch /usr/local/bin/
rm -rf nnn-master/ master.tar.gz
diff --git a/plugins/launch b/plugins/launch
new file mode 100755
index 0000000..f1b8a73
--- /dev/null
+++ b/plugins/launch
@@ -0,0 +1,42 @@
+#!/usr/bin/env sh
+
+# Description: Independent POSIX-compliant GUI application launcher.
+# Fuzzy find executables in $PATH and launch an application.
+# stdin, stdout, stderr are suppressed so CLI tools exit silently.
+#
+# To configure launch as an independent app launcher add a keybind
+# to open launch in a terminal e.g.,
+#
+# xfce4-terminal -e "${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/launch
+#
+# Requires: fzf or fzy
+#
+# Usage: launch [delay]
+# delay is in seconds, if omitted launch waits for 1 sec
+#
+# Integration with nnn: launch is installed with other plugins, nnn picks it up.
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+IFS=':'
+
+get_selection() {
+ if which fzf >/dev/null 2>&1; then
+ ls -H $PATH | sort | fzf
+ elif which fzy >/dev/null 2>&1; then
+ ls -H $PATH | sort | fzy
+ else
+ exit 1
+ fi
+}
+
+if selection=$( get_selection ); then
+ setsid "$selection" 2>/dev/null 1>/dev/null &
+
+ if ! [ -z "$1" ]; then
+ sleep "$1"
+ else
+ sleep 1
+ fi
+fi
diff --git a/plugins/nuke b/plugins/nuke
index 1109894..2bab939 100755
--- a/plugins/nuke
+++ b/plugins/nuke
@@ -1,11 +1,12 @@
#!/usr/bin/env sh
# #############################################################################
-# nuke: a sample script to play files in different apps by file type and mime
-# shell: POSIX compliant
-# usage: nuke filepath
+# Description: Sample script to play files in apps by file type or mime
#
-# nnn integration:
+# Shell: POSIX compliant
+# Usage: nuke filepath
+#
+# Integration with nnn:
# 1. Export the required config:
# export NNN_OPENER=/absolute/path/to/nuke
# # Otherwise, if nuke is in $PATH
@@ -14,7 +15,7 @@
# nnn -c
# 3. nuke can use nnn plugins (e.g. mocplay is used for audio), $PATH is updated.
#
-# details:
+# Details:
# Inspired by ranger's scope.sh, modified for usage with nnn.
#
# Tries to play 'file' (1st argument) in the following order:
@@ -22,7 +23,7 @@
# ii. by mime (image, video, audio, pdf)
# iii. by mime (other file types)
#
-# modification tips:
+# Modification tips:
# 1. Invokes CLI utilities by default. Set GUI to 1 to enable GUI apps.
# 2. PAGER is "less -R".
# 3. Start GUI apps in bg to unblock. Redirect stdout and strerr if required.
@@ -32,7 +33,7 @@
#
# Feel free to change the utilities to your favourites and add more mimes.
#
-# defaults:
+# Defaults:
# By extension (only the enbaled ones):
# most archives: list with atool, bsdtar
# rar: list with unrar