Tuesday, October 7, 2014

macOS stuff

This post is a collection of little things related to macOS (Mac OS X was rebranded macOS).  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

.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 \; ; }

macOS versions and hardware compatibility

Versions of macOS are described here.

Hardware compatibility (i.e. latest version of macOS) 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 2010 Macbook Pro, the details are here (search for "Maximum MacOS" on this page).

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.
Disabling facetime notification sound

When receiving calls on a cell phone running iOS, the calls appear on macOS.  This causes an annoying sound, especially if one is already in the midst of a conference call via some other tool like zoom or skype.  To disable these sounds, do the following:

System Preferences -> Notifications -> FaceTime -> Play sound for notifications (uncheck)

Useful applications
Other useful stuff

No comments:

Post a Comment