8-3iag
Last Updated: February 25, 2016
·
2.858K
· wookiecooking
53910f203b1e11fe77898916ffdb78d6

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'

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

# 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"
Say Thanks
Respond

8 Responses
Add your response

11880
3eae340e049abecfb4a117ad7a907bd1

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

over 1 year ago ·
11885
Icflorescu

Nice!

over 1 year ago ·
11897
31b4ac2fe2b2922f6c913156babb2a74

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

over 1 year ago ·
11899
4d574942e2627e5a01262657dda8a299

alias cleardns="sudo killall -HUP mDNSResponder"

over 1 year ago ·
11967
D42a7264714dee5006b9c99d2567a320

@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 ·
11968
53910f203b1e11fe77898916ffdb78d6

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

over 1 year ago ·
11969
D42a7264714dee5006b9c99d2567a320

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

over 1 year ago ·
12450
Macicon 48x48 256c

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 ·