Skip to content

Instantly share code, notes, and snippets.

@luebking
Created January 20, 2023 14:53
Show Gist options
  • Save luebking/9f9941f878baaa8ca069a461dc328d08 to your computer and use it in GitHub Desktop.
Save luebking/9f9941f878baaa8ca069a461dc328d08 to your computer and use it in GitHub Desktop.
Get abbs!
abbs() {
if ! grep -q "ID=arch" /etc/os-release; then
grep -E 'NAME|ID' /etc/os-release
echo 'https://bbs.archlinux.org/misc.php?action=rules'
return 1
fi
case $1 in
"pastebin"|"0x0.st")
curl -F 'file=@-' 0x0.st
;;
"ix.io")
curl -F 'f:1=<-' ix.io
;;
# fonts)
# FC_DEBUG=4 pango-view --font="$1" -t "$2" | grep family:
# fc-list :charset=1f63f
# fc-list :mono
# fc-list :spacing=100
# ;;
imgur|pasteimg)
echo "Do NOT post images of text. Post the text!"
echo "Do NOT embed huge images! Just link anything > 250x250 px"
if type jq >/dev/null 2>&1; then
curl -X POST "https://api.imgur.com/3/upload" -F "image=@\"$2\"" | jq ".data.link" -r
elif type sed>/dev/null 2>&1; then
curl -X POST "https://api.imgur.com/3/upload" -F "image=@\"$2\"" | sed 's%.*,"link":"https://i.imgur.com/\([^\"]*\)",.*%https://i.imgur.com/\1%'
else
curl -X POST "https://api.imgur.com/3/upload" -F "image=@\"$2\""
fi
;;
integrity)
printf "Ideally this won't print anything for quite a while.\nGet yourself a cup of coffee...\n"
sudo LC_ALL=C pacman -Qkk | grep -v ', 0 altered files'
;;
locale)
localectl; echo " ---"
locale; echo " ---"
locale -a
;;
services)
find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f
;;
session)
echo $DBUS_SESSION_BUS_ADDRESS
loginctl session-status | head -n16
;;
should*)
mpv --ytdl-raw-options='format="mp4,best[height<=480]"' 'https://www.youtube.com/watch?v=5RyYrs5tu60' || echo 'Watch https://www.youtube.com/watch?v=5RyYrs5tu60'
;;
net)
case $2 in
speed)
servers=("newark" "singapore" "london" "frankfurt" "dallas" "toronto1" "syd1" "atlanta" "tokyo2" "mumbai1" "fremont")
locations=( "Newark, USA" "Singapore" "London, UK" "Frankfurt, Deutschland" "Dallas, USA"
"Toronto, Canada" "Sidney, Australia" "Atlanta, USA" "東京都 (Tokyo), 日本国 (Japan)"
"मुंबई (Bombay), Bhārat (India)" "Fremont, USA")
sizes=("100MB" "1GB")
echo
PS3=$'\n'"Enter location: "
select t in "${locations[@]}"; do
if [ "${SHELL##*/}" = "zsh" ]; then
server="${servers[$REPLY]}"
else # ass_u_me bash logic
server="${servers[(($REPLY-1))]}"
fi
[[ $REPLY -ge 1 && $REPLY -le ${#servers[@]} ]] && break
done
unset REPLY
echo
PS3=$'\n'"Select size: "
select size in "${sizes[@]}"; do
[[ $REPLY -ge 1 && $REPLY -le ${#sizes[@]} ]] && break
done
echo
[[ -n "${server}" && -n "${size}" ]] && wget -nv --show-progress -O /dev/null "http://speedtest.${server}.linode.com/${size}-${server}.bin"
;;
show)
case $3 in
dhcp)
type sudo; type nmap
sudo nmap --script broadcast-dhcp-discover
;;
resolv*)
resolvectl status; echo " ---"
ls -l /etc/resolv.conf; echo " ---"
cat /etc/resolv.conf
;;
*)
ip a; echo " ---"
ip r; echo " ---"
getent ahostsv4 archlinux.org; echo " ---"
getent ahostsv6 archlinux.org; echo " ---"
nslookup archlinux.org; echo " ---" # hopefully
;;
esac
;;
esac
;;
help)
echo "locale"
echo "integrity - scan for broken packages"
echo "net show - network status"
echo "net show resolv - DNS resovler config"
echo "net show dhcp - scan for dhcp servers (requires nmap)"
echo "net speed - run speedtest"
echo "pastebin|0x0.st|ix.io - feed into a pastebin service"
echo "pasteimg|imgur <file.jpg> - upload an image"
echo "services - list *all* enabled systemd services"
echo "should - yeah, \"should\""
;;
*)
echo "Ummm... what??"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment