diff --git a/.zshrc b/.zshrc index 5d6e9b3..d81709a 100644 --- a/.zshrc +++ b/.zshrc @@ -2,3 +2,34 @@ # # Colored ls alias ls=ls --color=auto +# +# Detect Device Arch +arch="$(uname -m | tr '[:upper:]' '[:lower:]')" + +case "${arch}" in + x86_64) arch="amd64" ;; + armv*) arch="arm" ;; + arm64) arch="arm64" ;; + aarch64) arch="arm64" ;; + i686) arch="386" ;; +esac + +if [ "${arch}" = "arm64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then + arch=arm +fi +# +# Detect Device Platform +platform="$(uname -s | awk '{print tolower($0)}')" + +case "${platform}" in + linux) platform="linux" ;; + darwin) platform="darwin" ;; +esac +# +# Get and download the correct OMP +correct_omp="~/.config/oh-my-posh/posh-$platform-$arch" +if [ ! -f "$correct_omp" ]; then + echo "Downloading Oh My Posh for $platform-$arch" + curl -s -o "$correct_omp" "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/latest/posh-$platform-$arch" +fi +alias oh-my-posh="$correct_omp"