mirror of
https://github.com/gotbletu/shownotes
synced 2024-11-05 00:00:51 +00:00
28 lines
936 B
Plaintext
28 lines
936 B
Plaintext
|
#!/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
|