Skip to content

Instantly share code, notes, and snippets.

@mindfullsilence
Created April 13, 2023 15:12
Show Gist options
  • Select an option

  • Save mindfullsilence/c3965de4d1fabb4da26b4171cdde4ca8 to your computer and use it in GitHub Desktop.

Select an option

Save mindfullsilence/c3965de4d1fabb4da26b4171cdde4ca8 to your computer and use it in GitHub Desktop.

Revisions

  1. mindfullsilence created this gist Apr 13, 2023.
    15 changes: 15 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    Add the function to your bash profile
    Ensure brew is installed
    Run it!

    Example:

    ```sh
    brewphus install 8.0
    ```

    ```sh
    brewphus use 8.0
    # or
    brewphus switch 8.0
    ```
    26 changes: 26 additions & 0 deletions brewphus.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    function brewphus() {
    ACTION=$1
    VERSION=$2
    VERSION_STRING="shivammathur/php/php@${VERSION}"

    case $ACTION in

    install)
    brew update
    brew tap shivammathur/php
    brew install $VERSION_STRING
    ;;

    switch | use)
    OUTPUT="brew link --overwrite --force $VERSION_STRING"
    if ( ${OUTPUT} | grep 'Warning: Already linked' ); then
    brew unlink php
    $(OUTPUT)
    fi
    ;;

    *)
    echo 'You did not define an action. brewphus {upgrade|update} {version}'
    ;;
    esac
    }