Sharing shell settings between Macs

Sharing shell settings between Macs

This one is a bit crazy, so be careful. Read on if you fall into most of these categories:

  • You have multiple Macs
  • You frequently make changes to .bash_profile (or equivalent)
  • You’d love to have your shell history shared between machines for tab completion
  • You have an iCloud account shared on all your Macs
  • You like to live a little dangerously

Iʼve been running this way over 10 years and have never run into problems, other than syncing sometimes being sluggish. However, most of the time it’s so fast that it’s amazing.

If your shell files get messed up during the setup and you can’t get to a command prompt, you can do the following:

  • Launch Terminal
  • Go to Preferences -> General
  • Change the “Shells open with”setting to specify a complete path.
  • Use a different shell path like /bin/tcsh or /bin/zsh.
  • Then, fix the problem if you know what it is or restore your shell files from backup

Since anyone wanting to try this is probably super advanced, I will provide a terse description rather than a beginner’s guide.

  • Back up any shell files you plan to sync
  • Move your shell files, such as .bash_profile and/or .bash_history to a new folder on iCloud Drive
  • Symlink from your home directory to the shell file(s) you moved
  • Repeat the symlink on all your Macs

Now, whenever you make a change to your shell config file or type any command, it’ll show up just as if you did the same on any of your other machines.

Related posts:

Sharing scripts between machines
Many-to-many screensharing
Multiple Macs, one location for screenshots