Skip to content

Deploy on macOS

G. Bai edited this page Apr 14, 2021 · 14 revisions

Bash

macOS comes with a Bash version with GPLv2 license, it is a version back in 2007:

$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.

To use newer version,

  1. Install from brew:

    $ brew install bash
  2. Whitelist it:

    $ sudo vim /etc/shells

    And add /usr/local/bin/bash to /etc/shells.

  3. Finally set default shell:

    $ chsh -s /usr/local/bin/bash
    $ echo $BASH_VERSION
    $ sudo chsh -s /usr/local/bin/bash

tmux-256color

Do not set $TERM in bashrc! It should be set by terminal emulator. However, to make prompt $PS1 display properly (italics) in tmux, it's best to use tmux-256color as tmux default-terminal, as in tmux.conf. And ncurses in macOS does not provide the right terminfo out-of-box, which creates problem for using Vim in tmux session. To enable tmux-256color terminfo support in macOS, see terminfo.

Vim

Python

When installing using brew, use the cask version, because it has python/dyn and python3/dyn enabled. Otherwise you need to compile Vim.

I use a Python 3.8.6 version installed by pyenv. Its dynamic library (called framework in macOS) is linked in vimrc. To build CPython with framework support on macOS:

  1. Uninstall binutils with brew temporarily. Usually instead of uninstalling we can do

    $ AR=/usr/bin/ar pyenv install ...

    but with option in next step this won't work. So we need to uninstall binutils and install it back afterwards.

  2. Run following in Bash:

    $ PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.8.6

I tried this with pyenv-virtualenv but no luck.

Colour scheme

Set colour scheme on Vim startup

This command queries system appearance:

$ defaults read -g AppleInterfaceStyle

In my vimrc, function MacBackground() utilises it.

Change gVim colour theme with system appearance

Per this pull of MacVim:

  • An event OSAppearanceChanged is added. This event is emitted when MacVim changes its appearance.
  • A vim variable v:os_appearance is added. This variable reflects the appearance setting.

In my vimrc, function MacGUIBackground() utilises it.

Clone this wiki locally