# for PlistBuddy see: http://codesnippets.joyent.com/posts/show/1484 # list Safari history 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 #/usr/bin/sed -n '1!G;h;$p' | /usr/bin/nl #/usr/bin/awk '!x[$0]++' | /usr/bin/sed -n '1!G;h;$p' | /usr/bin/nl #/usr/bin/sort -u | /usr/bin/nl return 0 } lsh # delete Safari history except ... # ... for those domains specified by an egrep regex function dshe() { declare array_indices historyplistfile index regex regex="${1:-$'\777'}" # delete entire history if there is no argument $1; for \777 see man ruby 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
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
List & delete Safari history (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» List & delete Safari cookies in shell osx mac bash cookie unix safari delete list plistbuddy plist
» Using PlistBuddy to customiz... in shell osx mac launchd bash unix defaults launchctl plistbuddy syslogd plist
» Listing Dock items with Plis... in shell osx mac bash unix plistbuddy plist dock
» app2dock in shell osx mac bash unix add remove plistbuddy plist lsregister dock
» Delete WebKit search fields in shell osx mac bash unix safari webkit
» Create & delete user account... in shell osx mac bash unix delete create user account dscl
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails