feat: add support for multiple clipboard utilities and handle copy failure in token display

This commit is contained in:
2026-08-28 01:19:24 +07:00
parent fc1d392fba
commit f357ef8fd7
+18 -2
View File
@@ -75,12 +75,24 @@ copy_to_clipboard() {
if command -v pbcopy >/dev/null 2>&1; then
echo -n "$text" | pbcopy
return 0
elif command -v clip.exe >/dev/null 2>&1; then
printf "%s" "$text" | clip.exe
return 0
elif command -v clip >/dev/null 2>&1; then
printf "%s" "$text" | clip
return 0
elif command -v wl-copy >/dev/null 2>&1; then
echo -n "$text" | wl-copy
return 0
elif command -v xclip >/dev/null 2>&1; then
echo -n "$text" | xclip -selection clipboard
return 0
elif command -v xsel >/dev/null 2>&1; then
echo -n "$text" | xsel --clipboard --input
return 0
elif command -v powershell.exe >/dev/null 2>&1; then
printf "%s" "$text" | powershell.exe -NoProfile -Command "Set-Clipboard" >/dev/null 2>&1
return 0
fi
return 1
}
@@ -417,8 +429,12 @@ show_interactive_menu() {
elif [[ "$choice" -eq $(( ${#ROUTES[@]} + 1 )) ]]; then
print_all_urls "$token"
elif [[ "$choice" -eq $(( ${#ROUTES[@]} + 2 )) ]]; then
copy_to_clipboard "$token"
echo -e "${GREEN}✓ Access Token copied to clipboard:${NC} $token"
if copy_to_clipboard "$token"; then
echo -e "${GREEN}✓ Access Token copied to clipboard:${NC} $token"
else
echo -e "${YELLOW}Could not detect clipboard tool. Here is the token:${NC}"
echo "$token"
fi
elif [[ "$choice" -eq $(( ${#ROUTES[@]} + 3 )) ]]; then
echo ""
read_input -r -p "Enter environment [live, beta, staging, demo, local, or URL]: " new_env