scripts/cl1p/cl1p.sh

41 lines
974 B
Bash
Executable File

#!/bin/bash
# Nom du clip utilisé et url
cat ~/.cl1p &>/dev/null
if [ $? -eq 0 ]
then id=`cat ~/.cl1p`
else read -p "Choisissez un nom pour votre cl1p : " id
echo $id > ~/.cl1p
echo "L'url de votre cl1p est https://cl1p.net/$id"
echo -e "Vous pouvez le modifier en éditant le fichier ~/.cl1p\n"
fi
url=https://cl1p.net/$id
tmp=$HOME/.cl1p_tmp
# Fonction print du contenu du cl1p
printclip() {
cat $tmp|iconv -f latin1 -t utf-8
}
# RECUPERER LE CL1P
curl -s https://api.cl1p.net/$id > $tmp
size=`wc -c $tmp | cut -d\ -f1`
if [ ${size} -gt 2 ]; then clip=1; else clip=0; fi
case $clip in
0) echo -e "Saisir le contenu et appuyer sur Ctrl+D :\n"
# ttl = time to live en MINUTES
# cat | curl --data "ttl=0&content=$(</dev/stdin)" $url &> /dev/null
cat | curl --data "ttl=0&content=$(</proc/self/fd/0)" $url &> /dev/null
echo -e "\nClip envoyé à $url"
;;
1) printclip
;;
esac
# Ajouter menu New/Resend/Quit...
rm $tmp