From 99233c4783b43aad19c653cc1c2be5574b3d9794 Mon Sep 17 00:00:00 2001 From: speedie Date: Mon, 7 Aug 2023 19:51:47 +0200 Subject: [PATCH] Allow history navigation to open bookmarks --- scripts/spmenu_path | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/spmenu_path b/scripts/spmenu_path index c3f90f0..d288951 100755 --- a/scripts/spmenu_path +++ b/scripts/spmenu_path @@ -72,6 +72,9 @@ parse() { echo > /tmp/spmenu_out fi + # remove "@" entries + [ -f "$HISTORY" ] && grep -v "^@" "$HISTORY" > /tmp/f && mv /tmp/f "$HISTORY" + while read -r sout; do command -v run_single_char_func > /dev/null && run_single_char_func "${sout:0:1}" command -v run_output_func > /dev/null && run_output_func "${sout}" @@ -115,6 +118,7 @@ parse() { printf "Type: '%s'\n" "$EXEC" >> "$LOGFILE" + bookmark_spmenu exec_cmd "$args" [ "$MULTISELECT" != "true" ] && break done < /tmp/spmenu_out @@ -129,9 +133,7 @@ bookmark_path() { done < "$BOOKMARK_FILE" } -print_bookmarks() { - bookmark_path | sort "${sort_args[@]}" | $RUNLAUNCHER "${rl_bm[@]}" > /tmp/spmenu_out - +bookmark_spmenu() { while read -r sout; do command -v run_pre_bookmark_list_func > /dev/null && run_pre_bookmark_list_func "$sout" command -v run_single_char_pre_bookmark_list_func > /dev/null && run_single_char_pre_bookmark_list_func "${sout:0:1}" @@ -139,7 +141,9 @@ print_bookmarks() { printf "Run launcher output: '%s'\n" "$sout" >> "$LOGFILE" sout_e="$(grep -- "$sout" "$BOOKMARK_FILE" | tail -n 1)" - printf "%s\n" "${sout_e#*:}" | ${SHELL:-"/bin/sh"} & + [ -n "${sout_e#*:}" ] && { + printf "%s\n" "${sout_e#*:}" | ${SHELL:-"/bin/sh"} & + } || return [ "$MULTISELECT" != "true" ] && break done < /tmp/spmenu_out @@ -148,6 +152,12 @@ print_bookmarks() { exit 0 } +print_bookmarks() { + bookmark_path | sort "${sort_args[@]}" | $RUNLAUNCHER "${rl_bm[@]}" > /tmp/spmenu_out + + bookmark_spmenu +} + exec_cmd() { [ -z "$EXEC" ] && EXEC=shell [ "$STDOUT" != "false" ] && printf "%s\n" "$sout" && exit 1