Skip to content

Instantly share code, notes, and snippets.

@ChristopherA
Last active August 29, 2015 14:06
Show Gist options
  • Save ChristopherA/7bfbe274ffc788777ba4 to your computer and use it in GitHub Desktop.
Save ChristopherA/7bfbe274ffc788777ba4 to your computer and use it in GitHub Desktop.
Bash Shell Trivialities — Short Useful Commands for the OSX Shell

Bash Shell Trivalities: Short Useful Commands & Recipes for the OSX Shell

I find returning to terminal after a break from programming that the simple things sometimes are lost. This document's goal is to capture these, even if otherwise trivial.

Count visible files in folder

$ /bin/ls . | wc -l

Count all files, visible and hidden in folder

$ /bin/ls . -a | wc -l

Git specific

Delete files from repository and all old revisions

You can delete large or troublesome files or blobs and remove them from repositories using git-filter-branch, howevever, BFG Repo-Cleaner is faster http://rtyley.github.io/bfg-repo-cleaner/

brew cask install java
brew install bfg
cd ~/project
git pull
rm troubesomefile.txt
git push origin master
bfg --deletefiles troublesomefile.txt
git push origin master

Mac Specific

Network

Get local network IP address for ethernet

$ ipconfig getifaddr en0

Get local network IP address for wireless

$ ipconfig getifaddr en0

Get external IP address

$ curl http://ipecho.net/plain; echo

Maintenance & Repair

Rebuilt Spotlight index for a specific volume

$ sudo mdutil -E /Volumes/DriveName

Remove duplicate "Open with…" entries

$ /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

Covert Mac .CDR to .ISO

as per http://osxdaily.com/2012/07/18/convert-dmg-to-cdr-or-iso-with-disk-utility/

hdiutil convert /path/imagefile.cdr -format UDTO -o /path/convertedimage.iso

Convert a plist to XML

plutil -convert xml1 /path/to/file.plist

and back

plutil -convert binary1 /path/to/file.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment