Add bin/duckduckgo & ddg alias

This commit is contained in:
Henrik Lissner 2017-04-25 02:35:22 -04:00
parent 2bc05af687
commit 216d1d5ec9
2 changed files with 18 additions and 0 deletions

16
bin/duckduckgo Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
urlencode() {
local LANG=C
for ((i=0;i<${#1};i++)); do
if [[ ${1:$i:1} =~ ^[a-zA-Z0-9\.\~\_\-]$ ]]; then
printf "${1:$i:1}"
else
printf '%%%02X' "'${1:$i:1}"
fi
done
}
query=$(urlencode "$*")
echo "Opening https://duckduckgo.com/?q=$query"
open "https://duckduckgo.com/?q=$query"

View file

@ -6,6 +6,8 @@ autoload -U zmv
zman() { PAGER="less -g -s '+/^ "$1"'" man zshall; } zman() { PAGER="less -g -s '+/^ "$1"'" man zshall; }
alias ag='noglob ag' alias ag='noglob ag'
alias ddg='duckduckgo'
# Canonical hex dump; some systems have this symlinked # Canonical hex dump; some systems have this symlinked
is-callable hd || alias hd="hexdump -C" is-callable hd || alias hd="hexdump -C"