function lsh() {
/usr/libexec/PlistBuddy -c Print ~/Library/Safari/History.plist | \
/usr/bin/awk '/^[[:space:]]+= /{sub( /^[[:space:]]+=[[:space:]]+/,""); print}' | \
sed -E -n -e 's/^(.{1,100}).*$/\1/' -e '1!G;h;$p' | /usr/bin/nl
return 0
}
lsh
function dshe() {
declare array_indices historyplistfile index regex
regex="${1:-$'\777'}"
historyplistfile="${HOME}/Library/Safari/History.plist"
array_indices="$(/usr/libexec/PlistBuddy -c print "${historyplistfile}" | /usr/bin/awk '/^[[:space:]]+= /{x++;print x-1,$0}' | \
/usr/bin/egrep -iv "${regex}" | /usr/bin/awk '{print $1}' | /usr/bin/sort -rn)"
:<<-'COMMENT'
# test
for index in ${array_indices}; do
echo $index;
#/usr/libexec/PlistBuddy -c "Print :WebHistoryDates:'${index}'" "${historyplistfile}"
/usr/libexec/PlistBuddy -c "Print :WebHistoryDates:'${index}':title" "${historyplistfile}"
done
COMMENT
for index in ${array_indices}; do
/usr/libexec/PlistBuddy -c "Delete :WebHistoryDates:'${index}'" "${historyplistfile}"
done
/usr/libexec/PlistBuddy -c save "${historyplistfile}" &>/dev/null
return 0
}
lsh
dshe unix
lsh
dshe
lsh