Tuesday, October 7, 2014

Mac OS X stuff

This post is a collection of little things related to Mac OS X.  I will be updating it with some of my learnings and the various changes that I made to customize the shell for my use.


.bash_rc vs .bash_profile

bash has two places where one can put startup commands -- .bashrc and .bash_profile.  .bash_profile is executed only for login shells.  .bashrc is executed for non-login shells.  If one has commands that only need to be executed for both, then one can create a .bash_profile and source .bashrc from there by adding the following line to the .bash_profile:

. ~/.bashrc || echo "problem sourcing ~/.bashrc"

On Mac OS all shells are login shells.  So I just use .bash_profile.

aliases and functions

Aliases are discouraged in bash, but I use them anyway.  An example of an alias I use is:

alias ls='ls -lF'

If I wanted to use a function, I would have used:

ls(){ command ls -lF "$@" ; }

One key difference between bash and csh is that in bash, aliases cannot accept arguments.  So for any such aliases in csh, one would have to define functions in bash.  For example, here's a function pg:

pg(){ open /Applications/iWork\ \'09/Pages.app/ "$@" ; }

At the command line I can simply say "pg file" and the pages application is started up with the file specified.

Case insensitive auto-completion

Create a file ~/.inputrc and add the following line in it:

set completion-ignore-case on

This will prevent /etc/inputrc from being used.  On macOS, there is no /etc/inputrc by default, but if there was you get around it by adding the following line as the first line in the ~/.inputrc file:

$include /etc/inputrc

findword utility

This is a useful utility which scans files for a given word within all files in all subdirectories from where the command is executed.

findword(){ find . -type f -exec egrep -i "$@" {} /dev/null \; ; }

Mac OS X versions and hardware compatibility

Versions of Mac OS X are described here.

Hardware compatibility (i.e. latest version of Mac OS X) that is supported on any device can be found at EveryMac.com.  Just find a given machine and at the bottom of the page are the details regarding OS compatibility.  For example, for my machine, the details are here (search for "Maximum MacOS" on this page).

SMC Reset for systems with non-removable battery
  1. Shut down your Mac.
  2. Unplug power adapter from your computer.
  3. Press Shift-Control-Option on the left side of the keyboard, then press the power button at the same time. Hold these keys and the power button for 10 seconds.
  4. Release all keys.
Recovery mode

Press power and then immediately Cmd-R.   Wait for Apple logo.  Run tools like First Aid on the startup disk and/or main disk or recover the OS.


Fortunately Mac OS is pretty secure by design.  Macrumors has a wiki page that discusses this, and also offers some tips on how to practice safe computing.

Battery health
  • Applications -> Utilities -> System Information.
  • On the left, under "Hardware," select "Power."
  • There it will show the charge capacity, number of cycles, and condition.
  • If you need the design capacity, you have to use an app such as coconutBattery.
Useful applications
Other useful stuff

No comments:

Post a Comment