Update 2023-10-12 08:18 OpenBSD/amd64-x13

This commit is contained in:
c0dev0id
2023-10-12 08:18:44 +02:00
parent 3e82170561
commit b9f90ca227
4 changed files with 21 additions and 27 deletions

View File

@@ -10,32 +10,26 @@
# 3. choose which browser to use
# (can suggest a matching default)
. ${HOME}/.bin/_config
HISTFILE="${HOME}/.browser_history"
touch "${HISTFILE}"
test -f ${HOME}/.bin/_config \
&& . ${HOME}/.bin/_config \
|| DMENU_CMD=dmenu
test -f "${HISTFILE}" \
|| touch "${HISTFILE}"
PICKLIST="\
paste_from_clipboard
$(< "${HISTFILE}")
"
# show filtered history file
# EXPECTS: $PICKLIST $HISTFILE $DMENU_CMD
# show history file
# EXPECTS: $HISTFILE $DMENU_CMD
# PROVIDES: $INPUT
read_input() {
local S=$(printf '%s\n' "${PICKLIST}" \
| ${DMENU_CMD} -p "Bookmarks")
local S=$( { echo "paste_from_clipboard"; tail -r ${HISTFILE}; } \
| awk '!seen[$0]++' \
| ${DMENU_CMD} -p "Bookmarks")
case "${S}" in
paste_from_clipboard)
S=$(xclip -o \
| head -n 1) ;;
paste_from_clipboard) S=$(xclip -o | head -n 1); ;;
esac
[ -z "${S}" ] && exit 0
INPUT="${S}"
}
@@ -175,7 +169,7 @@ choose_browser() {
}
save_history() {
printf '%s\n' "${INPUT}" >> "${HISTFILE}"
printf '%s\n' "${INPUT}" | sed 's/^ *//g;s/ *$//g' >> "${HISTFILE}"
}
# main program starts here.