We generally like to use macs because they are unix-like, meaning that they can easily interface with the College linux systems (which are also unix-like), while also supporting a lot of proprietary software that we need (like Word, Excel...).
How would we go about setting up a brand new apple computer for scientific work? Below I outline how I would proceed with this task, but it will vary significantly from person to person (particularly in what is considered "essential" software).
The following assumes we made it through the most basic setup like starting the wifi, logging in with an apple ID, and turning Siri off.
First, open a terminal and install the package manager homebrew.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Homebrew can be used to install the majority of the software that is needed for science. You could install all the software mentioned below manually, but it would be incredibly tedious and error prone.
Occasionally, software on homebrew needs Apples developer toolkit to work (Xcode), so next we install Xcode from the app store and run,
xcode-select --install
in the terminal.
Now use brew to install all the command line tools we might need, in no particular order:
brew install git gh uv gcc netcdf ncview wget ffmpeg rclone rsync tree java neovim
An explanation of some of these tools:
git - a version control systemgh - a command line interface to GitHub.comuv - a python package and project managergcc - the GNU compiler collectionncview - a super simple netCDF file viewerwget - a utility for downloading things from the internetffmpeg - an audio and video converterrclone - a tool for connecting to cloud storage like Dropbox and Google Driveneovim - a modern version of the classic terminal text editor vimSome of these might already be on your system, but often they are out of date versions. Note that I don't install python this way, instead I do that with miniconda in the next step.
Homebrew can be used to install almost any software, including graphical user interface (GUI) software like the browser firefox, as well as other packages. To do so, we need to use the --cask option.
brew install --cask visual-studio-code adobe-acrobat-reader appcleaner caffeine firefox vlc julia mactex iterm2 dropbox gimp google-drive r rstudio inkscape zoom texmaker zotero bitwarden box-drive calibre djview
All of the above software is entirely optional. Of course, it will probably take a long time to install and use up significant bandwidth.
An explanation of some of the software:
visual-studio-code - a good code editorappcleaner - handy tool for uninstalling macOS applicationsmactex - TeX/LaTeX installation, which needs to be coupled with a tex editor like texmakerr - the R programming languagecaffeine - a handy command line utility that stops your operating system from sleeping for a set amount of timebitwarden - password manageriterm2 - terminalgimp - image editorinkscape - vector graphics editorzotero - my current favourite reference manager (which needs to be coupled with the better bibtex extension)calibre - an ebook managerdjview - for opening djv files, which are similar to pdf'smacOS now uses zsh by default and this amusingly named configuration of your shell adds very useful features like auto-completions. Find out more at https://ohmyz.sh/. Install using:
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
If you use bash rather than zsh, there is also oh my bash:
The most basic git configuration is to set a name and email.
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
I like to install miniforge
I also like to stop conda from automatically activating base in every new terminal.
conda config --set auto_activate_base false
If you installed Julia or R via brew install --cask above, then you can install the jupyter kernel for these languages.
To install the R kernel, first open a terminal and run R to start the R console. Then run:
install.packages('IRkernel')
IRkernel::installspec()
To install the Julia kernel, first open a terminal and run julia to start the julia console. Then hit ] to enter the REPL and follow up with:
add IJulia
That should be all you need to do.
Usually this involves logging into mathworks.com, downloading the latest version, and activating.
Add an alias to your ~/.zshrc file so that you can start up matlab from the terminal without the desktop environment. I might add,
alias mlab="matlab -nosplash -nodesktop"
There are numerous useful extensions. E.g.:
I like to use iTerm2 as my terminal application because it is both straightforward and extensively modifiable. Perhaps my favourite modification is to set ctrl + ~ to activate a terminal that drops down from the top of the screen. Instructions here.
In iTerm2, you can create unique profiles for each of your working spaces (e.g., local computer, server, vim). For each of these profiles, you can customize colors, specify shortcut keys to activate them, as well as starting commands (e.g., ssh [server]). This makes it far easier to know where you are.
iTerm2 > Preferences > Profiles
If you use multiple computers (e.g., laptop and workstation), you can sync your iTerm2 setting (including profiles) by saving them in a Dropbox folder.
On your main computer, go to iTerm2 > Preferences > General > Preferences and click Load preferences from a custom folder or URL. Select a Dropbox folder and save your local settings. Repeat the process on a secondary computer, but this time, do not save your local settings. After you restart iTerm2, the settings from your main computer should be available on your secondary computer.
I used to run jupyter lab on a conda environment for all my coding needs. I have now entirely switched to VS code. This is how I used to do things.
When using miniconda, the default conda environment (which is called base) doesn't contain any packages. For convenience I like to install code style formatters and jupyter lab with some extensions into base. You could also create a new environment (perhaps called jlab) to do this, leaving base completely clean, but then you'll have to activate jlab every time you want to start jupyter. Ultimately, there is no right or wrong way to proceed. I do:
conda activate base
conda install jupyterlab black isort cookiecutter jupyter-forward jupytext jupyterlab-system-monitor jupyterlab-spellchecker jupyterlab-git
For reference we can create a new named environment like so:
conda create -n [name] python=3.* [more packages]
replacing bracketed variables as appropriate. Delete an environment like this:
conda remove --name [name] --all
At this point I might add an alias to ~/.zshrc for convenience, e.g.
alias jlab="jupyter lab"
To set global jupytext configuration that will ignore jupytext version number metadata, create the following file:
mkdir -p ~/.config/jupytext
echo "notebook_metadata_filter: -jupytext.text_representation.jupytext_version" > ~/.config/jupytext/jupytext.yml