I'm curious to hear if anybody has any cool aliases or etc.
.bashrc
Code: Select all
# ALIASES
####################
alias ps='ps auxf'
alias pg='ps aux | grep'
# LIST DIRECTORIES
alias lsd='ls -l | grep --color=never "^d" | awk '\''{
split($0,a," ");
for(i=8; i<=length(a); ++i)
{
printf "%s",a[i];
if(i<length(a)) printf " ";
}
printf "\n"
}'\'' | column'
# LIST ALL DIRECTORIES
alias lsda='ls -lA | grep --color=never "^d" | awk '\''{
split($0,a," ");
for(i=8; i<=length(a); ++i)
{
printf "%s",a[i];
if(i<length(a)) printf " ";
}
printf "\n"
}'\'' | column'
# LIST FILES
alias lsf='ls -l | grep --color=never -v "^d" | awk '\''{
split($0,a," ");
for(i=8; i<=length(a); ++i)
{
printf "%s",a[i];
if(i<length(a)) printf " ";
}
printf "\n"
}'\'' | column'
# LIST ALL FILES
alias lsfa='ls -lA | grep --color=never -v "^d" | awk '\''{
split($0,a," ");
for(i=8; i<=length(a); ++i)
{
printf "%s",a[i];
if(i<length(a)) printf " ";
}
printf "\n"
}'\'' | column'
alias path='echo -e ${PATH//:/\\n}'
alias home='cd ~'
alias desktop='cd ~/Desktop'
alias mydocs='cd ~/Documents'
alias docs='cd ~/Documents'
alias music='cd ~/Music'
alias videos='cd ~/Videos'
alias downloads='cd ~/Downloads'
alias mplayer='mplayer -quiet -framedrop $*'
# COLOR DEFINES
####################
red='\e[0;31m'
RED='\e[1;31m'
green='\e[0;32m'
GREEN='\e[1;32m'
yellow='\e[0;33m'
YELLOW='\e[1;33m'
blue='\e[0;34m'
BLUE='\e[1;34m'
purple='\e[0;35m'
PURPLE='\e[1;35m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
white='\e[0;37m'
WHITE='\e[1;37m'
black='\e[0;30m'
BLACK='\e[1;30m'
NC='\e[0m' # No Color
# PR = Primary Color
# SC = Secondary Color
# Mmmm, Minty
PR=$YELLOW
SC=$GREEN
# FUNCTIONS
####################
function _greet()
{
hour=`date +'%H'`
if [ $hour -lt 12 ]; then
echo "Good morning"
elif [ $hour -lt 18 ]; then
echo "Good day"
else
echo "Good evening"
fi
}
# WELCOME SCREEN
####################
username=`whoami`
echo -e ${SC}`_greet` ${PR}`~/bin/titlecase $username`${SC}, welcome to ${PR}`hostname`
echo -e ${SC}`cat /etc/issue.net` `uname -omp`
echo -e ${PR}`hostname`\'s ${SC}IP address is ${PR}`hostname -I`
echo -e ${PR}Router\'s${SC} IP address is ${PR}`~/bin/ipaddress`
echo -e ${SC}Uptime for ${PR}`hostname`${SC} is ${PR}`uptime | awk /'up/ {print $3}'`
echo
Code: Select all
#!/usr/bin/python
from sys import argv
if len(argv) == 1 or argv[1].lower() in ["--help", "--h", "-h", "-help"]:
from os.path import basename
print "Prints the passed arguements converted to title case."
print "Usage: %s <string> ..."%(basename(argv[0]))
exit()
for arg in argv[1:]:
print arg.title(),
Code: Select all
#!/usr/bin/python
"""
About: A simple script to fetch an IP address from a remote host
Version: 1.1
HISTORY
--------------------------------------------------------------------
Version 1.1 - 06/25/2012
* Fixed hanging on non-responsive hosts.
* Removed several non-responsive hosts from host list.
* Added option to verify hosts are still working.
Version 1.0 - 05/06/2012
"""
from urllib2 import urlopen
from re import findall
from os.path import isfile, dirname, join, basename
from time import time
from sys import exit, argv
########################################################################
# Config section
# These hosts provide a simple plain text or minimal HTML
# page with your IP address
hosts = [
"http://www.formyip.com/",
"http://checkip.dyndns.org/",
"http://www.cmyip.com/",
"http://www.viewmyipaddress.com/",
"http://cfaj.freeshell.org/ipaddr.cgi",
"https://secure.informaction.com/ipecho/",
"http://icanhazip.com/",
"http://ipecho.net/plain",
"http://smart-ip.net/myip",
]
cache_update = 3600
cache_name = "ipaddr_cache"
# End Config
########################################################################
cache_name = join(dirname(argv[0]), cache_name)
cache_stale = False
cache_exists = False
help = False
verify=False
# Fetch IP from remote host
def fetchIP(host,data=None,timeout=10):
try:
r = urlopen(host,data,timeout)
h = r.read()
r.close()
return findall("(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})", h)[-1]
except:
return None
# Parse Options
for option in argv[1:]:
opt = option.lower()
if opt == "--stale":
cache_stale = True
elif opt[:7] == "--host=":
host = option[7:]
cache_stale = True
elif opt == "--help":
help = True
elif opt == "--verify":
verify = True
cache_stale = True
# Print help and exit
if help:
print "Usage: %s [options]"%(basename(argv[0]))
print "Options:"
print " --host=<hostURL>\tFetch IP address from hostURL."
print " --stale\t\tDon't use cached IP address."
print " --verify\t\tVerify all hosts are still working."
print " --help\t\tThis message"
exit()
# Check if a cache file exists
if not isfile(cache_name):
cache_exists = False
else:
cache_exists = True
# If the cache exists use it unless it's stale
if cache_exists and not cache_stale:
d = open(cache_name,"r").readlines()
if int(d[0]) > time() - cache_update:
print d[1]
else:
cache_stale = True
h = False
# Cache is stale or doesn't exist, lets get the IP
if not cache_exists or cache_stale:
while True:
if not hosts:
print "Exhausted all IP Address Servers"
break
if not h and verify:
print "IP ADDRESS\tTIME\tHOST"
h = True
host = hosts.pop(int(time())%len(hosts))
c = time()
ip = fetchIP(host)
c = time() - c
if ip:
open(cache_name, "w").write("%d\n%s"%(time(),ip))
if not verify:
print ip
break
else:
print "%s\t%0.2f\t%s"%(ip,c,host)
else:
if verify:
print "Failed\t\t%0.2f\t%s"%(c,host)
continue