ChristianLempa / dotfiles

This contain my personal config files. Here you'll find configs, customizations, themes, and whatever I need to personalize my Linux and mac OS experience.
MIT License
920 stars 316 forks source link

.dotfiles/.zshrc, LFILE doesn't work #12

Closed nmofonseca closed 2 years ago

nmofonseca commented 2 years ago

Hello @xcad2k ,

I am raising an issue because I am not sure if I am correct or not, otherwise, I would have raised a PR. Anyway, I got here after watching your youtube video about setting up WSL2 + Windows Terminal + Starship, so, first of all, thank you so much for all the content you put out there, is very useful.

I am trying to setup starship and I am "stealing" your own zsh and starship config to setup my WSL, however, the code in the .zshrc didn't work for me in two WSL distros, the section I am referring is :

# find out which distribution we are running on
LFILE="/etc/*-release"
MFILE="/System/Library/CoreServices/SystemVersion.plist"
if [[ -f $LFILE ]]; then
  _distro=$(awk '/^ID=/' /etc/*-release | awk -F'=' '{ print tolower($2) }')
elif [[ -f $MFILE ]]; then
  _distro="macos"
fi

Setting the LFILE like that for me wasn't working, mainly because .zshrc doesn't have any shebang just runs as regular sh so I was getting the variable LFILE populated literally with the value "/etc/*-release", it still worked, STARSHIP_DISTRO was still being set with the Linux icon but I really wanted the ubuntu

I changed the code to be like this, however, is a very hacky way:

# find out which distribution we are running on
LFILE=$(ls -1 /etc/*-release | head -1)
MFILE="/System/Library/CoreServices/SystemVersion.plist"
if [[ -f $LFILE ]]; then
  _distro=$(awk '/^ID=/' /etc/*-release | awk -F'=' '{ print tolower($2) }')
  echo "I am here LFILE"
elif [[ -f $MFILE ]]; then
  _distro="macos"
  echo "I am here MFILE"
fi

Anyway thank you so much for sharing this with all of us.