summaryrefslogtreecommitdiff
path: root/tmuxsh/_applauncher,--.start.programs.in.new.window
diff options
context:
space:
mode:
Diffstat (limited to 'tmuxsh/_applauncher,--.start.programs.in.new.window')
-rwxr-xr-xtmuxsh/_applauncher,--.start.programs.in.new.window27
1 files changed, 27 insertions, 0 deletions
diff --git a/tmuxsh/_applauncher,--.start.programs.in.new.window b/tmuxsh/_applauncher,--.start.programs.in.new.window
new file mode 100755
index 0000000..5f9f8fc
--- /dev/null
+++ b/tmuxsh/_applauncher,--.start.programs.in.new.window
@@ -0,0 +1,27 @@
+#!/usr/bin/env sh
+TMPFILE="/tmp/fzfspeed_applauncher.txt"
+FZF_ARG() {
+ fzf -e -i -m --delimiter '/' --with-nth -1 --prompt="Select program(s) to open: " --info=default --layout=reverse --tiebreak=index
+}
+
+selected=$(
+ # delete if database is older than 1day
+ if test "$(find "$TMPFILE" -mtime +1 2>/dev/null)" ; then
+ rm "$TMPFILE"
+ elif [ -f "$TMPFILE" ]; then
+ FZF_ARG < "$TMPFILE" | awk '{print $1}'
+ else
+ # if file does not exist then generate new database
+ find $(echo "$PATH" | sed 's@:@\n@g' | sed 's:/*$::' | awk '!x[$0]++' | sed ':a;N;$!ba;s/\n/\/* /g' ) -type f 2>/dev/null |
+ awk '!x[$0]++' | while read -r line
+ do
+ printf '%s\n' "$(basename "$line") $line"
+ done | sort > "$TMPFILE"
+ FZF_ARG < "$TMPFILE" | awk '{print $1}'
+ fi
+)
+[ -z "$selected" ] && exit
+echo "$selected" | while read -r line; do
+ tmux new-window -n "${line}"
+ tmux send-keys -t "${line}" "$line" C-m
+done