Setting up Mac OS X

Installing Xcode Command Line Tools

Open the Terminal app and install Xcode Command Line Tools by entering:

xcode-select --install

Installing X-Window system

X11 is a software system and network protocol that provides a basis for graphical user interfaces (GUIs) and rich input device capability for Linux/Unix applications. Normally, it will run in the background and, with the exception of an icon on your dock, will be unnoticeable.

  1. Since OS X 10.8, X11.app is not shipped with the OS, and need to be installed from XQuartz or using Homebrew (brew install --cask xquartz; see below). NOTE: You should NOT set the DISPLAY variable in any system configuration files or the X11 forwarding will be disabled.
  2. The default behavior for X11 applications is to open a XTerm terminal at start-up. With the superior features of the Terminal applications, you will be unlikely to have need of this XTerm terminal. To disable it, open a Terminal window and enter the following:
    defaults write org.x.X11 app_to_run /usr/bin/true
  3. In the Settings menu, under the Input tab, make sure “Enable key equivalents under X11” is unchecked. This is going to make any meta-key functions in Emacs work properly. However, the drawback is that none of the Apple functions (such as Apple-S for save, or Apple-Q to close) will work in your X-window programs. It is a trade-off — either Emacs works “normally” or the Apple functions work “normally” in X-windows. My preference is to have Emacs working since this is a commonly used program, while the apple functions are really just keyboard shortcuts that can all be done a different way.

Package management systems

There exist a few package management systems that port free/open source Unix/Linux software to Mac OS X, including Homebrew, MacPorts, Fink, rudix, stow. Homebrew, MacPorts, Fink are the more popular choices. Use Homebrew if you haven’t yet settled on one. Fink builds on Debian’s packaging tools and apt-get, and has pre-compiled executables. MacPorts is strongly influenced by BSD’s ‘ports’ system and builds everything from source code. Homebrew makes maximum use of what comes with OS X and does not need root/sudo to install packages. In addition, Homebrew Cask extends support to other OS X applications (such as Chrome) and let you skip the step-by-step installation process. MacPorts and Homebrew are more up to date than Fink, but Fink tends to have more scientific applications.

List of useful packages

Install CMake, Git, ImageMagick, a text editor, Jmol, gnuplot, grace, and others as needed. Some of the packages (git, numpy/scipy/matplotlib) below come with the Command Line Tools of Xcode, but they are usually not the latest versions.

  • AltTab (brew install --cask alt-tab) enables the Windows style ALT + TAB shortcut to see all open windows, instead of active applications like with CMD + TAB in MacOS.
  • BetterDisplay gives more flexibility in display options and can apply supersampling (i.e., turning on HiDPI scaling) to smooth font geometry on non-Retina external monitors (with less than ~220 PPI).
    • This can be combined with turning off font smoothing by defaults -currentHost write -g AppleFontSmoothing -int 0. Font smoothing slightly increases the font weight on bright Retina displays to make them look richer and more solid, but can make fonts look smudgy and blurry on non-Retina displays. Font smoothing is a global setting and turning it off can make fonts on the laptop screen look too thin and spindly. You can reset the default font smoothing level by defaults -currentHost delete -g AppleFontSmoothing. Log out and back in for the effect to take place.
  • CMake - a cross-platform build system; easier to use than Autotools or writing Makefiles, and will be used as the default build system for the group code
  • eqMac allows volume control of an external monitor connected by HDMI or DisplayPort. It creates a virtual audio device to apply software-level volume reduction before the audio ever leaves the Mac.
  • Graph plotting program: gnuplot or (xm)grace
  • GIMP - an open-source program similar to Adobe Photoshop
  • Git - a distributed version control system used to manage code development in our group; you must learn to use it, see Git Guidelines.
  • Hunspell - a spell-checker program.
  • ImageMagick - a software suite to create, edit, compose, or convert bitmap images
  • Inkscape - an open-source SVG vector graphics editor
  • iTerm2 is an alternative terminal emulator with more feature rich options than the stock terminal in MacOS.
  • Karabiner-Elements (brew install --cask karabiner-elements) is a keyboard customizer to manage shortcuts.
  • LinearMouse (brew install --cask linearmouse) or Mos (brew install --cask mos) allows for natural scrolling (page going down when scrolling up) when using the touchpad and reverse scrolling when using a mouse. They also makes cheaper mice scroll much more smoothly.
  • Octave - a Matlab-like environment for numerical computation and graphics
  • Python extensions: NumPy/SciPy/matplotlib/pandas. These extensions define numerical array and matrix type and associated basic operations and support advanced math, signal processing, optimization, statistics, plotting and much more
  • R - a statistical computing and graphics environment
  • Rectangle (brew install --cask rectangle) enables the Windows style snapping behavior and shortcuts like Control + Command + Up.
  • TeX typesetting program, including LaTeX: MacTeX or TeX Live
  • Text editors for code, markup and prose.
    • Emacs - a customizable text editor. The community-maintained Mac port is highly recommended over the standard X11 or Cocoa builds, as it handles native windowing and keyboard shortcuts much better. You can install it using these commands:

      :

brew tap railwaycat/emacsmacport brew install emacs-mac —with-modules

  • Tiles is a window manager that allows for window snapping by dragging windows to the edge or through keyboard shortcuts. Newer versions of MacOS now have similar functionality, without the keyboard shortcuts.
  • Visualization software.

Using Homebrew

  1. Read more on Homebrew’s home page, but basically installation is a one-liner
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. To install new packages, simply type brew install packagename(s) at the command prompt. To search for a package, use brew search packagename.
  3. If you haven’t, you can install XQuartz and other macOS applications through Homebrew Cask with:
    brew install --cask mactex xquartz
    brew install --cask corretto cyberduck keepassxc microsoft-edge vlc zoom # choose as you see fit
  4. To install everything at once, use the following command. Keep in mind this will take a long time to complete and will accept the default option for all questions during the installation (remove the “-y” switch to answer each of them yourself).
    brew tap homebrew/x11
    brew tap homebrew/science
    brew install cmake fd gnuplot grace imagemagick ripgrep

Using MacPorts

  1. MacPorts has a “pkg” installer and the instructions for installation are straightforward.
  2. To install new packages, simply type “sudo port install packagename(s)” at the command prompt. To search for a package, use “port search packagename”. The full list of available packages is found on the MacPorts website on the Available Ports page.
  3. To install everything at once, use the following command. Keep in mind this will take a long time to complete and will accept the default option for all questions during the installation.
sudo port install cmake emacs gimp git gnuplot grace hunspell imagemagick inkscape octave py-matplotlib py-numpy py-scipy R texlive

Using Fink

  1. Fink used to also have a binary installer, but as of 03/25/2008 it is not available for Leopard or later OS X versions. You will need to follow the instructions on the Download page on Fink website.
  2. To install new packages, simply type “fink install packagename(s)” at the command prompt. To search for a package, use “fink apropos packagename”. The full list of available packages is found on the Fink Project website on the Packages page.
  3. To install everything at once, use the following command. Keep in mind this will take a long time to complete and will accept the default option for all questions during the installation (remove the “-y” switch to answer each of them yourself).
fink -y install cmake emacs24 gimp2 git gnuplot grace hunspell imagemagick inkscape octave matplotlib-py27 scipy-py27 numpy-py27 r-base texlive
Password: (enter your password)

Setting up ssh-agent

ssh USER_NAME@server.dept.univ.edu

Keep this terminal open so you can access the sample files on the group server for later steps.

Setting up .ssh/config

Transferring ssh setup to group server

  • Follow the instructions to transfer your ssh setup to the group server.
  • Using the terminal that was connected to the group server and kept open, edit the ~/.gnupg/gpg-agent.conf file and remove the line pinentry-program /usr/local/bin/pinentry-mac.
  • Test your SSH setup.

Customizing shell

Follow this part in Setting up Linux.

Customizing Terminal

  1. Open a Terminal window: find the Terminal icon again and double-click to open it. You can add this icon to your dock if you want (I recommend this since you will probably use Terminal more than any other application) by clicking and dragging the icon onto the dock.
  2. Once you have a Terminal window open, go to Terminal -> Settings. On the left of the Profiles tab is a series of included styles for the Terminal window. These are similar to PowerPoint templates. If you like one of them, simply highlight it and click on Default at the bottom of the list. This will make that style your default Terminal style.
  3. If you are interested in fuller customization, there are several things you can change. Explore the tabs of the Profiles tab to see what can be modified. You can change font style and size, text color, bold text color, highlight color, transparency, background color, etc.
  4. To make your terminal function more like a Unix terminal with familiar key functions, I recommend changing the following settings:
    • Shell: where it says: “When the shell exits”, select “Close if the shell exited cleanly”.
    • Keyboard: Check “Use Option as Meta Key” and change the following key bindings:
      • End: highlight and click on “edit.” Modifier: none. Action: “send string to shell.” Key sequence: type option-ctrl-[ together, then release and type [ followed by F. If you did this successfully, you will see \033[F on the line.
      • Home: highlight and click on “edit.” Modifier: none. Action: “send string to shell.” Key sequence: option-ctrl-[ then [ and H
      • Page down: highlight and click on “edit.” Modifier: none. Action: “send string to shell.” Key sequence: option-ctrl-[ then [ 6 ~
      • Page up: highlight and click on “edit.” Again, the modifier is “none” and the action is “send string to shell.” The key sequence is option-ctrl-[ then [ 5 ~.
      • Shift end: highlight and click on “edit.” Modifier: shift. Action: “scroll to end of buffer.”
      • Shift home: highlight and click on “edit.” Modifier: shift. Action: “scroll to start of buffer.”
      • Shift page down: highlight and click on “edit.” Modifier: shift. Action: “scroll to next page in buffer.”
      • Shift page up: highlight and click on “edit.” Modifier: shift. Action: “scroll to previous page in buffer.”
  5. The various color schemes also serve a purpose. You can create a library of different backgrounds corresponding to different work locations. Most of the work done in our lab involves remote connections to several computers, often multiple connections at the same time. I find the different backgrounds and colors, along with adding fun and interest to my screen, helps me keep straight which computer I am connected to at any given time. You can modify any of the existing color schemes or create your own.
    • In the Shell tab, check the box next to ‘Run command:’ and add the name of an aliased SSH command in the text box. Any time this particular Terminal profile is opened, it will automatically connect to the computer specified in the SSH command. The result will be a differently colored window open with a remote connection to a specific machine.
    • To open these customized windows, select New Window from the Terminal menu bar. A drop down list of the profiles you created will appear. Selecting any of them will open the new window with appropriate connection.

Comments

Comments powered by Disqus