Author: rukh-debug
February 20, 2025 ยท View on GitHub
#!/usr/bin/env bash
Author: rukh-debug
Date: 2025 Feb 16
https://github.com/orhun/rustypaste <3
This script is a very minimal UI for rustyPaste server - built for poweruser.
demo: https://i.postimg.cc/MHXFPdCq/image.png
Requirements: zenity, wl-copy
SERVER="https://your.server.url" AUTH_TOKEN=$(cat ~/.secrets/rustypaste.secret)
Function to copy to clipboard
copy_to_clipboard() { echo "$1" | wl-copy # zenity --info --title "Success" --text "URL copied to clipboard:\n$1" notify-send "Success" "URL copied to clipboard:\n$1" exit 0 }
Main menu
while true; do
choice=$(zenity --list
--title "Upload Options"
--column "Options"
"Paste Text"
"Upload File"
"Upload File with Expiry"
"One-shot File"
"One-shot URL"
"Shorten URL"
"Upload from Remote URL"
"Exit")
case $choice in
"Paste Text")
text=$(zenity --text-info \
--title "Paste Text" \
--width 400 \
--height 300 \
--editable)
if [ $? -eq 0 ] && [ ! -z "$text" ]; then
url=$(echo "$text" | curl -H "Authorization: $AUTH_TOKEN" -F "file=@-" "$SERVER")
copy_to_clipboard "$url"
fi
;;
"Upload File")
file=$(zenity --file-selection --title "Select File")
if [ $? -eq 0 ]; then
url=$(curl -H "Authorization: $AUTH_TOKEN" -F "file=@$file" "$SERVER")
copy_to_clipboard "$url"
fi
;;
"Upload File with Expiry")
file=$(zenity --file-selection --title "Select File")
if [ $? -eq 0 ]; then
expiry=$(zenity --entry \
--title "Set Expiry" \
--text "Enter expiry time (e.g., 10min, 1h, 1d):")
if [ $? -eq 0 ]; then
url=$(curl -H "Authorization: $AUTH_TOKEN" -F "file=@$file" -H "expire:$expiry" "$SERVER")
copy_to_clipboard "$url"
fi
fi
;;
"One-shot File")
file=$(zenity --file-selection --title "Select One-shot File")
if [ $? -eq 0 ]; then
url=$(curl -H "Authorization: $AUTH_TOKEN" -F "oneshot=@$file" "$SERVER")
copy_to_clipboard "$url"
fi
;;
"One-shot URL")
url_input=$(zenity --entry \
--title "One-shot URL" \
--text "Enter URL:")
if [ $? -eq 0 ] && [ ! -z "$url_input" ]; then
url=$(curl -H "Authorization: $AUTH_TOKEN" -F "oneshot_url=$url_input" "$SERVER")
copy_to_clipboard "$url"
fi
;;
"Shorten URL")
long_url=$(zenity --entry \
--title "URL Shortener" \
--text "Enter long URL:")
if [ $? -eq 0 ] && [ ! -z "$long_url" ]; then
url=$(curl -H "Authorization: $AUTH_TOKEN" -F "url=$long_url" "$SERVER")
copy_to_clipboard "$url"
fi
;;
"Upload from Remote URL")
remote_url=$(zenity --entry \
--title "Remote URL Upload" \
--text "Enter remote file URL:")
if [ $? -eq 0 ] && [ ! -z "$remote_url" ]; then
url=$(curl -H "Authorization: $AUTH_TOKEN" -F "remote=$remote_url" "$SERVER")
copy_to_clipboard "$url"
fi
;;
"Exit")
exit 0
;;
*)
exit 0
;;
esac
done