initial commit

This commit is contained in:
ksyasuda 2024-04-05 00:18:27 -07:00
commit 8022250599
No known key found for this signature in database

44
dexscreener-opener.sh Executable file
View File

@ -0,0 +1,44 @@
#!/bin/bash
set -Eeuo pipefail
BROWSER=firefox
PASTE_CMD=wl-paste
lg() {
printf "\033[1;32m%s\033[0m\n" "$*"
}
debug() {
printf "\033[1;34m%s\033[0m\n" "$*" >&2
}
notify() {
dunstify -u normal -t 3000 "$*"
}
get_token_name() {
jq -r '.pairs[0].baseToken.name' <<< "$(curl --no-progress-meter "https://api.dexscreener.com/latest/dex/tokens/$1")"
}
get_ticker() {
jq -r '.pairs[0].baseToken.symbol' <<< "$(curl --no-progress-meter "https://api.dexscreener.com/latest/dex/tokens/$1")"
}
CONTRACT_ADDRESS="$($PASTE_CMD)"
if [ -z "$CONTRACT_ADDRESS" ]; then
notify "No contract address in clipboard"
exit 1
fi
TOKEN_NAME="$(get_token_name "$CONTRACT_ADDRESS")"
TICKER="$(get_ticker "$CONTRACT_ADDRESS")"
lg "Opening dexscreener page for $TOKEN_NAME (\$$TICKER)"
notify "Opening dexscreener page for $TOKEN_NAME (\$$TICKER)"
if ! $BROWSER "https://dexscreener.com/solana/$CONTRACT_ADDRESS"; then
notify "Failed to open browser tab/window"
exit 1
fi