Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
Fix #14 & Fix #15
  • Loading branch information
Flyounet committed Feb 11, 2016
2 parents a1b0741 + 63f1192 commit 01e7ed5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions bm
Expand Up @@ -253,11 +253,15 @@ EOF

getAccelMax() {
# $2 ~ /^[[:SPACE:]]*:[[:SPACE:]]*[0-9][[:SPACE:]]*+$/ { n=gensub(/:([0-9])+/, "\\1", "g", $2); if (n>m) m=n; }
awk -F'|' '
BEGIN { m=0; }
$0 !~ /^[ ]*#/ && $2 ~ /^[:space:]*:[:space:]*[0-9]+[:space:]*$/ { sub(/:+/, "", $2); if ($2>m) m=$2; }
END { print m+1; }
' "${_BM_BOOKMARK_FILE}"
# awk -F'|' '
# BEGIN { m=0; }
# $0 !~ /^[ ]*#/ && $2 ~ /^[:space:]*:[:space:]*[0-9]+[:space:]*$/ { sub(/:+/, "", $2); if ($2>m) m=$2; }
# END { print m+1; }
# ' "${_BM_BOOKMARK_FILE}"
while read a; do
(( ${a:=0} >= ${_max:=0} )) && (( _max=${a}+1 ))
done <<< "$( awk -F'|' '$0 !~ /^[ ]*#/ && $2 ~ /^[:space:]*:[:space:]*[0-9]+[:space:]*$/ { sub(/:+/, "", $2); print $2; }' "${_BM_BOOKMARK_FILE}")"
echo -n "${_max}"
}

backupBm() {
Expand Down Expand Up @@ -289,6 +293,7 @@ saveUrl() {
if [ ${_BM_GET_PAGE_TITLE} = true -a -z "${__T:=}" ]; then
__T="$( curl -ks "${__url}" 2>&1 | sed '/<title>/I!d;/<\/title>/I!d;s;^[[:space:]]*<title>\([^<]*\)<.*;\1;i' )"
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
Expand Down Expand Up @@ -412,19 +417,21 @@ 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 ''
fi
fi
backupBm
local _all=''
while read _nl; do
readLines <<< "${_nl}"
if [ ${_BM_DELETE_TO_FILE} = true -o ${__D:=0} -eq 1 ]; then
echo "${_nl}" >> "${_BM_DELETE_FILE}"
fi
_nl="${_nl//\|/\\|}"
sed -i -e '/'"${_nl//\//\\/}"'/d' "${_BM_BOOKMARK_FILE}"
done <<< "$(echo -e "${_lines}")"
else
Expand Down

0 comments on commit 01e7ed5

Please sign in to comment.