Skip to content

Instantly share code, notes, and snippets.

@wbs75
Last active February 7, 2019 01:29
Show Gist options
  • Select an option

  • Save wbs75/6110027 to your computer and use it in GitHub Desktop.

Select an option

Save wbs75/6110027 to your computer and use it in GitHub Desktop.
aliases
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
# Shortcuts
alias d="cd ~/Documents/Dropbox"
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias p="cd ~/Projects"
alias cds="cd ~/Sites/httpd"
alias cdl="cd /usr/local"
alias cdb="cd /usr/local/bin "
alias g="git"
alias h="history"
alias j="jobs"
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # OS X `ls`
colorflag="-G"
fi
# List all files colorized in long format
alias l="ls -lF ${colorflag}"
# List all files colorized in long format, including dot files
alias la="ls -laF ${colorflag}"
# List only directories
alias lsd='ls -lF ${colorflag} | grep "^d"'
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
# Enable aliases to be sudo’ed
alias sudo='sudo '
# Imaging
alias sparse1="hdiutil create -type SPARSE -size 1g -fs HFS+ growableTo1g"
alias sparse10="hdiutil create -type SPARSE -size 10g -fs HFS+ growableTo10g"
alias sparse15="hdiutil create -type SPARSE -size 15g -fs HFS+ growableTo15g"
alias sparse25="hdiutil create -type SPARSE -size 25g -fs HFS+ growableTo25g"
alias sparse50="hdiutil create -type SPARSE -size 50g -fs HFS+ growableTo50g"
alias sparse100="hdiutil create -type SPARSE -size 100g -fs HFS+ growableTo100g"
alias sparse150="hdiutil create -type SPARSE -size 150g -fs HFS+ growableTo150g"
alias sparse300="hdiutil create -type SPARSE -size 300g -fs HFS+ growableTo300g"
alias sparse500="hdiutil create -type SPARSE -size 500g -fs HFS+ growableTo500g"
alias sparse1000="hdiutil create -type SPARSE -size 1000g -fs HFS+ growableTo1000g"
alias g="git"
alias h="history"
alias j="jobs"
alias s="subl ."
alias v="vim"
alias o="open"
alias oo="open ."
alias sbpkg="cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages"
alias tfinder="/Applications/TotalFinder.app/Contents/MacOS/TotalFinder "
alias bompkg="cd /private/var/db/receipts && lsbom -p MUGsf "
alias fs="stat -f \"%z bytes\""
alias pcmds="systemsetup -printCommands"
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
alias undopush="git push -f origin HEAD^:master"
# Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup'
# Clean up LaunchServices to remove duplicates in the “Open With” menu
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
alias c="tr -d '\n' | pbcopy"
alias asa="sudo rm -rf ~/Library/Saved\ Application\ State/*"
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
alias cleanup="find . -name '*.DS_Store' -type f -ls -delete"
alias flush="dscacheutil -flushcache"
alias cleanasl="echo 'Cleaning ASL files...\c';sudo -S find -d /var/log/asl -name "AUX*" -exec rm -fr {} \;;sudo -S find -d /var/log/asl -name "*\.asl" -exec rm -fr {} \;;sudo -S find /var/log/DiagnosticMessages/ -name "*\.asl";sudo -S ls -@ailO /var/log/asl /var/log/DiagnosticMessages;echo;echo done."
alias cleanaudit="sudo -S ls /var/audit;echo;echo 'Cleaning audit data...\c';echo;sudo -S find /var/audit -name *\.2* -type f -exec rm -f {} \;;sudo -S ls /var/audit;echo;echo done."
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
alias rootpref="sudo -s ls -@ailOR /private/var/root/Library/Preferences"
alias skext="sudo kextcache -system-prelinked-kernel && sudo kextcache -system-caches"
alias repair="diskutil repairPermissions /"
alias kconf="sudo killall configd"
alias rb="sudo shutdown -r +1"
alias spotoff="sudo mdutil -a -i off"
alias spoton="sudo mdutil -a -i on"
# Show/hide hidden files in Finder
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
# 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"
# enable or disable Bonjour
alias dbon="sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist"
alias ebon="sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist"
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en1"
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'"
alias whois="whois -h whois-servers.net"
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
alias server="open http://localhost:8080/ && python -m SimpleHTTPServer 8080"
# One of @janmoesen’s ProTip™s
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do alias "$method"="lwp-request -m '$method'"; done
# Cannot delete cause of http://xkcd.com/530/
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume 10'"
alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'"
# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
alias plistbuddy="/usr/libexec/PlistBuddy"
# Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
# (useful when executing time-consuming commands)
alias badge="tput bel"
# One of @janmoesen’s ProTip™s
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
alias "$method"="lwp-request -m '$method'"
done
# Vagrant
alias vdestroy="vagrant destroy -f"
alias vhalt="vagrant halt --f"
alias vreload="vagrant reload --no-provision"
alias vssh="vagrant ssh"
alias vup="vagrant up --provider=vmware_fusion"
# pkgutil
alias dpkg="sudo hdiutil create -srcfolder "
alias bompkg="cd /private/var/db/receipts && lsbom -p MUGsf "
# Brew Cask
alias binstall="brew cask install "
alias bsearch="brew cask search"
# munki
alias munki_update="sudo /usr/local/munki/managedsoftwareupdate"
alias munki_config="/usr/local/munki/munkiimport --configure"
alias munki_defaults="defaults read /Library/Preferences/ManagedInstalls"
alias munki_SoftRepoURL="sudo defaults write /Library/Preferences/ManagedInstalls SoftwareRepoURL"
alias munki_ClientIdentifier="sudo defaults write /Library/Preferences/ManagedInstalls ClientIdentifier"
alias munki_load="sudo launchctl load /Library/LaunchDaemons/com.googlecode.munki.munkiwebadmin.plist"
alias munki_unload="sudo launchctl unload /Library/LaunchDaemons/com.googlecode.munki.munkiwebadmin.plist"
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume 7'"
alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'"
# Open a manpage in Preview, which can be saved to PDF
function pman {
man -t "${1}" | open -f -a /Applications/Preview.app
}
if [[ "$OSTYPE" == "darwin"* ]]; then
alias man="pman"
fi
alias kd="cd /opt/kDeploy/tools"
alias ks="cd /opt/kServer"
alias varnishon='iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 6081;iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 6081 -j REDIRECT --to-ports 80'
alias varnishoff='iptables -t nat -D PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 6081;iptables -t nat -D PREROUTING -i eth0 -p tcp -m tcp --dport 6081 -j REDIRECT --to-ports 80'
alias varnishstatus='iptables -L -t nat |grep -q 6081; if [ "test$?" = "test0" ]; then echo "Varnish On"; else echo "Varnish Off"; fi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment