aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/launch
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-09 00:34:53 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-09 00:34:53 +0530
commitd5512462afa1612eee6018290a55eb6bf151e15f (patch)
treec4b1043cee52b3b5dc80d9c1faa5abf5c6c73130 /plugins/launch
parent77ebfff98b4aa2fafa5d43e056af4217b9a6c70e (diff)
downloadnnn-d5512462afa1612eee6018290a55eb6bf151e15f.tar.gz
Move nlaunch to plugins as launch
Diffstat (limited to 'plugins/launch')
-rwxr-xr-xplugins/launch42
1 files changed, 42 insertions, 0 deletions
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