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
9 elif [[ $LBUFFER == cd ]] ; then
15 zle -N rationalise-dot
16 bindkey . rationalise-dot
18 bindkey '\eq' push-line-or-edit
20 zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
24 if [[ "$#*" -eq 0 ]] ; then
25 [[ -r ~/.zshrc ]] && . ~/.zshrc
34 compdef _functions reload
37 [[ -z $1 ]] && { print "USAGE: zurl <URL>" ; return 1 }
39 local PN url tiny grabber search result preview
42 # Check existence of given URL with the help of ping(1).
43 # N.B. ping(1) only works without an eventual given protocol.
44 ping -c 1 ${${url#(ftp|http)://}%%/*} >& /dev/null || \
45 read -q "?Given host ${${url#http://*/}%/*} is not reachable by pinging. Proceed anyway? [y|n] "
47 if (( $? == 0 )) ; then
48 # Prepend 'http://' to given URL where necessary for later output.
49 [[ ${url} != http(s|)://* ]] && url='http://'${url}
50 tiny='http://tinyurl.com/create.php?url='
51 if check_com -c wget ; then
52 grabber='wget -O- -o/dev/null'
54 print "wget is not available, but mandatory for ${PN}. Aborting."
56 # Looking for i.e.`copy('http://tinyurl.com/7efkze')' in TinyURL's HTML code.
57 search='copy\(?http://tinyurl.com/[[:alnum:]]##*'
58 result=${(M)${${${(f)"$(${=grabber} ${tiny}${url})"}[(fr)${search}*]}//[()\';]/}%%http:*}
59 # TinyURL provides the rather new feature preview for more confidence. <http://tinyurl.com/preview.php>
60 preview='http://preview.'${result#http://}
62 printf '%s\n\n' "${PN} - Shrinking long URLs via webservice TinyURL <http://tinyurl.com>."
63 printf '%s\t%s\n\n' 'Given URL:' ${url}
64 printf '%s\t%s\n\t\t%s\n' 'TinyURL:' ${result} ${preview}
70 ## END OF FILE #################################################################