Skip to content

Instantly share code, notes, and snippets.

@ryo-n
Last active December 13, 2019 14:46
Show Gist options
  • Save ryo-n/2bfed7e79972e950d1c6950ef2226664 to your computer and use it in GitHub Desktop.
Save ryo-n/2bfed7e79972e950d1c6950ef2226664 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# https://github.com/junegunn/fzf/wiki/examples
c() {
local columns cols sep google_history open
columns=$(tput cols)
cols=$(( columns / 3 ))
sep='{::}'
if [ "$(uname)" = "Darwin" ]; then
google_history="$HOME/Library/Application Support/Google/Chrome/Default/History"
open=open
else
google_history="$HOME/.config/google-chrome/Default/History"
open=xdg-open
fi
cp -f "$google_history" /tmp/h
sqlite3 -separator $sep /tmp/h \
"SELECT substr(title, 1, $cols), url
FROM urls WHERE title != '' GROUP BY url ORDER BY last_visit_time DESC" |
awk -F $sep '{printf "%-'$cols's \x1b[36m%s\x1b[m\n", $1, $2}' |
fzf --ansi --multi --no-sort --toggle-sort=ctrl-r | sed 's#.*\(https*://\)#\1#' | xargs $open > /dev/null 2> /dev/null
}
c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment