Skip to content

Instantly share code, notes, and snippets.

View iansu's full-sized avatar

Ian Sutherland iansu

View GitHub Profile
@iansu
iansu / README.md
Last active June 20, 2022 00:20
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
@iansu
iansu / .bash_profile
Created April 20, 2019 21:45
Automatically run nvm when entering a directory with a .nvmrc file
_enter_dir() {
local git_root
git_root=$(git rev-parse --show-toplevel 2>/dev/null)
if [[ "$git_root" == "$PREV_PWD" ]]; then
return
elif [[ -n "$git_root" && -f "$git_root/.nvmrc" ]]; then
nvm use
NVM_DIRTY=1
elif [[ "$NVM_DIRTY" == 1 ]]; then