1 # Reads original zshrc and contains old zshrc stuff
3 source ${HOME}/.zsh/grml-etc-core/etc/zsh/zshrc
5 # just type 'cd ...' to get 'cd ../..'
7 if [[ $LBUFFER == *.. ]] ; then
13 zle -N rationalise-dot
14 bindkey . rationalise-dot
16 bindkey '\eq' push-line-or-edit
18 zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
22 if [[ "$#*" -eq 0 ]] ; then
23 [[ -r ~/.zshrc ]] && . ~/.zshrc
32 compdef _functions reload
35 [[ -z $1 ]] && { print "USAGE: zurl <URL>" ; return 1 }
37 local PN url tiny grabber search result preview
40 # Check existence of given URL with the help of ping(1).
41 # N.B. ping(1) only works without an eventual given protocol.
42 ping -c 1 ${${url#(ftp|http)://}%%/*} >& /dev/null || \
43 read -q "?Given host ${${url#http://*/}%/*} is not reachable by pinging. Proceed anyway? [y|n] "
45 if (( $? == 0 )) ; then
46 # Prepend 'http://' to given URL where necessary for later output.
47 [[ ${url} != http(s|)://* ]] && url='http://'${url}
48 tiny='http://tinyurl.com/create.php?url='
49 if check_com -c wget ; then
50 grabber='wget -O- -o/dev/null'
52 print "wget is not available, but mandatory for ${PN}. Aborting."
54 # Looking for i.e.`copy('http://tinyurl.com/7efkze')' in TinyURL's HTML code.
55 search='copy\(?http://tinyurl.com/[[:alnum:]]##*'
56 result=${(M)${${${(f)"$(${=grabber} ${tiny}${url})"}[(fr)${search}*]}//[()\';]/}%%http:*}
57 # TinyURL provides the rather new feature preview for more confidence. <http://tinyurl.com/preview.php>
58 preview='http://preview.'${result#http://}
60 printf '%s\n\n' "${PN} - Shrinking long URLs via webservice TinyURL <http://tinyurl.com>."
61 printf '%s\t%s\n\n' 'Given URL:' ${url}
62 printf '%s\t%s\n\t\t%s\n' 'TinyURL:' ${result} ${preview}
68 ## END OF FILE #################################################################