Add bookmark finder scripts, fix a few incorrect uses of IFS and read

This commit is contained in:
2026-01-19 17:10:08 -06:00
parent 6ca8fb0c33
commit eac6894d66
7 changed files with 72 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
# this file is just here to easily allow committing this directory to git
# the imported themes are copied here when ./copy_dotfiles.sh is run

View File

@@ -6,8 +6,9 @@ cmd - l : $(which skhd) -k "ctrl - tab"
# shortcuts to open programs
cmd - return : open -a kitty.app -n
cmd - b : open -a Brave\ Browser.app -n
cmd + shift - b : open -a Brave\ Browser.app -n
cmd - s : open -a kitty.app -n --args htop
cmd - b : open -a kitty.app -n --args bookmark-find
# shortcuts to scripts/procs
# cmd - zxcv : path/to/script.sh

View File

@@ -0,0 +1,35 @@
#!/bin/sh
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
[ "$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 clipboard tool; bookmark url: %s" "$bm_selected_bookmark_url"
read # read command to force a pause for input (hit return) before shell is closed
}

View File

@@ -0,0 +1,29 @@
#!/bin/sh
IFS="^" read -r bm_name bm_url bm_tags bm_date_added bm_type bm_parent <<BM_LINE_BLOCK
$(printf "%s" "$@")
BM_LINE_BLOCK
bm_preview_format_block=$(cat <<'BM_PREVIEW_FORMAT_BLOCK'
name:
%s
url:
%s
tags:
%s
date_added:
%s
type:
%s
parent:
%s
BM_PREVIEW_FORMAT_BLOCK)
printf "$bm_preview_format_block" \
"$bm_name" "$bm_url" "$bm_tags" "$bm_date_added" "$bm_type" "$bm_parent"

View File

@@ -9,7 +9,7 @@ non_primary_monitors_off() {
grep -v "^Screen" |
grep -v "^\s" |
grep -v "primary" |
while IFS="\n " read -r target_mon_id remaining_text; do
while read -r target_mon_id remaining_text; do
xrandr --output "$target_mon_id" --off
done
}