Last active
August 29, 2015 14:08
-
-
Save liverbool/f7dc60b6df8e467d9193 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------------------------- | |
# | |
# Description: This file holds all my BASH configurations and aliases | |
# | |
# Sections: | |
# 1. Environment Configuration | |
# 2. Make Terminal Better (remapping defaults and adding functionality) | |
# 3. File and Folder Management | |
# 4. Searching | |
# 5. Process Management | |
# 6. Networking | |
# | |
# --------------------------------------------------------------------------- | |
# ------------------------------- | |
# 1. ENVIRONMENT CONFIGURATION | |
# ------------------------------- | |
# Change Prompt | |
# ------------------------------------------------------------ | |
export PS1="\w \u$" | |
# Set Paths | |
# ------------------------------------------------------------ | |
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin | |
#Set Default Editor (change 'Vim' to the editor of your choice) | |
# ------------------------------------------------------------ | |
export EDITOR=/usr/bin/vim | |
# Add color to terminal | |
# from http://osxdaily.com/2012/02/21/add-color-to-the-terminal-in-mac-os-x/ | |
# ------------------------------------------------------------ | |
export CLICOLOR=1 | |
export LSCOLORS=GxFxCxDxBxegedabagaced | |
# ----------------------------- | |
# 2. MAKE TERMINAL BETTER | |
# ----------------------------- | |
alias vi='vim' | |
alias cp='cp -iv' # Preferred 'cp' implementation | |
alias mv='mv -iv' # Preferred 'mv' implementation | |
alias edit='subl' # edit: Opens any file in sublime editor | |
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder | |
alias c='clear' # c: Clear terminal display | |
alias myip='curl ip.appspot.com' # myip return my extern IP | |
alias l.='ls -d .* --color=auto' # l. ls all hidden files | |
alias please="sudo" #please jukes on you! | |
# --------------------------- | |
# 4. SEARCHING | |
# --------------------------- | |
# qfind: Quickly search for file | |
alias qfind="find . -name " | |
# ff: Find file under the current directory | |
ff () { /usr/bin/find . -name "$@" ; } | |
# ffs: Find file whose name starts with a given string | |
ffs () { /usr/bin/find . -name "$@"'*' ; } | |
# ffe: Find file whose name ends with a given string | |
ffe () { /usr/bin/find . -name '*'"$@" ; } | |
# --------------------------- | |
# 5. PROCESS MANAGEMENT | |
# --------------------------- | |
# findPid: find out the pid of a specified process | |
# ----------------------------------------------------- | |
# Note that the command name can be specified via a regex | |
# E.g. findPid '/d$/' finds pids of all processes with names ending in 'd' | |
# Without the 'sudo' it will only find processes of the current user | |
# ----------------------------------------------------- | |
findPid () { lsof -t -c "$@" ; } | |
# memHogsTop, memHogsPs: Find memory hogs | |
# ----------------------------------------------------- | |
alias memHogsTop='top -l 1 -o rsize | head -20' | |
alias memHogsPs='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10' | |
# cpuHogs: Find CPU hogs | |
# ----------------------------------------------------- | |
alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10' | |
# topForever: Continual 'top' listing (every 10 seconds) | |
# ----------------------------------------------------- | |
alias topForever='top -l 9999999 -s 10 -o cpu' | |
# ttop: Recommended 'top' invocation to minimize resources | |
# ------------------------------------------------------------ | |
# Taken from this macosxhints article | |
# http://www.macosxhints.com/article.php?story=20060816123853639 | |
# ------------------------------------------------------------ | |
alias ttop="top -R -F -s 10 -o rsize" | |
# my_ps: List processes owned by my user: | |
# ------------------------------------------------------------ | |
my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,start,time,bsdtime,command ; } | |
# --------------------------- | |
# 6. NETWORKING | |
# --------------------------- | |
alias myip='curl ip.appspot.com' # myip: Public facing IP Address | |
alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets | |
alias flushDNS='dscacheutil -flushcache' # flushDNS: Flush out the DNS Cache | |
alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Display open sockets | |
# lsockU: Display only open UDP sockets | |
alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' | |
# lsockT: Display only open TCP sockets | |
alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' | |
alias ipInfo0='ipconfig getpacket en0' # ipInfo0: Get info on connections for en0 | |
alias ipInfo1='ipconfig getpacket en1' # ipInfo1: Get info on connections for en1 | |
alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections | |
alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs | |
# ii: display useful host related informaton | |
# ------------------------------------------------------------------- | |
ii() { | |
echo -e "\nYou are logged on ${RED}$HOST" | |
echo -e "\nAdditionnal information:$NC " ; uname -a | |
echo -e "\n${RED}Users logged on:$NC " ; w -h | |
echo -e "\n${RED}Current date :$NC " ; date | |
echo -e "\n${RED}Machine stats :$NC " ; uptime | |
echo -e "\n${RED}Current network location :$NC " ; scselect | |
echo -e "\n${RED}Public facing IP Address :$NC " ;myip | |
#echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns | |
echo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment