Après zpaste voici zurl

Baptiste Daroussin baptiste.daroussin at gmail.com
Fri Dec 5 17:18:52 CET 2008


zurl envoie une url sur pastealacon en pure zsh

---
Bapt
-------------- section suivante --------------
#!/usr/bin/env zsh
PROG=$0
usage() {
    print "$PROG [-x] [url]"
    print "-x\tgrab url from X11 clipboard"
    return -1
}
[[ $# -eq 0 ]] && usage
zurlencode() {
    setopt localoptions extendedglob
    input=( ${(s::)1} )
    URLREPLY=${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%${(l:2::0:)$(([##16]#match))}}
}
if [[ $# = 0 ]];then
    usage
elif [[ "$1" = "-x" ]] ;then
    URL=$(xclip -o 2>/dev/null)
else
    URL=$1
fi
autoload -U tcp_open
TCP_SILENT=1
zurlencode $URL
tcp_open -q urlalacon.com 80 urlalacon || return 2
tcp_send -s urlalacon -- "GET /?url=${URLREPLY}&alacon=1 HTTP/1.1"
tcp_send -s urlalacon -- "Host: urlalacon.com"
tcp_send -s urlalacon -- "Accept-Charset: utf-8"
tcp_send -s urlalacon -- ""
tcp_read -b -d -s urlalacon 
tcp_close -q urlalacon
print ${${tcp_lines[149]/*href=/}/>*}


More information about the Shell mailing list