Skip to content

Commit

Permalink
Rewrite brew.fish
Browse files Browse the repository at this point in the history
  • Loading branch information
lunij authored and scorphus committed Nov 1, 2021
1 parent b437b29 commit df34386
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions conf.d/brew.fish
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
set -l brew_paths /opt/homebrew/bin /usr/local/bin /usr/bin /bin /opt/homebrew/sbin /usr/local/sbin /usr/sbin /sbin

# Append all existing brew paths to PATH
set -l existing_brew_paths
for brew_path in $brew_paths
if test -d $brew_path
set PATH $PATH $brew_path
set existing_brew_paths $existing_brew_paths $brew_path
if contains $brew_path $PATH
continue
end
end

# Remove brew paths from tail to head that were not recently added
set -l number_of_paths_to_ignore (math (count $PATH) - (count $existing_brew_paths))
for i in (seq (count $PATH))[-1..1]
if test $i -le $number_of_paths_to_ignore
if contains $PATH[$i] $brew_paths
set -e PATH[$i]
end
if test -f $brew_path/brew
set brew_found true
set PATH $brew_path $PATH
break
end
end

if not set -q brew_found
echo "Please install 'brew' first!"
end

0 comments on commit df34386

Please sign in to comment.