Skip to content

Instantly share code, notes, and snippets.

@sumimakito
Last active September 20, 2017 07:03
Show Gist options
  • Save sumimakito/3c458f9fdc40889c3edc17da884508be to your computer and use it in GitHub Desktop.
Save sumimakito/3c458f9fdc40889c3edc17da884508be to your computer and use it in GitHub Desktop.
A bloody simple script for lazy cats.
#!/bin/bash
#
# Written by Makito <master@keep.moe>
#
# A bloody simple script for lazy cats.
# I'm too lazy to give it a name more than two words.
# Just regard it as the abbreviation of ping, please.
#
# You : Can I ping a URL?
# Ping: NO WAY! Cannot resolve *****: Unknown host!!
# Pn : It's my turn.
#
# First things first:
#
# Append the line below into your ~/.bash_profile or ~/.zshrc or similiar files:
#
# function pn(){;ping `echo $@ | perl -pe 's/(?:\w+:\/\/)([^:\/\n]+)(\S*)/\1/ig'`;}
#
# Alternatively, you can use ln -s to create a symbolic link or just move
# the script into the bin directory so that you can run the script as a
# convenient command whenever you feel lazy. :-\
#
# How to use?
#
# Since the script only works as a wrapper, any native options
# for the ping command will be passed to the real ping.
# And also, you can ping a URL directly, without any pain.
#
# pn [native_options] hostname|URL
#
# pn -c 5 https://gist.github.com/ => ping -c 5 gist.github.com
#
# Have fun.
#
function pn(){
ping `echo $@ | perl -pe 's/(?:\w+:\/\/)([^:\/\n]+)(\S*)/\1/ig'`
}
pn $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment