From 75dcda2e82c58f7d5b7d59919e6c7d411f2ef41e Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Fri, 22 Jan 2021 11:18:14 +0800 Subject: [PATCH] [feature] udpate bookmark link --- bin/bm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bin/bm b/bin/bm index 38d2872..40bb2b2 100755 --- a/bin/bm +++ b/bin/bm @@ -46,6 +46,21 @@ function open end end +function update + set url (xsel -ob) + if ! string match 'http*' $url + echo "no url found on clipboard" + exit 1 + end + set query (sed -r '/^(#.*|\s*)$/d' $BOOKMARK_PATH | $BOOKMARK_SEARCHER) + echo url: $url + echo query: $query + mv $BOOKMARK_PATH $BOOKMARK_PATH.bak + awk '$0 == "'$query'" { + sub(/\(http.*\)/, "('$url')") + } { print }' $BOOKMARK_PATH.bak > $BOOKMARK_PATH +end + function _filter_category if not count $argv >/dev/null cat - @@ -105,7 +120,7 @@ function _search end switch $argv[1] - case open list help + case open list help update $argv[1..-1] case '*' _search