property traversingType : "previous"
property searchPath : "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
on run
tell application "Finder"
if (count of Finder windows) is 0 then
display alert "sibling" message "No Finder window is open." as warning
return
end if
set currentFolder to (target of front Finder window) as alias
end tell
set currentPath to POSIX path of currentFolder
set theCommand to "export PATH=" & quoted form of searchPath & "; " & ¬
"sibling --type " & traversingType & " -- " & quoted form of currentPath
try
set siblingPath to do shell script theCommand
on error errorMessage number errorNumber
if errorNumber is 1 then
display notification "No more " & traversingType & " folder." with title "sibling"
else
display alert "sibling" message errorMessage as warning
end if
return
end try
set siblingFolder to POSIX file siblingPath as alias
tell application "Finder"
set target of front Finder window to siblingFolder
activate
end tell
end run