Praveen Chandrashekar

Centre for Applicable Mathematics, TIFR, Bangalore

[ People | News | Codes | Talks | Teaching | Publications | Calendar | Hiking | Contact ]

Computing on Mac OSX

Mac OSX comes with a huge collection of free tools pre-installed and has almost everything that a developer needs for C/C++ coding. Other things need to be installed. I mainly used two package managers for this.

  1. Homebrew
  2. Spack

Command line tools

This gives you compilers, git, etc.; you can install it by

sudo xcode-select --install

Sometimes, I find it necessary to delete the existing command line tools and then install to get the latest version

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

Searching your desktop

Alfred is so much better than Spotlight, it is now my preferred tool for searching my mac. It uses the Spotlight index to perform the search, so you need to have Spotlight enabled.

Text editors

For coding, you can use the editor in XCode but XCode is a big package and I prefer not to install it. Instead I use VSCode which is free and can be installed from Homebrew. You can use the Vim plugin in VSCode if you are a Vim user. Another option is MacVim with NerdTree for file browsing.

Diff tool

OSX comes with a nice diff tool called opendiff which can be invoked from the command line to compare two files side by side, but this needs XCode. Other options are VSCode,

code -n -d file1 file2

or, meld and tkdiff (install via homebrew).

Version control

git is already available and I use SourceTree as a gui for git.

Python

You can install Python using brew but I use miniforge to get a Python installation.

brew install miniforge
conda install ...

Plotting/visualization tools

Gnuplot is really useful to do some quick and simple visualizations. Install via brew

brew install gnuplot

To generate line plots for publication, Matplotlib is probably the most useful. Install this from your Python distribution.

VisIt is my favourite program for visualizing PDE solutions coming from finite difference/volume/element methods. You may also want to try Paraview which is also very powerful tool.

Document preparation/viewing

MacTex is a nice way to install all the Latex packages.

TexStudio is a great editor for Latex.

To manage my bibliography, I have come to like Zotero a lot.

TexMacs is a wysiwyg editor that seems to be getting very good. I sometimes use it for writing small notes and documents.

Acrobat: For viewing pdf files, but I find this a very heavy application and avoid using it normally. I prefer to use builtin Preview. But there are some times when your PDF doesnt display properly and you absolutely need this. Keep it installed for those times.

djview: For viewing djvu archive files. Most ebooks are packaged as djvu files. The available binaries are old versions; you can install this via brew (brew install djview).

Keynote is free with OSX and is surprisingly good, even better than PowerPoint. You also get Pages for free which is an alternative to Word.

LibreOffice: Built on openoffice.

File transfer

FileZilla lets you setup some servers so that you can quickly transfer files between your computers.

Image tools

Asymptote: Asymptote is a powerful descriptive vector graphics language that provides a natural coordinate-based framework for technical drawing. Labels and equations are typeset with LaTeX, for high-quality PostScript output. If you installed MaxTex, then you already have asymptote. Otherwise you can install it using brew.

ImageMagick: Use ImageMagick to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, HEIC, TIFF, DPX, EXR, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bezier curves.

Engauge: This open source, digitizing software converts an image file showing a graph or map, into numbers. The image file can come from a scanner, digital camera or screenshot. The numbers can be read on the screen, and written or copied to a spreadsheet

Inkscape: Inkscape is a Vector Graphics Editor, similar to Adobe Illustrator, that strives to be SVG Compliant, open source, responsive and extensible.

Video player

While I have experimented many, IINA is the one I now use.

Browser

Safari works well; other options are Firefox and Opera. (Avoid Chrome like the plague)

Some command line stuff

softwareupdate -l

Creating bootable USB drive on MacOS

Convert iso file to dmg

hdiutil convert -format UDRW -o foo foo.iso

This creates foo.dmg file. List the drives and find drive /dev/diskN associated to the USB device

diskutil list

Unmount it

diskutil unmountDisk /dev/diskN

Copy the dmg file

sudo dd if=foo.dmg of=/dev/rdiskN bs=1m

When it finishes, you can remove the USB drive.

Miscellaneous stuff

  1. If you are behind a proxy server, then to get server settings to be visible under sudo, you need to set some environment variables for http and rsync and do the following
    sudo visudo
    
    Enter your password and add the following additional lines and save the file. You need to know how to use vi/vim for this.
    Defaults env_keep += "http_proxy HTTP_PROXY"
    Defaults env_keep += "https_proxy HTTPS_PROXY"
    Defaults env_keep += "ftp_proxy FTP_PROXY"
    Defaults env_keep += "rsync_proxy RSYNC_PROXY"
    
  2. AppCleaner allows you to uninstall apps and all associated files.
  3. To see some info on your wireless connection, click Option + wifi icon in menubar.
  4. On new versions like Catalina, the battery discharges overnight even if the laptop is in sleep because it is waking up for network. In System Preferences --> Energy Saver --> Battery, disable "Enable Power Nap while on battery power". To disable network while sleeping on battery
    sudo pmset -b tcpkeepalive  0    # Redo if you did SMC/NVRAM reset or os update
    sudo pmset -a hibernatemode 25
    sudo pmset -a standby       1
    
    You can check the settings by (do this check while using battery)
    pmset -g
    
    Use only integrated GPU when on battery
    sudo pmset -b gpuswitch 0
    
    Here are the various power states
    -a - global (same behavior for charging and battery states)
    -c - charging
    -b - battery
    
    Here are the possible options for gpuswitch
    0 - integrated GPU only
    1 - discrete GPU only
    2 - autoswitch GPU
    
  5. To disable laptop auto booting on lid opening
    sudo nvram AutoBoot=%00 # Redo if NVRAM is reset
    
    To reenable auto boot
    sudo nvram AutoBoot=%03
    
  6. Sometimes Activity Monitor does not display any columns. Then delete the preferences file
    rm ~/Library/Preferences/com.apple.ActivityMonitor.plist
    
    and reopen it.
  7. PulseSecure starts automatically on login. Disable it like this
    sudo rm /Library/LaunchAgents/net.pulsesecure.pulsetray.plist
    
    Then, add symlink to `/Applications`
    sudo ln -s /Applications/Pulse\ Secure.app/Contents/Plugins/JamUI/PulseTray.app \
               /Applications/PulseTray.app
    
    and use PulseTray to launch PulseSecure in future.
  8. Reset NVRAM from terminal
    sudo nvram -c
    sudo shutdown -r now
    
  9. Reset icons in launchpad
    defaults write com.apple.dock ResetLaunchPad -bool true && killall Dock
    
  10. BigSur messed up the menu bar design in app windows, to get previous type view do this
    defaults write -g NSWindowSupportsAutomaticInlineTitle -bool false
    
    You have to quit and start the app for this to take effect. (Does not seem to work in Monterey)
  11. Reset Finder views/settings
    find . -name ".DS_Store" -delete
    rm ~/Library/Preferences/com.apple.finder.plist
    
  12. Enable repeat key press, useful for Vim mode in VSCode, overleaf, etc.
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
    
  13. Get expanded desktop view in mission control using this, needs SIP to be disabled.
  14. Disable Safari tab preview
    defaults write com.apple.Safari DebugDisableTabHoverPreview 1
    
  15. Disable spelling correction, etc.: System Preferences --> Keyboard --> Text
  16. Getting display of X11 programs running on remote Mac: On your remote Mac, add following to /etc/ssh/sshd_config
    X11Forwarding yes
    X11DisplayOffset 10
    X11UseLocalhost yes
    XauthLocation /opt/X11/bin/xauth
    
    and restart ssh service
    sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
    sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist