Skip to content

Instantly share code, notes, and snippets.

@Donavan
Forked from wookiecooking/aliases.sh
Created December 2, 2013 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Donavan/7756993 to your computer and use it in GitHub Desktop.
Save Donavan/7756993 to your computer and use it in GitHub Desktop.
# Rails Stuff
alias stoprails='kill -9 $(lsof -i :3000 -t)'
alias startrails='rails server -d'
alias restartrails='stopRails && startRails'
#Check PHP For Erroes
alias phpcheck='find ./ -name \*.php | xargs -n 1 php -l'
# ROT13-encode text. Works for decoding, too! ;)
alias rot13='tr a-zA-Z n-za-mN-ZA-M'
#chmod train
alias mx='chmod a+x'
alias 000='chmod 000'
alias 400='chmod 400'
alias 644='chmod 644'
alias 755='chmod 755'
# Show Mounted info
alias mountedinfo='df -h'
# programs
alias s='open -a "Sublime Text 2"'
alias chrome='open -a "Google Chrome"'
alias makepass='openssl rand -base64 32'
alias mvim='open -a MacVim'
alias vbox="VBoxManage"
# Random
alias please="sudo !!"
alias hosts='sudo $EDITOR /etc/hosts'
alias sshconfig='$EDITOR ~/.ssh/config'
alias currentwifi="networksetup -getairportnetwork en0"
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume 10'"
alias week='date +%V'
# List only directories
alias lsd='ls -l | grep "^d"'
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'"
# Enhanced WHOIS lookups
alias whois="whois -h whois-servers.net"
# Flush Directory Service cache
alias flush="dscacheutil -flushcache"
# Canonical hex dump; some systems have this symlinked
type -t hd > /dev/null || alias hd="hexdump -C"
# Trim new lines and copy to clipboard
alias trimcopy="tr -d '\n' | pbcopy"
# Recursively delete `.DS_Store` files
alias cleanup="find . -name '*.DS_Store' -type f -ls -delete"
# File size
alias fs="stat -f \"%z bytes\""
# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
alias plistbuddy="/usr/libexec/PlistBuddy"
# cd into whatever is the forefront Finder window.
cdf() { # short for cdfinder
cd "`osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)'`"
}
function batterylife() {
printf ' Battery Life: ' && ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{ printf("%.2f%%", $10/$5 * 100) }' && echo ""
}
function watchhttp() {
sudo tcpdump -i en0 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
}
# Tar up folder
function tarup() {
tar -zcvf $1
}
# Search Replace
function sr() {
sed -i "" s/$1/$2/g $3
}
# Checks port number to see what service is attached
function port2service() {
lsof -i -P | grep $1
}
function mk() {
mkdir -p "$@" && cd "$@"
}
# take this repo and copy it to somewhere else minus the .git stuff.
function gitexport(){
mkdir -p "$1"
git archive master | tar -x -C "$1"
}
# All the dig info
function digga() {
dig +nocmd "$1" any +multiline +noall +answer
}
function syslog() {
tail -f /var/log/system.log
}
# Extract archives - use: extract <file>
# Credits to http://dotfiles.org/~pseup/.bashrc
function extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment