🤬
  • ■ ■ ■ ■ ■ ■
    clink.sh
     1 +#!/bin/bash
     2 +# crash.link CLI
     3 +# Author: Justin Kromlinger
     4 +# Porting: from kutt by crash.link
     5 +# License: MIT
     6 + 
     7 +# FOR A QUICK SETUP PASTE THIS ON YOUR TERMINAL 👇 ##########################
     8 +# #
     9 +# 👉 /bin/bash -c "$(curl -fsSL https://crash.link/clink.sh)" 👈️ #
     10 +# #
     11 +# FOR A QUICK SETUP PASTE THIS ON YOUR TERMINAL 👆️ ######################
     12 + 
     13 +if ! command -v jq &> /dev/null
     14 +then
     15 + echo -e "\n please install jq package, learn more on \033[1m👉 crash.link/jq\033[0m \n"
     16 + exit
     17 +fi
     18 +touch ~/.bashrc
     19 +grep -q clink ~/.bashrc && echo -e "\n clink function already installed on \033[3m~/.bashrc\033[0m, you can run \033[1mclink\033[0m command or edit the API key there [if needed] \n" && exit
     20 +read -rep $'\n Please enter your crash.link API KEY 🔑 : ' API_KEY
     21 +read -rep "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
     22 +echo "CLINK_API_KEY=\"$API_KEY\" # 👈 [if&when-needed] edit your generated API KEY here" >> ~/.bashrc
     23 + 
     24 +# Add source bash_aliases on .bashrc
     25 + cat >> ~/.bashrc << EOT
     26 +CLINK_HOST="https://crash.link"
     27 +clink() {
     28 + if [[ "\$1" == "delete" ]] && [[ -n "\$2" ]]; then
     29 + curl -s -H "X-API-KEY: \$CLINK_API_KEY" \
     30 + -X DELETE \
     31 + "\$CLINK_HOST/api/v2/links/\$2" | jq
     32 + elif [[ -z "\$1" ]]; then
     33 + curl -s -H "X-API-KEY: \$CLINK_API_KEY" \
     34 + "\$CLINK_HOST/api/v2/links" | jq
     35 + elif [[ "\$1" != "help" ]] && [[ "\$1" != "--help" ]]; then
     36 + curl -s -H "X-API-KEY: \$CLINK_API_KEY" \
     37 + -H "Content-Type: application/json" \
     38 + --data "{
     39 + \"target\": \"\$1\",
     40 + \"password\": \"\$2\",
     41 + \"expire_in\": \"\$3\",
     42 + \"description\": \"\$4\"
     43 + }" \
     44 + "\$CLINK_HOST/api/v2/links" | jq
     45 + else
     46 + echo "\033[1mclink\033[0m"
     47 + echo "\033[1mclink help\033[0m"
     48 + echo "\033[1mclinkk <target-url> [<password> <expire_in> <description>]\033[0m"
     49 + echo "\033[1mclink delete <uuid>\033[0m"
     50 + return 2
     51 + fi
     52 +}
     53 +EOT
     54 + 
     55 +# Reload current environment
     56 +source ~/.bashrc
     57 +echo -e "\n ✅ clink function added to \033[3m~/.bashrc\033[0m, you ca now run \033[1mclink\033[0m command \n"
     58 +# Reinvoking shell to short circuits
     59 +bash
     60 +exit 0
Please wait...
Page is in error, reload to recover