Skip to content

Commit

Permalink
Merge pull request #239 from himkt/make-func-zsh-script
Browse files Browse the repository at this point in the history
misc: implement clean_platform_specific_env in zsh
  • Loading branch information
himkt authored Apr 20, 2024
2 parents 4109d40 + d703ee1 commit 1cfae8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
19 changes: 0 additions & 19 deletions bin/clean-platform-specific-env

This file was deleted.

22 changes: 20 additions & 2 deletions zsh/config.d/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,25 @@ function retcode () {
}

function clean_platform_specific_env () {
export PATH=`clean-platform-specific-env $HOMEBREW_ROOT $PYENV_ROOT $NODENV_ROOT`
prefixes=("$@")

paths=("${(@s/:/)PATH}")
cleaned_paths=()

for path in $paths; do
match=0
for prefix in $prefixes; do
if [[ $path == $prefix* ]]; then
match=1
break
fi
done
if [[ $match -eq 0 ]]; then
cleaned_paths+=$path
fi
done

export PATH=`echo ${(j/:/)cleaned_paths}`
}

function change-platform () {
Expand All @@ -64,7 +82,7 @@ function change-platform () {
deactivate
fi

clean_platform_specific_env
clean_platform_specific_env $HOMEBREW_ROOT $PYENV_ROOT $NODENV_ROOT

case "${next_platform}" in
arm64*)
Expand Down

0 comments on commit 1cfae8c

Please sign in to comment.