Last Updated: February 25, 2016
· wookiecooking

OSX Influenced bash aliases

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'


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"


# Updated, thanks to dpashkevich
alias please='sudo $(history -p !!)' 
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"

8 Responses
Add your response


alias please="sudo !!" awesome! ^^

over 1 year ago ·


over 1 year ago ·

Verbose copy with progress bar:
alias cp='rsync -r -v --progress'

over 1 year ago ·

alias cleardns="sudo killall -HUP mDNSResponder"

over 1 year ago ·

@oparty you can't alias sudo !!, as !! is expanded by bash when you type it. This worked for me instead:

alias please='sudo $(history -p !!)'

Source: How can I alias sudo !!? | Unix & Linux Stack Exchange

over 1 year ago ·

@dpashkevich Great catch, I've updated the post to reflect.

over 1 year ago ·

You may want to format the command lines in your post for better readability (indent them with four spaces)

over 1 year ago ·

Nice to see others using 'sudo $(history -p !!)'. I've been using it for a while but with a slightly different alias name. :)

alias sandwich='sudo $(history -p !!)'

Reference: http://xkcd.com/149/

over 1 year ago ·