Skip to content

Instantly share code, notes, and snippets.

@iansu
Last active June 20, 2022 00:20
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save iansu/1ad9fc5db90aafbf14ce58e99d5940ef to your computer and use it in GitHub Desktop.
Display shell architecture in prompt

Display the architecture (arm64 or x86) of the current shell in your prompt using Starship. I use zsh as my shell but you should be able to adapt this for other shells. As a bonus this also shows you how to set up your path to work with both arm64 and x86 versions of Homebrew.

Add this to your ~/.zshrc:

if [[ $(arch) == 'arm64' ]]; then
  export PATH="$HOME/bin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
  export SHELL_ARCH="arm64"
  echo '=========== arm64 ============'
else
  export PATH="$HOME/bin:/usr/local/bin:/usr/local/sbin:$PATH"
  export SHELL_ARCH="x86"
  echo '============ x86 ============='
fi

Add this to your ~/.config/starship.toml:

[env_var]
variable = "SHELL_ARCH"
style = "bold yellow"
format = "[$env_value]($style) "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment