Add bookmark finder scripts, fix a few incorrect uses of IFS and read
This commit is contained in:
41
src_files/.local/scripts/bookmark-find
Executable file
41
src_files/.local/scripts/bookmark-find
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
BM_SELECT_TMP_PATH="/tmp/bookmark-find-selected-url"
|
||||
|
||||
bm_selected_bookmark_url=$(
|
||||
find "$DIR_HOME_BOX" \
|
||||
\( -type d -name "*archive" -prune \) \
|
||||
-o \( -type d -name "*z-sort" -prune \) \
|
||||
-o -name "*.bkmrk" -print |
|
||||
while IFS= read -r bookmark_file; do tail -n +2 "$bookmark_file"; done |
|
||||
fzf \
|
||||
--preview-border=line \
|
||||
--preview='bookmark-preview-info {}' |
|
||||
sed -E "s/^[^^]+\^([^^]+)\^.*$/\1/g" ||
|
||||
printf "%s" "BM_SELECT_ERROR"
|
||||
)
|
||||
|
||||
[ "$bm_selected_bookmark_url" = "BM_SELECT_ERROR" ] &&
|
||||
printf "%s\n" "error while selecting bookmark" &&
|
||||
read && # read command to force a pause for input (hit return) before shell is closed
|
||||
exit 1
|
||||
|
||||
printf "%s" "$bm_selected_bookmark_url" > "$BM_SELECT_TMP_PATH"
|
||||
|
||||
[ "$XDG_SESSION_TYPE" = "wayland" ] && command -v wl-copy > /dev/null 2>&1 && {
|
||||
printf "%s" "$bm_selected_bookmark_url" | wl-copy
|
||||
} || {
|
||||
command -v xclip > /dev/null 2>&1 && {
|
||||
printf "%s" "$bm_selected_bookmark_url" | xclip -selection clipboard
|
||||
}
|
||||
} || {
|
||||
command -v pbcopy > /dev/null 2>&1 && {
|
||||
printf "%s" "$bm_selected_bookmark_url" | pbcopy
|
||||
}
|
||||
} || {
|
||||
printf "error finding tool for copy/paste, selected bookmark (%s) written to %s\n" \
|
||||
"$bm_selected_bookmark_url" \
|
||||
"$BM_SELECT_TMP_PATH"
|
||||
read # read command to force a pause for input (hit return) before shell is closed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user