f2078372756008a4f49ac50e2677aa269eabf20f
[uzbl-mobile] / examples / data / uzbl / scripts / load_url_from_history.sh
1 #!/bin/sh
2
3 history_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history
4 [ -r "$history_file" ] || exit 1
5
6 # choose from all entries, sorted and uniqued
7 # goto=`awk '{print $3}' $history_file | sort -u | dmenu -i`
8 COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
9 if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]';
10 then
11         DMENU="dmenu -i -xs -rs -l 10" # vertical patch
12         # choose an item in reverse order, showing also the date and page titles
13         # pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url.
14         goto=`tac $history_file | $DMENU $COLORS | cut -d ' ' -f -3  | awk '{print $NF}'`
15 else    
16         DMENU="dmenu -i"
17         # choose from all entries (no date or title), the first one being current url, and after that all others, sorted and uniqued, in ascending order
18         current=`tail -n 1 $history_file | awk '{print $3}'`; 
19   goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" \
20       | sort -u) | $DMENU $COLORS`
21 fi 
22
23 [ -n "$goto" ] && echo "uri $goto" > $4
24 #[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto"