# ------------------------------- # 1. ENVIRONMENT CONFIGURATION # ------------------------------- # Change Prompt # ------------------------------------------------------------ export internalip=`ifconfig | grep inet | grep netmask | grep -v 127 | cut -d" " -f2` export router=`ifconfig | grep inet | grep netmask | grep -v 127 | cut -d" " -f6` export publicip=`curl --url http://icanhazip.com` export PS1="________________________________________________________________________________\n\w @ \h (\u) $internalip <=> $publicip\n| => " # export PS1="|=> " # Add color to terminal # (this is all commented out as I use Mac Terminal Profiles) # from http://osxdaily.com/2012/02/21/add-color-to-the-terminal-in-mac-os-x/ # ------------------------------------------------------------ export CLICOLOR=1 export LSCOLORS=ExFxBxDxCxegedabagacad export PATH="$PATH:~/bin/" export PATH="$PATH:/Users/admin/.local/bin/:/Users/admin/Library/Python/3.9/bin/" export NVM_DIR="$HOME/.nvm" [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion alias c='clear' # c: Clear terminal display alias which='type -all' # which: Find executables alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths # --------------------------- # 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 lanRange='ifconfig | grep inet | grep netmask | grep -v 127 | cut -d" " -f6 | sed s/255/0\\/24/g | grep -v Exit' 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 alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Display only open UDP sockets alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Display only open TCP sockets 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 alias atompwd='atom `pwd`' alias nmapLANscan='nmap `lanRange`' # 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 } # --------------------------------------- # 8. WEB DEVELOPMENT # --------------------------------------- alias apacheEdit='sudo edit /etc/httpd/httpd.conf' # apacheEdit: Edit httpd.conf alias apacheRestart='sudo apachectl graceful' # apacheRestart: Restart Apache alias editHosts='sudo edit /etc/hosts' # editHosts: Edit /etc/hosts file alias herr='tail /var/log/httpd/error_log' # herr: Tails HTTP error logs alias apacheLogs="less +F /var/log/apache2/error_log" # Apachelogs: Shows apache error logs httpHeaders () { /usr/bin/curl -I -L $@ ; } # httpHeaders: Grabs headers from web page # httpDebug: Download a web page and show info on what took time # ------------------------------------------------------------------- httpDebug () { /usr/bin/curl $@ -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n" ; } alias bashprofile='c; cat ~/.bash_profile' # sudo chown -R $(whoami) /path/path/path # CLAI setup if ! [ ${#preexec_functions[@]} -eq 0 ]; then if ! [[ " ${preexec_functions[@]} " =~ " preexec_override_invoke " ]]; then source ~/.clairc fi else source ~/.clairc fi # End CLAI setup