mirror of
https://github.com/The-Repo-Club/DotFiles.git
synced 2024-11-24 16:28:41 -05:00
BM
This commit is contained in:
parent
700a61f4a9
commit
30d9bb6ef1
@ -19,6 +19,7 @@ function pacman
|
||||
command sudo pacman --color auto -Qttdq | command sudo pacman --color auto -Rns -
|
||||
end
|
||||
else if [ "$argv" = --upall ]
|
||||
command sudo pkgfile -u
|
||||
command sudo pacman -Fy
|
||||
command sudo pacman -Sy
|
||||
command pikaur -Su
|
||||
|
@ -12,7 +12,7 @@
|
||||
#Created:
|
||||
# Fri 09 December 2022, 07:19:23 AM [GMT]
|
||||
#Modified:
|
||||
# Fri 09 December 2022, 08:24:49 AM [GMT]
|
||||
# Fri 14 July 2023, 11:47:25 PM [GMT+1]
|
||||
#
|
||||
#Description:
|
||||
# <Todo>
|
||||
@ -46,10 +46,10 @@ config() {
|
||||
export _BM_CONFIG_FILE='none'
|
||||
fi
|
||||
# _BM_BOOKMARK_FILE : Where is stored the bookmark file
|
||||
export _BM_BOOKMARK_FILE="${_BM_BOOKMARK_FILE:=${__w}bm.bmf}"
|
||||
export _BM_BOOKMARK_FILE="${_BM_BOOKMARK_FILE:=${__w}bm.bm}"
|
||||
|
||||
# _BM_BOOKMARK_BACKUP_FILE : Where is stored the backup of bookmark file
|
||||
export _BM_BOOKMARK_BACKUP_FILE="${_BM_BOOKMARK_BACKUP_FILE:=${__w}.bm.bmf.bck}"
|
||||
export _BM_BOOKMARK_BACKUP_FILE="${_BM_BOOKMARK_BACKUP_FILE:=${__w}.bm.bm.bck}"
|
||||
|
||||
# _BM_HTML_FILE : Location of generated HTML file
|
||||
export _BM_HTML_FILE="${_BM_HTML_FILE:=${__w}bm.html}"
|
||||
@ -102,7 +102,7 @@ config() {
|
||||
export _BM_NO_ARGS_FORCE_HELP=${_BM_NO_ARGS_FORCE_HELP:=false}
|
||||
|
||||
# _BM_CREATE_BOOKMARK_FILE : If bm is called to list and no file exists. bm will create a default one.
|
||||
export _BM_CREATE_BOOKMARK_FILE=${_BM_CREATE_BOOKMARK_FILE:=false}
|
||||
export _BM_CREATE_BOOKMARK_FILE=${_BM_CREATE_BOOKMARK_FILE:=true}
|
||||
|
||||
# _BM_CMD_CAPTURE_CHECK : If you don't have tool installed to take screenshot, just put to false.
|
||||
# It will disable the _BM_GET_SCREENSHOT.
|
||||
@ -158,7 +158,7 @@ VERSION='2021.04.05'
|
||||
#
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
cat <<EOF
|
||||
|
||||
Usage: ${0} [modifier(s)] command [option(s)]
|
||||
|
||||
@ -242,7 +242,7 @@ Usage: ${0} [modifier(s)] command [option(s)]
|
||||
|
||||
-C Print the color table (usefull for configuration)
|
||||
|
||||
-E Open the bm.bmf with your \$EDITOR
|
||||
-E Open the bm.bm with your \$EDITOR
|
||||
|
||||
-S Show statistics about bookmarks/tags (and also configuration)
|
||||
Options for -S
|
||||
@ -260,22 +260,22 @@ EOF
|
||||
|
||||
getAccelMax() {
|
||||
while read a; do
|
||||
((${a:=0} >= ${_max:=0})) && ((_max = ${a} + 1))
|
||||
done <<<"$(awk -F'|' '$0 !~ /^[ ]*#/ && $3 ~ /^[:space:]*:[:space:]*[0-9]+[:space:]*$/ { sub(/:+/, "", $3); print $3; }' "${_BM_BOOKMARK_FILE}")"
|
||||
(( ${a:=0} >= ${_max:=0} )) && (( _max=${a}+1 ))
|
||||
done <<< "$( awk -F'|' '$0 !~ /^[ ]*#/ && $3 ~ /^[:space:]*:[:space:]*[0-9]+[:space:]*$/ { sub(/:+/, "", $3); print $3; }' "${_BM_BOOKMARK_FILE}")"
|
||||
echo -n "${_max}"
|
||||
}
|
||||
|
||||
backupBm() {
|
||||
if [ "${_BM_BOOKMARK_BACKUP,,}" = 'true' ]; then
|
||||
while [ ${count:=${_BM_BOOKMARK_BACKUP_VERSION}} -gt 0 ]; do
|
||||
cp -- "${_BM_BOOKMARK_BACKUP_FILE}.$((count - 1))" "${_BM_BOOKMARK_BACKUP_FILE}.$((count--))" 2>&1 >/dev/null
|
||||
cp -- "${_BM_BOOKMARK_BACKUP_FILE}.$(( count-1 ))" "${_BM_BOOKMARK_BACKUP_FILE}.$(( count-- ))" 2>&1 >/dev/null
|
||||
done
|
||||
cp -- "${_BM_BOOKMARK_FILE}" "${_BM_BOOKMARK_BACKUP_FILE}.0"
|
||||
fi
|
||||
}
|
||||
|
||||
titleDl() {
|
||||
if command -v hxselect &>/dev/null; then
|
||||
if command -v hxselect &>/dev/null ; then
|
||||
curl -Lks "${1:-}" 2>&1 | hxselect -ic title 2>/dev/null
|
||||
else
|
||||
curl -Lks "${1:-}" 2>&1 | sed '/<title>/I!d;/<\/title>/I!d;s;^[[:space:]]*<title>\([^<]*\)<.*;\1;i'
|
||||
@ -290,36 +290,36 @@ saveUrl() {
|
||||
echo "Force adding invalid URL" >&2
|
||||
fi
|
||||
}
|
||||
local _sum="$(${_BM_CMD_MD5} <<<"${__url}")"
|
||||
if [ "${_BM_DUPS_DETECT,,}" = 'true' ]; then
|
||||
if [ ! -z "$(awk -F '|' '$0 !~ /^[ ]*#/ && $1 ~ /'"${_sum%% *}"'/' "${_BM_BOOKMARK_FILE}")" ]; then
|
||||
if [ ${__F:=0} -eq 0 ]; then
|
||||
die "URL is already in the Bookmark file"
|
||||
else
|
||||
echo "Force adding duplicate URL" >&2
|
||||
fi
|
||||
local _sum="$(${_BM_CMD_MD5} <<< "${__url}")"
|
||||
if [ "${_BM_DUPS_DETECT,,}" = 'true' ]; then
|
||||
if [ ! -z "$(awk -F '|' '$0 !~ /^[ ]*#/ && $1 ~ /'"${_sum%% *}"'/' "${_BM_BOOKMARK_FILE}")" ]; then
|
||||
if [ ${__F:=0} -eq 0 ]; then
|
||||
die "URL is already in the Bookmark file"
|
||||
else
|
||||
echo "Force adding duplicate URL" >&2
|
||||
fi
|
||||
fi
|
||||
if [ "${_BM_GET_PAGE_TITLE,,}" = 'true' -a -z "${__T:=}" ]; then
|
||||
# if [ $( command -v hxselect &>/dev/null ) ]; then
|
||||
# __T="$( curl -Lks "${__url}" 2>&1 | hxselect -ic title )"
|
||||
# else
|
||||
# __T="$( curl -Lks "${__url}" 2>&1 | sed '/<title>/I!d;/<\/title>/I!d;s;^[[:space:]]*<title>\([^<]*\)<.*;\1;i' )"
|
||||
# fi
|
||||
__T="$(titleDl "${__url}")"
|
||||
fi
|
||||
[[ ! -z "${__T:=}" ]] && __T="${__T//\|/\\|}"
|
||||
backupBm
|
||||
[[ -z "${__T:=}" ]] && __T="$(slug <<<"${__url}")" # If no title => slug the url
|
||||
[[ -z "${__t:=}" ]] && __t='default' # Default tag is default
|
||||
[[ -z "${__A:=}" ]] && __A="$(getAccelMax)"
|
||||
[[ "${__A:0:1}" != ':' ]] && __A=":${__A}" # If no accel => Add a number
|
||||
echo "${_sum%% *}|$(date '+%FT%TZ')|${__A}|${__url}|${__T}|${__t}" >>"${_BM_BOOKMARK_FILE}" || die "Insert aborted into '${_BM_BOOKMARK_FILE}' !"
|
||||
echo "${__url} inserted into '${_BM_BOOKMARK_FILE}'"
|
||||
[[ ! -f "${_BM_SCREENSHOT_DIRECTORY}/${_sum%% *}.png" || ${__F:=0} -eq 1 ]] && { screenshot_take "${_BM_SCREENSHOT_DIRECTORY}/${_sum%% *}.png" "${__url}" & }
|
||||
[[ "${_BM_SCREENSHOT_WAIT,,}" = 'true' ]] && wait
|
||||
search_bookmarks "${__A}"
|
||||
}
|
||||
fi
|
||||
if [ "${_BM_GET_PAGE_TITLE,,}" = 'true' -a -z "${__T:=}" ]; then
|
||||
# if [ $( command -v hxselect &>/dev/null ) ]; then
|
||||
# __T="$( curl -Lks "${__url}" 2>&1 | hxselect -ic title )"
|
||||
# else
|
||||
# __T="$( curl -Lks "${__url}" 2>&1 | sed '/<title>/I!d;/<\/title>/I!d;s;^[[:space:]]*<title>\([^<]*\)<.*;\1;i' )"
|
||||
# fi
|
||||
__T="$( titleDl "${__url}" )"
|
||||
fi
|
||||
[[ ! -z "${__T:=}" ]] && __T="${__T//\|/\\|}"
|
||||
backupBm
|
||||
[[ -z "${__T:=}" ]] && __T="$(slug <<< "${__url}")" # If no title => slug the url
|
||||
[[ -z "${__t:=}" ]] && __t='default' # Default tag is default
|
||||
[[ -z "${__A:=}" ]] && __A="$(getAccelMax)"
|
||||
[[ "${__A:0:1}" != ':' ]] && __A=":${__A}" # If no accel => Add a number
|
||||
echo "${_sum%% *}|$(date '+%FT%TZ')|${__A}|${__url}|${__T}|${__t}" >> "${_BM_BOOKMARK_FILE}" || die "Insert aborted into '${_BM_BOOKMARK_FILE}' !"
|
||||
echo "${__url} inserted into '${_BM_BOOKMARK_FILE}'"
|
||||
[[ ! -f "${_BM_SCREENSHOT_DIRECTORY}/${_sum%% *}.png" || ${__F:=0} -eq 1 ]] && { screenshot_take "${_BM_SCREENSHOT_DIRECTORY}/${_sum%% *}.png" "${__url}" & }
|
||||
[[ "${_BM_SCREENSHOT_WAIT,,}" = 'true' ]] && wait
|
||||
search_bookmarks "${__A}"
|
||||
}
|
||||
|
||||
#
|
||||
# manage each line to print it
|
||||
@ -332,7 +332,7 @@ readLines() {
|
||||
[[ ${__z:=0} -eq 1 ]] && _line="${_BM_PRINT_LINE_ALTERNATIVE}"
|
||||
_line="${_line//BM_MD5/$m}"
|
||||
if [ "${_BM_PRINT_SCHEME,,}" = 'false' ]; then
|
||||
u="$(sed 's/^[[:space:]]*\(f\|ht\)tps*:\/\///' <<<"${u}")"
|
||||
u="$(sed 's/^[[:space:]]*\(f\|ht\)tps*:\/\///' <<< "${u}")"
|
||||
fi
|
||||
_line="${_line//BM_URL/$u}"
|
||||
_line="${_line//BM_TITLE/$T}"
|
||||
@ -351,14 +351,8 @@ readLines() {
|
||||
#
|
||||
|
||||
list_bookmarks() {
|
||||
[[ ${__n:=0} -eq 1 ]] && {
|
||||
awk '$0 !~ /^[ ]*#/' "${_BM_BOOKMARK_FILE}" | sort -t'|' -k2 | readLines
|
||||
return
|
||||
}
|
||||
[[ ${__N:=0} -eq 1 ]] && {
|
||||
awk '$0 !~ /^[ ]*#/' "${_BM_BOOKMARK_FILE}" | sort -t'|' -k2 -r | readLines
|
||||
return
|
||||
}
|
||||
[[ ${__n:=0} -eq 1 ]] && { awk '$0 !~ /^[ ]*#/' "${_BM_BOOKMARK_FILE}" | sort -t'|' -k2 | readLines; return; }
|
||||
[[ ${__N:=0} -eq 1 ]] && { awk '$0 !~ /^[ ]*#/' "${_BM_BOOKMARK_FILE}" | sort -t'|' -k2 -r | readLines; return; }
|
||||
awk '$0 !~ /^[ ]*#/' "${_BM_BOOKMARK_FILE}" | readLines
|
||||
}
|
||||
|
||||
@ -369,26 +363,11 @@ search() {
|
||||
local _s=''
|
||||
[[ -z "${1:-}" ]] && list_bookmarks && return
|
||||
case "${1:0:1}" in
|
||||
:)
|
||||
_s=3
|
||||
_ss=0
|
||||
;; # Accelerator
|
||||
+)
|
||||
_s="NF"
|
||||
_ss=1
|
||||
;; # Tags
|
||||
=)
|
||||
_s=1
|
||||
_ss=1
|
||||
;; # MD5 part
|
||||
/)
|
||||
_s=4
|
||||
_ss=1
|
||||
;; # URL part
|
||||
*)
|
||||
_s=0
|
||||
_ss=0
|
||||
;; # full text search
|
||||
:) _s=3; _ss=0 ;; # Accelerator
|
||||
+) _s="NF"; _ss=1 ;; # Tags
|
||||
=) _s=1; _ss=1 ;; # MD5 part
|
||||
/) _s=4; _ss=1 ;; # URL part
|
||||
*) _s=0; _ss=0 ;; # full text search
|
||||
esac
|
||||
[[ "${_BM_SEARCH_IGNORECASE,,}" = 'true' || ${__i:=0} -eq 1 ]] && local _ign=1
|
||||
awk -F'|' -vIgn=${_ign:=0} '
|
||||
@ -400,14 +379,8 @@ $0 !~ /^[ ]*#/ && (Ign == 0 && $'"${_s}"' ~ s) || (Ign ==1 && tolower($'"${_s}"
|
||||
|
||||
}
|
||||
search_bookmarks() {
|
||||
[[ ${__n:=0} -eq 1 ]] && {
|
||||
search "${@}" | sort -t'|' -k2 | readLines
|
||||
return
|
||||
}
|
||||
[[ ${__N:=0} -eq 1 ]] && {
|
||||
search "${@}" | sort -t'|' -k2 -r | readLines
|
||||
return
|
||||
}
|
||||
[[ ${__n:=0} -eq 1 ]] && { search "${@}" | sort -t'|' -k2 | readLines; return; }
|
||||
[[ ${__N:=0} -eq 1 ]] && { search "${@}" | sort -t'|' -k2 -r | readLines; return; }
|
||||
search "${@}" | readLines
|
||||
}
|
||||
|
||||
@ -418,7 +391,7 @@ search_bookmarks() {
|
||||
recorded_picture() {
|
||||
local _lines="$(search "${@}")"
|
||||
if [ "${_BM_ASK_BEFORE_OPEN,,}" = 'true' -a ${__O:=0} -eq 0 -a ${__Y:=0} -eq 0 ]; then
|
||||
if [ $(wc -l <<<"${_lines}") -gt 1 ]; then
|
||||
if [ $(wc -l <<< "${_lines}") -gt 1 ]; then
|
||||
read -p"More than one URL found. Open all Pictures ? [Y/N] : " -n1 _answer
|
||||
[[ "${_answer,,}" != 'y' ]] && die "\nUse -O to force the first URL or refine your search"
|
||||
fi
|
||||
@ -426,21 +399,21 @@ recorded_picture() {
|
||||
local _all=''
|
||||
echo ''
|
||||
while read _nl; do
|
||||
readLines <<<"${_nl}"
|
||||
readLines <<< "${_nl}"
|
||||
if [ "${_BM_OPEN_ALL,,}" = 'true' -o ${__Y:=0} -eq 1 ]; then
|
||||
_all="${_BM_SCREENSHOT_DIRECTORY}/$(awk -F'|' '{print $1}' <<<"${_nl}").png ${_all}"
|
||||
_all="${_BM_SCREENSHOT_DIRECTORY}/$(awk -F'|' '{print $1}' <<< "${_nl}").png ${_all}"
|
||||
else
|
||||
"${_BM_CMD_IMAGE_OPEN}" "${_BM_SCREENSHOT_DIRECTORY}/$(awk -F'|' '{print $1}' <<<"${_nl}").png"
|
||||
"${_BM_CMD_IMAGE_OPEN}" "${_BM_SCREENSHOT_DIRECTORY}/$(awk -F'|' '{print $1}' <<< "${_nl}").png"
|
||||
[[ "${_BM_OPEN_FIRST,,}" = 'true' || ${__O:=0} -eq 1 ]] && exit 0
|
||||
fi
|
||||
done <<<"$(echo -e "${_lines}")"
|
||||
[[ "${_BM_OPEN_ALL,,}" = 'true' || ${__Y:=0} -eq 1 ]] && "${_BM_CMD_IMAGE_OPEN}" "${_all}"
|
||||
done <<< "$(echo -e "${_lines}")"
|
||||
[[ "${_BM_OPEN_ALL,,}" = 'true' || ${__Y:=0} -eq 1 ]] && "${_BM_CMD_IMAGE_OPEN}" "${_all}"
|
||||
}
|
||||
|
||||
download_title() {
|
||||
local _lines="$(search "${@}")"
|
||||
if [ "${_BM_ASK_BEFORE_OPEN,,}" = 'true' -a ${__O:=0} -eq 0 -a ${__Y:=0} -eq 0 ]; then
|
||||
if [ $(wc -l <<<"${_lines}") -gt 1 ]; then
|
||||
if [ $(wc -l <<< "${_lines}") -gt 1 ]; then
|
||||
read -p"More than one URL found. Download Title for all URLs ? [Y/N] : " -n1 _answer
|
||||
[[ "${_answer,,}" != 'y' ]] && die "\nUse -O to force the first URL or refine your search"
|
||||
fi
|
||||
@ -448,85 +421,85 @@ download_title() {
|
||||
local _all=''
|
||||
echo ''
|
||||
while read _nl; do
|
||||
readLines <<<"${_nl}"
|
||||
local u="$(awk -F'|' '{print $4}' <<<"${_nl}")"
|
||||
readLines <<< "${_nl}"
|
||||
local u="$(awk -F'|' '{print $4}' <<< "${_nl}")"
|
||||
if [ "${_BM_OPEN_ALL,,}" = 'true' -o ${__Y:=0} -eq 1 ]; then
|
||||
echo "${u} --> $(titleDl "${u}")"
|
||||
echo "${u} --> $( titleDl "${u}" )"
|
||||
else
|
||||
echo "${u} --> $(titleDl "${u}")"
|
||||
echo "${u} --> $( titleDl "${u}" )"
|
||||
[[ "${_BM_OPEN_FIRST,,}" = 'true' || ${__O:=0} -eq 1 ]] && exit 0
|
||||
fi
|
||||
done <<<"$(echo -e "${_lines}")"
|
||||
done <<< "$(echo -e "${_lines}")"
|
||||
}
|
||||
|
||||
open_bookmark() {
|
||||
local _lines="$(search "${@}")"
|
||||
if [ "${_BM_ASK_BEFORE_OPEN,,}" = 'true' -a ${__O:=0} -eq 0 -a ${__Y:=0} -eq 0 ]; then
|
||||
if [ $(wc -l <<<"${_lines}") -gt 1 ]; then
|
||||
if [ $(wc -l <<< "${_lines}") -gt 1 ]; then
|
||||
read -p"More than one URL found. Open all ? [Y/N] : " -n1 _answer
|
||||
[[ "${_answer,,}" != 'y' ]] && die "\nUse -O to force the first URL or refine your search"
|
||||
fi
|
||||
fi
|
||||
local _all=''
|
||||
while read _nl; do
|
||||
readLines <<<"${_nl}"
|
||||
readLines <<< "${_nl}"
|
||||
if [ "${_BM_OPEN_ALL,,}" = 'true' -o ${__Y:=0} -eq 1 ]; then
|
||||
_all="$(awk -F'|' '{print $4}' <<<"${_nl}") ${_all}"
|
||||
_all="$(awk -F'|' '{print $4}' <<< "${_nl}") ${_all}"
|
||||
else
|
||||
"${_BM_CMD_OPEN}" "$(awk -F'|' '{print $4}' <<<"${_nl}")"
|
||||
"${_BM_CMD_OPEN}" "$(awk -F'|' '{print $4}' <<< "${_nl}")"
|
||||
[[ "${_BM_OPEN_FIRST,,}" = 'true' || ${__O:=0} -eq 1 ]] && exit 0
|
||||
fi
|
||||
done <<<"$(echo -e "${_lines}")"
|
||||
[[ "${_BM_OPEN_ALL,,}" = 'true' || ${__Y:=0} -eq 1 ]] && "${_BM_CMD_OPEN}" "${_all}"
|
||||
done <<< "$(echo -e "${_lines}")"
|
||||
[[ "${_BM_OPEN_ALL,,}" = 'true' || ${__Y:=0} -eq 1 ]] && "${_BM_CMD_OPEN}" "${_all}"
|
||||
}
|
||||
|
||||
copy_bookmark() {
|
||||
local _lines="$(search "${@}")"
|
||||
if [ "${_BM_ASK_BEFORE_OPEN,,}" = 'true' -a ${__X:=0} -eq 0 -a ${__Y:=0} -eq 0 ]; then
|
||||
if [ $(wc -l <<<"${_lines}") -gt 1 ]; then
|
||||
if [ $(wc -l <<< "${_lines}") -gt 1 ]; then
|
||||
read -p"More than one URL found. Copy all ? [Y/N] : " -n1 _answer
|
||||
[[ "${_answer,,}" != 'y' ]] && die "\nUse -X to force the first URL or refine your search"
|
||||
fi
|
||||
fi
|
||||
local _all=''
|
||||
while read _nl; do
|
||||
readLines <<<"${_nl}"
|
||||
readLines <<< "${_nl}"
|
||||
if [ "${_BM_OPEN_ALL,,}" = 'true' -o ${__Y:=0} -eq 1 ]; then
|
||||
_all="$(awk -F'|' '{print $4}' <<<"${_nl}") ${_all}"
|
||||
_all="$(awk -F'|' '{print $4}' <<< "${_nl}") ${_all}"
|
||||
else
|
||||
awk -F'|' '{print $4}' <<<"${_nl}" | "${_BM_CMD_COPY}"
|
||||
awk -F'|' '{print $4}' <<<"${_nl}" | "${_BM_CMD_COPY}" -b
|
||||
awk -F'|' '{print $4}' <<< "${_nl}" | "${_BM_CMD_COPY}"
|
||||
awk -F'|' '{print $4}' <<< "${_nl}" | "${_BM_CMD_COPY}" -b
|
||||
[[ "${_BM_OPEN_FIRST,,}" = 'true' || ${__X:=0} -eq 1 ]] && exit 0
|
||||
fi
|
||||
done <<<"$(echo -e "${_lines}")"
|
||||
[[ "${_BM_OPEN_ALL,,}" = 'true' || ${__Y:=0} -eq 1 ]] && "${_BM_CMD_COPY}" <<<"${_all}"
|
||||
[[ "${_BM_OPEN_ALL,,}" = 'true' || ${__Y:=0} -eq 1 ]] && "${_BM_CMD_COPY}" -b <<<"${_all}"
|
||||
done <<< "$(echo -e "${_lines}")"
|
||||
[[ "${_BM_OPEN_ALL,,}" = 'true' || ${__Y:=0} -eq 1 ]] && "${_BM_CMD_COPY}" <<< "${_all}"
|
||||
[[ "${_BM_OPEN_ALL,,}" = 'true' || ${__Y:=0} -eq 1 ]] && "${_BM_CMD_COPY}" -b <<< "${_all}"
|
||||
}
|
||||
|
||||
delete_bookmark() {
|
||||
[[ -z "${@//[ ]/}" ]] && die "You MUST give an argument !"
|
||||
local _lines="$(search "${@}")"
|
||||
if [ "${_BM_DELETE_ALLOWED,,}" = 'true' ]; then
|
||||
while read _nl; do readLines <<<"${_nl}"; done <<<"$(echo -e "${_lines}")"
|
||||
if [ "${_BM_ASK_BEFORE_OPEN,,}" = 'true' -a ${__D:=0} -eq 0 -a ${__Y:=0} -eq 0 ]; then
|
||||
if [ $(wc -l <<<"${_lines}") -ge 1 ]; then
|
||||
read -p"You're about to delete entry(ies). Ready ? [Y/N] : " -n1 _answer
|
||||
[[ "${_answer,,}" != 'y' ]] && die "\nUse -D to force the backup if not configured."
|
||||
echo ''
|
||||
if [ "${_BM_DELETE_ALLOWED,,}" = 'true' ]; then
|
||||
while read _nl; do readLines <<< "${_nl}"; done <<< "$(echo -e "${_lines}")"
|
||||
if [ "${_BM_ASK_BEFORE_OPEN,,}" = 'true' -a ${__D:=0} -eq 0 -a ${__Y:=0} -eq 0 ]; then
|
||||
if [ $(wc -l <<< "${_lines}") -ge 1 ]; then
|
||||
read -p"You're about to delete entry(ies). Ready ? [Y/N] : " -n1 _answer
|
||||
[[ "${_answer,,}" != 'y' ]] && die "\nUse -D to force the backup if not configured."
|
||||
echo ''
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
backupBm
|
||||
local _all=''
|
||||
while read _nl; do
|
||||
if [ "${_BM_DELETE_TO_FILE,,}" = 'true' -o ${__D:=0} -eq 1 ]; then
|
||||
echo "${_nl}" >>"${_BM_DELETE_FILE}"
|
||||
fi
|
||||
[[ "${_BM_DELETE_PICTURE,,}" = 'true' || ${__p:=0} -eq 1 ]] && rm -f -- "${_BM_SCREENSHOT_DIRECTORY}/${_nl%%|*}.png"
|
||||
IFS='|' read m d a u T t <<<"${_nl}"
|
||||
sed -i -e '/^'"${m}.*${u//\//\\/}.*${t//\//\\/}"'$/d' "${_BM_BOOKMARK_FILE}"
|
||||
done <<<"$(echo -e "${_lines}")"
|
||||
else
|
||||
die "You're not allowed to delete entries. Change the _BM_DELETE_ALLOWED to true !"
|
||||
backupBm
|
||||
local _all=''
|
||||
while read _nl; do
|
||||
if [ "${_BM_DELETE_TO_FILE,,}" = 'true' -o ${__D:=0} -eq 1 ]; then
|
||||
echo "${_nl}" >> "${_BM_DELETE_FILE}"
|
||||
fi
|
||||
[[ "${_BM_DELETE_PICTURE,,}" = 'true' || ${__p:=0} -eq 1 ]] && rm -f -- "${_BM_SCREENSHOT_DIRECTORY}/${_nl%%|*}.png"
|
||||
IFS='|' read m d a u T t <<< "${_nl}"
|
||||
sed -i -e '/^'"${m}.*${u//\//\\/}.*${t//\//\\/}"'$/d' "${_BM_BOOKMARK_FILE}"
|
||||
done <<< "$(echo -e "${_lines}")"
|
||||
else
|
||||
die "You're not allowed to delete entries. Change the _BM_DELETE_ALLOWED to true !"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -550,42 +523,29 @@ stats() {
|
||||
echo " ${i}"
|
||||
done
|
||||
echo -e "\n===== Statistics ====="
|
||||
readarray -t lines <"${_BM_BOOKMARK_FILE}"
|
||||
readarray -t lines < "${_BM_BOOKMARK_FILE}"
|
||||
echo "# of Bookmarks : ${#lines[@]}"
|
||||
echo "# of Duplicate : $(awk -F'|' '$0 !~ /^[ ]*#/ {print $1}' "${_BM_BOOKMARK_FILE}" | sort | uniq -d | wc -l)"
|
||||
echo "# of Duplicate : $(awk -F'|' '$0 !~ /^[ ]*#/ {print $1}' "${_BM_BOOKMARK_FILE}" |sort |uniq -d |wc -l)"
|
||||
local tags="$(awk -F'|' '$0 !~ /^[ ]*#/ {print $NF}' "${_BM_BOOKMARK_FILE}" | sed -e 's/\([[:space:]]*,[[:space:]]*\)/\n/g')"
|
||||
|
||||
echo "# of tags : $(sort -u <<<"${tags,,}" | wc -l)"
|
||||
echo "# of tags : $( sort -u <<< "${tags,,}" |wc -l)"
|
||||
echo "Top 14 tags used :"
|
||||
local nli=0
|
||||
local pa=0
|
||||
local nli=0;local pa=0
|
||||
(
|
||||
sort <<<"${tags,,}" | uniq -c | sort -nr | while read n t; do
|
||||
((nli++))
|
||||
[[ ${nli} -gt 7 ]] && nli=1 && echo ''
|
||||
((pa++))
|
||||
[[ ${pa} -gt 14 ]] && break
|
||||
echo -n "${t// / }:${n} "
|
||||
done
|
||||
echo ''
|
||||
) | column -t -c 17
|
||||
echo "# of Pictures : $(ls -1 "${_BM_SCREENSHOT_DIRECTORY}"/*.png | wc -l) [# of files in ${_BM_SCREENSHOT_DIRECTORY}:$(ls -1 "${_BM_SCREENSHOT_DIRECTORY}"/* | wc -l)]"
|
||||
echo "All Pictures size : $(du -sh "${_BM_SCREENSHOT_DIRECTORY}" | awk '{print $1}')"
|
||||
local orphaned="$(
|
||||
cd "${_BM_SCREENSHOT_DIRECTORY}" && for i in *; do [[ -z "$(sed -e '/'"${i%%.*}"'/!d' "${_BM_BOOKMARK_FILE}")" ]] && ((orph++)); done
|
||||
echo "${orph:=0}"
|
||||
)"
|
||||
local nopics="$(
|
||||
while read i; do [[ ! -f "${_BM_SCREENSHOT_DIRECTORY}/${i%%|*}.png" ]] && ((nopics++)); done <<<${lines[@]}
|
||||
echo "${nopics:=0}"
|
||||
)"
|
||||
echo "Bookmark Without Pic : ${nopics}"
|
||||
echo "Orphaned pictures : ${orphaned}"
|
||||
[[ ${__p:=0} -eq 1 ]] && {
|
||||
echo -e "\n===== Orphaned ====="
|
||||
echo "List of orphaned pictures :"
|
||||
cd "${_BM_SCREENSHOT_DIRECTORY}" && for i in *; do [[ -z "$(sed -e '/'"${i%%.*}"'/!d' "${_BM_BOOKMARK_FILE}")" ]] && echo " - ${_BM_SCREENSHOT_DIRECTORY}/${i} [Trashed URL should be: $(awk -F'|' 'BEGIN{l="Unknown"} ($1 ~ /'"${i%%.*}"'/) {l=$4;} END {print l}' "${_BM_DELETE_FILE}")]"; done
|
||||
}
|
||||
sort <<< "${tags,,}" | uniq -c | sort -nr | while read n t; do
|
||||
(( nli++ ));[[ ${nli} -gt 7 ]] && nli=1 && echo ''
|
||||
(( pa++ ));[[ ${pa} -gt 14 ]] && break
|
||||
echo -n "${t// / }:${n} "
|
||||
done
|
||||
echo ''
|
||||
) | column -t -c 17
|
||||
echo "# of Pictures : $(ls -1 "${_BM_SCREENSHOT_DIRECTORY}"/*.png |wc -l) [# of files in ${_BM_SCREENSHOT_DIRECTORY}:$(ls -1 "${_BM_SCREENSHOT_DIRECTORY}"/* |wc -l)]"
|
||||
echo "All Pictures size : $(du -sh "${_BM_SCREENSHOT_DIRECTORY}" | awk '{print $1}')"
|
||||
local orphaned="$( cd "${_BM_SCREENSHOT_DIRECTORY}" && for i in *; do [[ -z "$(sed -e '/'"${i%%.*}"'/!d' "${_BM_BOOKMARK_FILE}")" ]] && ((orph++)); done; echo "${orph:=0}" )"
|
||||
local nopics="$( while read i; do [[ ! -f "${_BM_SCREENSHOT_DIRECTORY}/${i%%|*}.png" ]] && ((nopics++)); done <<< ${lines[@]}; echo "${nopics:=0}" )"
|
||||
echo "Bookmark Without Pic : ${nopics}"
|
||||
echo "Orphaned pictures : ${orphaned}"
|
||||
[[ ${__p:=0} -eq 1 ]] && { echo -e "\n===== Orphaned ====="; echo "List of orphaned pictures :"; cd "${_BM_SCREENSHOT_DIRECTORY}" && for i in *; do [[ -z "$(sed -e '/'"${i%%.*}"'/!d' "${_BM_BOOKMARK_FILE}")" ]] && echo " - ${_BM_SCREENSHOT_DIRECTORY}/${i} [Trashed URL should be: $(awk -F'|' 'BEGIN{l="Unknown"} ($1 ~ /'"${i%%.*}"'/) {l=$4;} END {print l}' "${_BM_DELETE_FILE}")]"; done; };
|
||||
}
|
||||
|
||||
#
|
||||
@ -596,13 +556,12 @@ list_tags() {
|
||||
local tags="$(awk -F'|' '$0 !~ /^[ ]*#/ {print $NF}' "${_BM_BOOKMARK_FILE}" | sed -e 's/\([[:space:]]*,[[:space:]]*\)/\n/g')"
|
||||
local nli=0
|
||||
(
|
||||
sort <<<"${tags,,}" | uniq -c | sort -nr | while read n t; do
|
||||
((nli++))
|
||||
[[ ${nli} -gt 7 ]] && nli=1 && echo ''
|
||||
echo -n "${t// / }:${n} "
|
||||
done
|
||||
echo ''
|
||||
) | column -t -c 17
|
||||
sort <<< "${tags,,}" | uniq -c | sort -nr | while read n t; do
|
||||
(( nli++ ));[[ ${nli} -gt 7 ]] && nli=1 && echo ''
|
||||
echo -n "${t// / }:${n} "
|
||||
done
|
||||
echo ''
|
||||
) | column -t -c 17
|
||||
}
|
||||
|
||||
#
|
||||
@ -687,68 +646,58 @@ EOF
|
||||
|
||||
screenshot_take() {
|
||||
if [ "${_BM_SCREENSHOT_GET,,}" = 'true' -o ${__p:=0} -eq 1 ]; then
|
||||
[[ ! -d "${_BM_SCREENSHOT_DIRECTORY}" ]] && { mkdir -p "${_BM_SCREENSHOT_DIRECTORY}" || die "Can't create thumbnail directory."; }
|
||||
[[ ! -z "${_BM_CMD_PRE_CAPTURE}" ]] && {
|
||||
local _pre="${_BM_CMD_PRE_CAPTURE//\{FILE\}/${1}}"
|
||||
_pre="${_pre//\{URL\}/${2}}"
|
||||
${_pre}
|
||||
}
|
||||
local _cmd="${_BM_CMD_CAPTURE//\{FILE\}/${1}}"
|
||||
_cmd="${_cmd//\{URL\}/${2}}"
|
||||
local _args="${_BM_CMD_CAPTURE_ARGS//\{FILE\}/${1}}"
|
||||
_args="${_args//\{URL\}/${2}}"
|
||||
[[ ! -d "${_BM_SCREENSHOT_DIRECTORY}" ]] && { mkdir -p "${_BM_SCREENSHOT_DIRECTORY}" || die "Can't create thumbnail directory." ; }
|
||||
[[ ! -z "${_BM_CMD_PRE_CAPTURE}" ]] && { local _pre="${_BM_CMD_PRE_CAPTURE//\{FILE\}/${1}}"; _pre="${_pre//\{URL\}/${2}}"; ${_pre} ; }
|
||||
local _cmd="${_BM_CMD_CAPTURE//\{FILE\}/${1}}"; _cmd="${_cmd//\{URL\}/${2}}";
|
||||
local _args="${_BM_CMD_CAPTURE_ARGS//\{FILE\}/${1}}"; _args="${_args//\{URL\}/${2}}";
|
||||
eval ${_cmd} ${_args}
|
||||
[[ ! -z "${_BM_CMD_POST_CAPTURE}" ]] && {
|
||||
local _post="${_BM_CMD_POST_CAPTURE//\{FILE\}/${1}}"
|
||||
_post="${_post//\{URL\}/${2}}"
|
||||
${_post}
|
||||
}
|
||||
[[ ! -z "${_BM_CMD_POST_CAPTURE}" ]] && { local _post="${_BM_CMD_POST_CAPTURE//\{FILE\}/${1}}"; _post="${_post//\{URL\}/${2}}"; ${_post} ; }
|
||||
fi
|
||||
}
|
||||
|
||||
picturize() {
|
||||
if [ -z "${1:-}" ]; then
|
||||
awk -F'|' '$0 !~ /^[ ]*#/ {print $1,$4;}' "${_BM_BOOKMARK_FILE}" | while read m u; do
|
||||
[[ ! -f "${_BM_SCREENSHOT_DIRECTORY}/${m}.png" || ${__F:=0} -eq 1 ]] && { screenshot_take "${_BM_SCREENSHOT_DIRECTORY}/${m}.png" "${u}" & }
|
||||
[[ "${_BM_SCREENSHOT_WAIT,,}" = 'true' ]] && wait
|
||||
done
|
||||
else
|
||||
local _lines="$(search "${@}")"
|
||||
if [ "${_BM_ASK_BEFORE_OPEN,,}" = 'true' -a ${__O:=0} -eq 0 -a ${__Y:=0} -eq 0 ]; then
|
||||
if [ $(wc -l <<<"${_lines}") -gt 1 ]; then
|
||||
read -p"More than one URL found. Open all ? [Y/N] : " -n1 _answer
|
||||
[[ "${_answer,,}" != 'y' ]] && die "\nUse -O to force the first URL or refine your search"
|
||||
fi
|
||||
[[ ! -f "${_BM_SCREENSHOT_DIRECTORY}/${m}.png" || ${__F:=0} -eq 1 ]] && { screenshot_take "${_BM_SCREENSHOT_DIRECTORY}/${m}.png" "${u}" & }
|
||||
[[ "${_BM_SCREENSHOT_WAIT,,}" = 'true' ]] && wait
|
||||
done
|
||||
else
|
||||
local _lines="$(search "${@}")"
|
||||
if [ "${_BM_ASK_BEFORE_OPEN,,}" = 'true' -a ${__O:=0} -eq 0 -a ${__Y:=0} -eq 0 ]; then
|
||||
if [ $(wc -l <<< "${_lines}") -gt 1 ]; then
|
||||
read -p"More than one URL found. Open all ? [Y/N] : " -n1 _answer
|
||||
[[ "${_answer,,}" != 'y' ]] && die "\nUse -O to force the first URL or refine your search"
|
||||
fi
|
||||
local _all=''
|
||||
while read _nl; do
|
||||
readLines <<<"${_nl}"
|
||||
if [ "${_BM_OPEN_ALL,,}" = 'true' -o ${__Y:=0} -eq 1 ]; then
|
||||
IFS='|' read m d a u b <<<"${_nl}"
|
||||
screenshot_take "${_BM_SCREENSHOT_DIRECTORY}/${m}.png" "${u}" &
|
||||
else
|
||||
IFS='|' read m d a u b <<<"${_nl}"
|
||||
screenshot_take "${_BM_SCREENSHOT_DIRECTORY}/${m}.png" "${u}" &
|
||||
[[ "${_BM_OPEN_FIRST,,}" = 'true' || ${__O:=0} -eq 1 ]] && exit 0
|
||||
fi
|
||||
done <<<"$(echo -e "${_lines}")"
|
||||
fi
|
||||
local _all=''
|
||||
while read _nl; do
|
||||
readLines <<< "${_nl}"
|
||||
if [ "${_BM_OPEN_ALL,,}" = 'true' -o ${__Y:=0} -eq 1 ]; then
|
||||
IFS='|' read m d a u b <<< "${_nl}"
|
||||
screenshot_take "${_BM_SCREENSHOT_DIRECTORY}/${m}.png" "${u}" &
|
||||
else
|
||||
IFS='|' read m d a u b <<< "${_nl}"
|
||||
screenshot_take "${_BM_SCREENSHOT_DIRECTORY}/${m}.png" "${u}" &
|
||||
[[ "${_BM_OPEN_FIRST,,}" = 'true' || ${__O:=0} -eq 1 ]] && exit 0
|
||||
fi
|
||||
done <<< "$(echo -e "${_lines}")"
|
||||
fi
|
||||
}
|
||||
|
||||
bookmark_generator() {
|
||||
[[ ! -f "${_BM_SCREENSHOT_DIRECTORY}/black-Linen.png" && -f "/usr/share/bm/black-Linen.png" ]] && cp "/usr/share/bm/black-Linen.png" "${_BM_SCREENSHOT_DIRECTORY}/black-Linen.png"
|
||||
echo "<!DOCTYPE html><html><head><meta charset="UTF-8"><title>bm v${VERSION} : all your bookmarks</title>" >"${1:-${_BM_HTML_FILE}}"
|
||||
style >>"${1:-${_BM_HTML_FILE}}"
|
||||
echo "</head><body>" >>"${1:-${_BM_HTML_FILE}}"
|
||||
echo "<!DOCTYPE html><html><head><meta charset="UTF-8"><title>bm v${VERSION} : all your bookmarks</title>" > "${1:-${_BM_HTML_FILE}}"
|
||||
style >> "${1:-${_BM_HTML_FILE}}"
|
||||
echo "</head><body>" >> "${1:-${_BM_HTML_FILE}}"
|
||||
# search "${2:-}" | while IFS='|' read m a u T t d; do
|
||||
awk '$0 !~ /^[ ]*#/' "${_BM_BOOKMARK_FILE}" | while IFS='|' read m d a u T t; do
|
||||
echo " <div class=bm>
|
||||
echo " <div class=bm>
|
||||
<a href='${u}'><img src='${_BM_SCREENSHOT_DIRECTORY}/${m}.png' alt='${u}' /></a>
|
||||
<p>${T}<br/><a href='${_BM_SCREENSHOT_DIRECTORY}/${m}.png'>View image</a></p>
|
||||
</div>" >>"${1:-${_BM_HTML_FILE}}"
|
||||
done
|
||||
echo "</body></html>" >>"${1:-${_BM_HTML_FILE}}"
|
||||
[[ ${__O:=0} -eq 1 ]] && "${_BM_CMD_OPEN}" "${1:-${_BM_HTML_FILE}}"
|
||||
</div>" >> "${1:-${_BM_HTML_FILE}}"
|
||||
done
|
||||
echo "</body></html>" >> "${1:-${_BM_HTML_FILE}}"
|
||||
[[ ${__O:=0} -eq 1 ]] && "${_BM_CMD_OPEN}" "${1:-${_BM_HTML_FILE}}"
|
||||
}
|
||||
|
||||
#
|
||||
@ -760,6 +709,7 @@ die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# checkBinaries check the script is able to run and give hints
|
||||
#
|
||||
@ -781,61 +731,47 @@ checkBinaries() {
|
||||
[[ ${rc:=0} -ne 0 ]] && die "At least one command is missing. Please install it before using bm."
|
||||
# Checking sed
|
||||
local rc=1
|
||||
[[ ! -f "/tmp/sedtest.$$" ]] &&
|
||||
echo -n 'toto' >"/tmp/sedtest.$$" &&
|
||||
sed -i.bak -e 's;^toto$;tata;' "/tmp/sedtest.$$" &&
|
||||
[[ -f "/tmp/sedtest.$$.bak" ]] &&
|
||||
grep -q "tata" "/tmp/sedtest.$$" &&
|
||||
rc=0 &&
|
||||
[[ ! -f "/tmp/sedtest.$$" ]] && \
|
||||
echo -n 'toto' > "/tmp/sedtest.$$" && \
|
||||
sed -i.bak -e 's;^toto$;tata;' "/tmp/sedtest.$$" && \
|
||||
[[ -f "/tmp/sedtest.$$.bak" ]] && \
|
||||
grep -q "tata" "/tmp/sedtest.$$" && \
|
||||
rc=0 && \
|
||||
rm -f "/tmp/sedtest.$$" "/tmp/sedtest.$$.bak"
|
||||
[[ ${rc} -ne 0 ]] && die "sed seems to not handle -i argument properly, please check"
|
||||
}
|
||||
[[ ${rc} -ne 0 ]] && die "sed seems to not handle -i argument properly, please check"
|
||||
}
|
||||
|
||||
#
|
||||
# defineColors generate the variables to use to colorize the output
|
||||
#
|
||||
|
||||
defineColors() {
|
||||
export BLACK="\e[30m"
|
||||
export BLACK_LIGHT="\e[90m"
|
||||
export GRAY_DARK="${BLACK_LIGHT}"
|
||||
export RED="\e[31m"
|
||||
export RED_LIGHT="\e[91m"
|
||||
export GREEN="\e[32m"
|
||||
export GREEN_LIGHT="\e[92m"
|
||||
export YELLOW="\e[33m"
|
||||
export YELLOW_LIGHT="\e[93m"
|
||||
export BLUE="\e[34m"
|
||||
export BLUE_LIGHT="\e[94m"
|
||||
export MAGENTA="\e[35m"
|
||||
export MAGENTA_LIGHT="\e[95m"
|
||||
export CYAN="\e[36m"
|
||||
export CYAN_LIGHT="\e[96m"
|
||||
export GRAY="\e[37m"
|
||||
export GRAY_LIGHT="\e[97m"
|
||||
export WHITE="${GRAY_LIGHT}"
|
||||
export BLACK="\e[30m"; export BLACK_LIGHT="\e[90m"; export GRAY_DARK="${BLACK_LIGHT}"
|
||||
export RED="\e[31m"; export RED_LIGHT="\e[91m"
|
||||
export GREEN="\e[32m"; export GREEN_LIGHT="\e[92m"
|
||||
export YELLOW="\e[33m"; export YELLOW_LIGHT="\e[93m"
|
||||
export BLUE="\e[34m"; export BLUE_LIGHT="\e[94m"
|
||||
export MAGENTA="\e[35m"; export MAGENTA_LIGHT="\e[95m"
|
||||
export CYAN="\e[36m"; export CYAN_LIGHT="\e[96m"
|
||||
export GRAY="\e[37m"; export GRAY_LIGHT="\e[97m"; export WHITE="${GRAY_LIGHT}"
|
||||
|
||||
export RESET="\e[0m"
|
||||
export BOLD="\e[1m"
|
||||
export BOLD_RESET="\e[21m"
|
||||
export DIM="\e[2m"
|
||||
export DIM_RESET="\e[22m"
|
||||
export UNDERLINE="\e[4m"
|
||||
export UNDERLINE_RESET="\e[24m"
|
||||
export INVERT="\e[7m"
|
||||
export INVERT_RESET="\e[27m"
|
||||
export BOLD="\e[1m"; export BOLD_RESET="\e[21m"
|
||||
export DIM="\e[2m"; export DIM_RESET="\e[22m"
|
||||
export UNDERLINE="\e[4m"; export UNDERLINE_RESET="\e[24m"
|
||||
export INVERT="\e[7m"; export INVERT_RESET="\e[27m"
|
||||
if [ ! -z "${1:-}" ]; then
|
||||
echo "Use the following colors to fit your needs :"
|
||||
(
|
||||
echo -e "${RESET}${BLACK}BLACK${RESET} - ${BLACK_LIGHT}BLACK_LIGHT${RESET} - ${BOLD}${BLACK}BOLD BLACK${RESET} - ${DIM}${BLACK}DIM BLACK${RESET}"
|
||||
echo -e "${RESET}${RED}RED${RESET} - ${RED_LIGHT}RED_LIGHT${RESET} - ${BOLD}${RED}BOLD RED${RESET} - ${DIM}${RED}DIM RED${RESET}"
|
||||
echo -e "${RESET}${GREEN}GREEN${RESET} - ${GREEN_LIGHT}GREEN_LIGHT${RESET} - ${BOLD}${GREEN}BOLD GREEN${RESET} - ${DIM}${GREEN}DIM GREEN${RESET}"
|
||||
echo -e "${RESET}${YELLOW}YELLOW${RESET} - ${YELLOW_LIGHT}YELLOW_LIGHT${RESET} - ${BOLD}${YELLOW}BOLD YELLOW${RESET} - ${DIM}${YELLOW}DIM YELLOW${RESET}"
|
||||
echo -e "${RESET}${BLUE}BLUE${RESET} - ${BLUE_LIGHT}BLUE_LIGHT${RESET} - ${BOLD}${BLUE}BOLD BLUE${RESET} - ${DIM}${BLUE}DIM BLUE${RESET}"
|
||||
echo -e "${RESET}${MAGENTA}MAGENTA${RESET} - ${MAGENTA_LIGHT}MAGENTA_LIGHT${RESET} - ${BOLD}${MAGENTA}BOLD MAGENTA${RESET} - ${DIM}${MAGENTA}DIM MAGENTA${RESET}"
|
||||
echo -e "${RESET}${CYAN}CYAN${RESET} - ${CYAN_LIGHT}CYAN_LIGHT${RESET} - ${BOLD}${CYAN}BOLD CYAN${RESET} - ${DIM}${CYAN}DIM CYAN${RESET}"
|
||||
echo -e "${RESET}${GRAY}GRAY${RESET} - ${GRAY_LIGHT}GRAY_LIGHT${RESET} - ${BOLD}${GRAY}BOLD GRAY${RESET} - ${DIM}${GRAY}DIM GRAY${RESET}"
|
||||
echo -e "${RESET}${GRAY_DARK}GRAY_DARK${RESET} - ${WHITE}WHITE${RESET}"
|
||||
echo -e "${RESET}${BLACK}BLACK${RESET} - ${BLACK_LIGHT}BLACK_LIGHT${RESET} - ${BOLD}${BLACK}BOLD BLACK${RESET} - ${DIM}${BLACK}DIM BLACK${RESET}"
|
||||
echo -e "${RESET}${RED}RED${RESET} - ${RED_LIGHT}RED_LIGHT${RESET} - ${BOLD}${RED}BOLD RED${RESET} - ${DIM}${RED}DIM RED${RESET}"
|
||||
echo -e "${RESET}${GREEN}GREEN${RESET} - ${GREEN_LIGHT}GREEN_LIGHT${RESET} - ${BOLD}${GREEN}BOLD GREEN${RESET} - ${DIM}${GREEN}DIM GREEN${RESET}"
|
||||
echo -e "${RESET}${YELLOW}YELLOW${RESET} - ${YELLOW_LIGHT}YELLOW_LIGHT${RESET} - ${BOLD}${YELLOW}BOLD YELLOW${RESET} - ${DIM}${YELLOW}DIM YELLOW${RESET}"
|
||||
echo -e "${RESET}${BLUE}BLUE${RESET} - ${BLUE_LIGHT}BLUE_LIGHT${RESET} - ${BOLD}${BLUE}BOLD BLUE${RESET} - ${DIM}${BLUE}DIM BLUE${RESET}"
|
||||
echo -e "${RESET}${MAGENTA}MAGENTA${RESET} - ${MAGENTA_LIGHT}MAGENTA_LIGHT${RESET} - ${BOLD}${MAGENTA}BOLD MAGENTA${RESET} - ${DIM}${MAGENTA}DIM MAGENTA${RESET}"
|
||||
echo -e "${RESET}${CYAN}CYAN${RESET} - ${CYAN_LIGHT}CYAN_LIGHT${RESET} - ${BOLD}${CYAN}BOLD CYAN${RESET} - ${DIM}${CYAN}DIM CYAN${RESET}"
|
||||
echo -e "${RESET}${GRAY}GRAY${RESET} - ${GRAY_LIGHT}GRAY_LIGHT${RESET} - ${BOLD}${GRAY}BOLD GRAY${RESET} - ${DIM}${GRAY}DIM GRAY${RESET}"
|
||||
echo -e "${RESET}${GRAY_DARK}GRAY_DARK${RESET} - ${WHITE}WHITE${RESET}"
|
||||
) | column -t
|
||||
echo -e "You could also use the ${UNDERLINE}UNDERLINE, the ${INVERT}INVERT and the ${RESET}RESET variable. INVERT_RESET and UNDERLINE_RESET also available"
|
||||
exit 0
|
||||
@ -850,38 +786,17 @@ defineColors() {
|
||||
_regex='^(help|version|tags|ls|list|search|open|add|view|stats|statistics|clear|colors)$'
|
||||
if [[ ${1:-} =~ ${_regex} ]]; then
|
||||
case "$1" in
|
||||
tags) __L=1 ;;
|
||||
ls | list) __l=1 ;;
|
||||
search)
|
||||
__s=1
|
||||
__search="${@:2}"
|
||||
;;
|
||||
open)
|
||||
__o=1
|
||||
__open="${@:2}"
|
||||
;;
|
||||
add)
|
||||
__a=1
|
||||
__url="${2:-}"
|
||||
__T="${3:-}"
|
||||
__t="${4:-}"
|
||||
__A="${5:-}"
|
||||
;;
|
||||
view)
|
||||
__r=1
|
||||
__search="${@:2}"
|
||||
;;
|
||||
stats | statistics) __S=1 ;;
|
||||
clear) die "This now a deprecated feature. Use -d instead." ;;
|
||||
colors) __C=1 ;;
|
||||
help)
|
||||
usage 1
|
||||
exit 0
|
||||
;;
|
||||
version)
|
||||
echo -n "${0} v${VERSION}"
|
||||
exit 0
|
||||
;;
|
||||
tags) __L=1 ;;
|
||||
ls|list) __l=1 ;;
|
||||
search) __s=1; __search="${@:2}" ;;
|
||||
open) __o=1; __open="${@:2}";;
|
||||
add) __a=1; __url="${2:-}"; __T="${3:-}"; __t="${4:-}"; __A="${5:-}";;
|
||||
view) __r=1; __search="${@:2}" ;;
|
||||
stats|statistics) __S=1 ;;
|
||||
clear) die "This now a deprecated feature. Use -d instead." ;;
|
||||
colors) __C=1;;
|
||||
help) usage 1;exit 0;;
|
||||
version) echo -n "${0} v${VERSION}";exit 0;;
|
||||
esac
|
||||
else
|
||||
# -c config file
|
||||
@ -912,87 +827,43 @@ else
|
||||
# available : ---------e-f----I-JjKk--Mm------Q-R-----Uu--W----yZ-0123456789
|
||||
while getopts ":a:A:b:c:d:G:o:P:q:r:s:t:T:w:x:BCDEFghHilLnNOpPSvVXYz" option; do
|
||||
case ${option} in
|
||||
a)
|
||||
__a=1
|
||||
__url="${OPTARG}"
|
||||
;; # Add url to bookmark
|
||||
A) __A="${OPTARG}" ;; # AcceleratoR
|
||||
b) __b="${OPTARG}" ;; # Bookmark file
|
||||
B) __B=1 ;; # Don't load the default config file
|
||||
c) __c="${OPTARG}" ;; # Config file
|
||||
C) __C=1 ;; # Print color table
|
||||
d)
|
||||
__d=1
|
||||
__del="${OPTARG}"
|
||||
;; # Config file
|
||||
D) __D=1 ;; # Print color table
|
||||
E) __E=1 ;; # Open the bm.bmf file with the $EDITOR
|
||||
F) __F=1 ;; # Force the add or delete or picture
|
||||
g) ((__g++)) ;; # generate html file(s)
|
||||
G)
|
||||
__G=1
|
||||
__file="${OPTARG}"
|
||||
;; # Generate this file (only for g=1)
|
||||
h | H)
|
||||
usage
|
||||
exit 0
|
||||
;; # Help
|
||||
i) __i=1 ;; # Ignore case when searching
|
||||
l) __l=1 ;; # List all bookmarks
|
||||
L) __L=1 ;; # List all tags
|
||||
n) __n=1 ;; # sort by date
|
||||
N) __N=1 ;; # sort by date (reverse)
|
||||
o)
|
||||
__o=1
|
||||
__open="${OPTARG}"
|
||||
;; # Open
|
||||
O) __O=1 ;; # Open First
|
||||
p) __p=1 ;; # Take a screenshot
|
||||
P)
|
||||
__P=1
|
||||
__search="${OPTARG}"
|
||||
;; # Take all screenshot
|
||||
q)
|
||||
__q=1
|
||||
__search="${OPTARG}"
|
||||
;; # Search
|
||||
r)
|
||||
__r=1
|
||||
__search="${OPTARG}"
|
||||
;; # Search
|
||||
s)
|
||||
__s=1
|
||||
__search="${OPTARG}"
|
||||
;; # Search
|
||||
S) __S=1 ;; # Print Statistics
|
||||
t) __t="${OPTARG}" ;; # tags for a URL
|
||||
T) __T="${OPTARG}" ;; # Title for a URL
|
||||
v | V)
|
||||
echo -n "${0} v${VERSION}"
|
||||
[[ "${option}" = 'V' ]] && echo -n " [commit: ${RELEASE}]"
|
||||
echo ''
|
||||
exit 0
|
||||
;;
|
||||
w) __w="${OPTARG}" ;; # Working directory
|
||||
x)
|
||||
__x=1
|
||||
__copy="${OPTARG}"
|
||||
;; # Copy
|
||||
X) __X=1 ;; # Copy First
|
||||
Y) __Y=1 ;; # Open/copy All
|
||||
z) __z=1 ;; # Alternative print listing
|
||||
:)
|
||||
echo "Missing argument for '-${OPTARG}'" >&2
|
||||
exit 1
|
||||
;;
|
||||
?)
|
||||
echo "Argument unknown '-${OPTARG}'" >&2
|
||||
exit 1
|
||||
;; # usage;;
|
||||
*)
|
||||
echo "Argument unknown '-${option}'" >&2
|
||||
exit 1
|
||||
;; # usage;;
|
||||
a) __a=1; __url="${OPTARG}";; # Add url to bookmark
|
||||
A) __A="${OPTARG}";; # AcceleratoR
|
||||
b) __b="${OPTARG}";; # Bookmark file
|
||||
B) __B=1;; # Don't load the default config file
|
||||
c) __c="${OPTARG}";; # Config file
|
||||
C) __C=1;; # Print color table
|
||||
d) __d=1; __del="${OPTARG}";; # Config file
|
||||
D) __D=1;; # Print color table
|
||||
E) __E=1;; # Open the bm.bm file with the $EDITOR
|
||||
F) __F=1;; # Force the add or delete or picture
|
||||
g) (( __g++ ));; # generate html file(s)
|
||||
G) __G=1; __file="${OPTARG}";; # Generate this file (only for g=1)
|
||||
h|H) usage; exit 0;; # Help
|
||||
i) __i=1;; # Ignore case when searching
|
||||
l) __l=1;; # List all bookmarks
|
||||
L) __L=1;; # List all tags
|
||||
n) __n=1;; # sort by date
|
||||
N) __N=1;; # sort by date (reverse)
|
||||
o) __o=1; __open="${OPTARG}";; # Open
|
||||
O) __O=1;; # Open First
|
||||
p) __p=1;; # Take a screenshot
|
||||
P) __P=1; __search="${OPTARG}";; # Take all screenshot
|
||||
q) __q=1; __search="${OPTARG}";; # Search
|
||||
r) __r=1; __search="${OPTARG}";; # Search
|
||||
s) __s=1; __search="${OPTARG}";; # Search
|
||||
S) __S=1;; # Print Statistics
|
||||
t) __t="${OPTARG}";; # tags for a URL
|
||||
T) __T="${OPTARG}";; # Title for a URL
|
||||
v|V) echo -n "${0} v${VERSION}"; [[ "${option}" = 'V' ]] && echo -n " [commit: ${RELEASE}]"; echo ''; exit 0;;
|
||||
w) __w="${OPTARG}";; # Working directory
|
||||
x) __x=1; __copy="${OPTARG}";; # Copy
|
||||
X) __X=1;; # Copy First
|
||||
Y) __Y=1;; # Open/copy All
|
||||
z) __z=1;; # Alternative print listing
|
||||
:) echo "Missing argument for '-${OPTARG}'" >&2 ; exit 1 ;;
|
||||
?) echo "Argument unknown '-${OPTARG}'" >&2 ; exit 1 ;; # usage;;
|
||||
*) echo "Argument unknown '-${option}'" >&2 ; exit 1 ;; # usage;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
@ -1013,92 +884,42 @@ config "${__c}"
|
||||
# Following config, we maybe not have to check the capture tool
|
||||
[[ ${_BM_CMD_CAPTURE_CHECK} ]] && checkBinaries "${_BM_CMD_CAPTURE}"
|
||||
|
||||
# If no bookmark file exist, create one if allowed else echo
|
||||
# If no bookmark file exist, create one if allowed
|
||||
if [ ! -f "${_BM_BOOKMARK_FILE}" -a "${_BM_CREATE_BOOKMARK_FILE,,}" = 'true' ]; then
|
||||
# Remember fields : 0=md5, 1=date, 2=accel, 3=url, 4=title, 5=tags
|
||||
echo "eef521de8df447ad392dbace16cf2edc|$(date '+%FT%TZ')|:bm|https://github.com/The-Repo-Club/repomenu-extra/|Download link for repomenu-extra|default,shell,scripts" >>"${_BM_BOOKMARK_FILE}"
|
||||
fi
|
||||
|
||||
if [ ! -f "${_BM_BOOKMARK_FILE}" -a "${_BM_CREATE_BOOKMARK_FILE,,}" = 'false' ]; then
|
||||
echo "No current bookmark file found.";
|
||||
exit
|
||||
# Remember fields : 1=md5, 2=date, 2=accel, 3=url, 4=title, 5=tags
|
||||
echo "eef521de8df447ad392dbace16cf2edc|$(date '+%FT%TZ')|:bm|https://github.com/The-Repo-Club/repomenu-extra/|Download link for repomenu-extra|default,shell,scripts" >> "${_BM_BOOKMARK_FILE}"
|
||||
fi
|
||||
|
||||
# Starting to work with args. If none probably list...
|
||||
[[ ${#} -eq 0 && "${_BM_NO_ARGS_FORCE_HELP,,}" = 'true' ]] && {
|
||||
usage
|
||||
exit
|
||||
}
|
||||
[[ ${#} -eq 0 && "${_BM_NO_ARGS_FORCE_HELP,,}" = 'true' ]] && { usage ; exit; }
|
||||
|
||||
# Only one action at a time
|
||||
if [ $((${__a:=0} + ${__C:=0} + ${__d:=0} + ${__E:=0} + ${__g:=0} + ${__l:=0} + ${__L:=0} + ${__o:=0} + ${__P:=0} + ${__q:=0} + ${__r:=0} + ${__s:=0} + ${__S:=0} + ${__x:=0})) -gt 1 ]; then
|
||||
if [ $(( ${__a:=0} + ${__C:=0} + ${__d:=0} + ${__E:=0} + ${__g:=0} + ${__l:=0} + ${__L:=0} + ${__o:=0} + ${__P:=0} + ${__q:=0} + ${__r:=0} + ${__s:=0} + ${__S:=0} + ${__x:=0} )) -gt 1 ]; then
|
||||
echo "You have to choose between -a, -C, -d, -E, -g, -l, -L, -o, -P, -q, -r, -s, -S, -x" >&2
|
||||
echo "Use -h for help" >&2
|
||||
exit 0
|
||||
fi
|
||||
if [ $((${__O:=0} + ${__Y:=0} + ${__X:=0})) -gt 1 ]; then
|
||||
if [ $(( ${__O:=0} + ${__Y:=0} + ${__X:=0} )) -gt 1 ]; then
|
||||
echo "You have to choose between -O, -X, -Y" >&2
|
||||
echo "Use -h for help" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Executing actions
|
||||
[[ ${__a} -eq 1 ]] && {
|
||||
saveUrl
|
||||
exit
|
||||
}
|
||||
[[ ${__C} -eq 1 ]] && {
|
||||
defineColors 1
|
||||
exit
|
||||
}
|
||||
[[ ${__d} -eq 1 ]] && {
|
||||
delete_bookmark "${__del}"
|
||||
exit
|
||||
}
|
||||
[[ ${__g} -ge 1 ]] && {
|
||||
bookmark_generator "${__file:=}" ''
|
||||
exit
|
||||
}
|
||||
[[ ${__l} -eq 1 ]] && {
|
||||
search
|
||||
exit
|
||||
}
|
||||
[[ ${__L} -eq 1 ]] && {
|
||||
list_tags
|
||||
exit
|
||||
}
|
||||
[[ ${__o} -eq 1 ]] && {
|
||||
open_bookmark "${__open}"
|
||||
exit
|
||||
}
|
||||
[[ ${__P} -eq 1 ]] && {
|
||||
picturize "${__search}"
|
||||
exit
|
||||
}
|
||||
[[ ${__r} -eq 1 ]] && {
|
||||
recorded_picture "${__search}"
|
||||
exit
|
||||
}
|
||||
[[ ${__q} -eq 1 ]] && {
|
||||
download_title "${__search}"
|
||||
exit
|
||||
}
|
||||
[[ ${__s} -eq 1 ]] && {
|
||||
search_bookmarks "${__search}"
|
||||
exit
|
||||
}
|
||||
[[ ${__S} -eq 1 ]] && {
|
||||
stats
|
||||
exit
|
||||
}
|
||||
[[ ${__x} -eq 1 ]] && {
|
||||
copy_bookmark "${__copy}"
|
||||
exit
|
||||
}
|
||||
[[ ${__E} -eq 1 ]] && {
|
||||
edit_bookmark
|
||||
exit
|
||||
}
|
||||
[[ ${__a} -eq 1 ]] && { saveUrl ; exit ; }
|
||||
[[ ${__C} -eq 1 ]] && { defineColors 1 ; exit ; }
|
||||
[[ ${__d} -eq 1 ]] && { delete_bookmark "${__del}"; exit ; }
|
||||
[[ ${__g} -ge 1 ]] && { bookmark_generator "${__file:=}" ''; exit ; }
|
||||
[[ ${__l} -eq 1 ]] && { search ; exit; }
|
||||
[[ ${__L} -eq 1 ]] && { list_tags ; exit; }
|
||||
[[ ${__o} -eq 1 ]] && { open_bookmark "${__open}" ; exit; }
|
||||
[[ ${__P} -eq 1 ]] && { picturize "${__search}" ; exit; }
|
||||
[[ ${__r} -eq 1 ]] && { recorded_picture "${__search}" ; exit; }
|
||||
[[ ${__q} -eq 1 ]] && { download_title "${__search}" ; exit; }
|
||||
[[ ${__s} -eq 1 ]] && { search_bookmarks "${__search}" ; exit; }
|
||||
[[ ${__S} -eq 1 ]] && { stats ; exit; }
|
||||
[[ ${__x} -eq 1 ]] && { copy_bookmark "${__copy}" ; exit; }
|
||||
[[ ${__E} -eq 1 ]] && { edit_bookmark ; exit; }
|
||||
search
|
||||
|
||||
# $Format:%cn @ %cD$ : $Id$
|
||||
|
@ -12,7 +12,7 @@
|
||||
#Created:
|
||||
# Fri 09 December 2022, 06:43:41 AM [GMT]
|
||||
#Modified:
|
||||
# Fri 09 December 2022, 08:02:52 AM [GMT]
|
||||
# Fri 14 July 2023, 11:04:29 PM [GMT+1]
|
||||
#
|
||||
#Description:
|
||||
# <Todo>
|
||||
@ -22,7 +22,7 @@
|
||||
#
|
||||
# shellcheck disable=all
|
||||
|
||||
bmFile="$HOME/.config/rofi/bookmarks/bm.bmf"
|
||||
bmFile="$HOME/.config/rofi/bookmarks/bm.bm"
|
||||
|
||||
if [[ ! -f $bmFile ]]; then
|
||||
printf "%s\n" "No current bookmark file found.";
|
||||
|
@ -12,7 +12,7 @@
|
||||
#Created:
|
||||
# Fri 09 December 2022, 06:43:30 AM [GMT]
|
||||
#Modified:
|
||||
# Fri 09 December 2022, 08:02:26 AM [GMT]
|
||||
# Fri 14 July 2023, 11:04:22 PM [GMT+1]
|
||||
#
|
||||
#Description:
|
||||
# <Todo>
|
||||
@ -22,7 +22,7 @@
|
||||
#
|
||||
# shellcheck disable=all
|
||||
|
||||
bmFile="$HOME/.config/rofi/bookmarks/bm.bmf"
|
||||
bmFile="$HOME/.config/rofi/bookmarks/bm.bm"
|
||||
|
||||
if [[ ! -f $bmFile ]]; then
|
||||
printf "%s\n" "No current bookmark file found.";
|
||||
|
Loading…
Reference in New Issue
Block a user