Skip to content

Instantly share code, notes, and snippets.

@sc0ttkclark
Last active March 3, 2024 09:22
Show Gist options
  • Select an option

  • Save sc0ttkclark/660655fea6916cd41bdc46c4fdb0d033 to your computer and use it in GitHub Desktop.

Select an option

Save sc0ttkclark/660655fea6916cd41bdc46c4fdb0d033 to your computer and use it in GitHub Desktop.

Revisions

  1. sc0ttkclark revised this gist Nov 15, 2022. No changes.
  2. sc0ttkclark revised this gist Nov 15, 2022. 2 changed files with 5 additions and 3 deletions.
    2 changes: 1 addition & 1 deletion 0-README.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Toolbox PhpStorm.app Mac integration with Tower.app for diff and merge

    1. Add `CompareTools.plist` and `phpstorm-toolbox.sh` files in the `~/Library/Application Support/com.fournova.Tower3/CompareTools/` directory.
    You may need to `mkdir ~/Library/Application\ Support/com.fournova.Tower3/CompareTools` if the folder does not already exist
    3. Update the `phpstorm-toolbox.sh` to use your username for the /Users/yourusername/ path.
    3. Update the `phpstorm-toolbox.sh` to use your username for the /Users/yourusername/ path and the correct version number (PhpStorm > About > Build #PS-XXX.XXXXX.XX where XXX.XXXXX.XX is the version number to use).
    4. Run `chmod +x ~/Library/Application\ Support/com.fournova.Tower3/CompareTools/phpstorm-toolbox.sh`
    5. Go into Tower.app Preference > Git Config > Select "PhpStorm" for "Diff tool" and "Compare tool", you can optionally enable "Perform directory diff"

    6 changes: 4 additions & 2 deletions phpstorm-toolbox.sh
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,10 @@
    LOCAL="$1"
    REMOTE="$2"

    APPLICATION_PATH="/Users/yourusername/Applications/JetBrains Toolbox/PhpStorm.app"
    CMD="$APPLICATION_PATH/Contents/MacOS/jetbrains-toolbox-launcher"
    PATH_USERNAME="yourusername"
    APP_VERSION="222.4345.15"
    APPLICATION_PATH="/Users/$PATH_USERNAME/Library/Application Support/JetBrains/Toolbox/apps/PhpStorm/ch-0/$APP_VERSION/PhpStorm.app"
    CMD="$APPLICATION_PATH/Contents/MacOS/phpstorm"

    # Sanitize LOCAL path
    if [[ ! "$LOCAL" =~ ^/ ]]; then
  3. sc0ttkclark revised this gist Nov 15, 2022. 2 changed files with 4 additions and 3 deletions.
    5 changes: 3 additions & 2 deletions 0-README.md
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,9 @@ Toolbox PhpStorm.app Mac integration with Tower.app for diff and merge

    1. Add `CompareTools.plist` and `phpstorm-toolbox.sh` files in the `~/Library/Application Support/com.fournova.Tower3/CompareTools/` directory.
    You may need to `mkdir ~/Library/Application\ Support/com.fournova.Tower3/CompareTools` if the folder does not already exist
    3. Run `chmod +x ~/Library/Application\ Support/com.fournova.Tower3/CompareTools/phpstorm-toolbox.sh`
    4. Go into Tower.app Preference > Git Config > Select "PhpStorm" for "Diff tool" and "Compare tool", you can optionally enable "Perform directory diff"
    3. Update the `phpstorm-toolbox.sh` to use your username for the /Users/yourusername/ path.
    4. Run `chmod +x ~/Library/Application\ Support/com.fournova.Tower3/CompareTools/phpstorm-toolbox.sh`
    5. Go into Tower.app Preference > Git Config > Select "PhpStorm" for "Diff tool" and "Compare tool", you can optionally enable "Perform directory diff"

    # Other variations

    2 changes: 1 addition & 1 deletion phpstorm-toolbox.sh
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    LOCAL="$1"
    REMOTE="$2"

    APPLICATION_PATH="/Users/sclark3/Applications/JetBrains Toolbox/PhpStorm.app"
    APPLICATION_PATH="/Users/yourusername/Applications/JetBrains Toolbox/PhpStorm.app"
    CMD="$APPLICATION_PATH/Contents/MacOS/jetbrains-toolbox-launcher"

    # Sanitize LOCAL path
  4. sc0ttkclark revised this gist Nov 15, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 0-README.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ Toolbox PhpStorm.app Mac integration with Tower.app for diff and merge
    # Other variations

    * PhpStorm (Standalone): https://gist.github.com/sc0ttkclark/213fe88f9eacbd5ae58a
    * PhpStorm (Toolbox): https://gist.github.com/sc0ttkclark/213fe88f9eacbd5ae58a
    * PhpStorm (Toolbox): https://gist.github.com/sc0ttkclark/660655fea6916cd41bdc46c4fdb0d033
    * WebStorm (Standalone): https://gist.github.com/sc0ttkclark/07f293e092fbb04d57dac0c2ed61c033
    * WebStorm (Toolbox): https://gist.github.com/sc0ttkclark/9e2529cb54edf9f7d316a07d7c2625e3

  5. sc0ttkclark revised this gist Jul 29, 2022. No changes.
  6. sc0ttkclark revised this gist Jul 29, 2022. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions 0-README.md
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,10 @@ Toolbox PhpStorm.app Mac integration with Tower.app for diff and merge

    # Other variations

    * WebStorm: https://gist.github.com/sc0ttkclark/07f293e092fbb04d57dac0c2ed61c033
    * PhpStorm (standalone): https://gist.github.com/sc0ttkclark/213fe88f9eacbd5ae58a
    * PhpStorm (Standalone): https://gist.github.com/sc0ttkclark/213fe88f9eacbd5ae58a
    * PhpStorm (Toolbox): https://gist.github.com/sc0ttkclark/213fe88f9eacbd5ae58a
    * WebStorm (Standalone): https://gist.github.com/sc0ttkclark/07f293e092fbb04d57dac0c2ed61c033
    * WebStorm (Toolbox): https://gist.github.com/sc0ttkclark/9e2529cb54edf9f7d316a07d7c2625e3

    # Credits

  7. sc0ttkclark revised this gist Jul 29, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions phpstorm-toolbox.sh
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    #! /usr/bin/env bash

    # Shell script shim to let PhpStorm.app to integrate with Tower.app
    # Shell script shim to let PhpStorm.app (Toolbox) to integrate with Tower.app
    #
    # Tower.app gives us these parameters:
    LOCAL="$1"
    REMOTE="$2"

    APPLICATION_PATH=/Applications/PhpStorm.app
    CMD="$APPLICATION_PATH/Contents/MacOS/phpstorm"
    APPLICATION_PATH="/Users/sclark3/Applications/JetBrains Toolbox/PhpStorm.app"
    CMD="$APPLICATION_PATH/Contents/MacOS/jetbrains-toolbox-launcher"

    # Sanitize LOCAL path
    if [[ ! "$LOCAL" =~ ^/ ]]; then
  8. sc0ttkclark revised this gist Jul 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CompareTools.plist
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    <key>ApplicationName</key>
    <string>PhpStorm</string>
    <key>DisplayName</key>
    <string>PhpStorm</string>
    <string>PhpStorm (Toolbox)</string>
    <key>LaunchScript</key>
    <string>phpstorm-toolbox.sh</string>
    <key>Identifier</key>
  9. sc0ttkclark revised this gist Jul 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 0-README.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ Toolbox PhpStorm.app Mac integration with Tower.app for diff and merge

    * WebStorm: https://gist.github.com/sc0ttkclark/07f293e092fbb04d57dac0c2ed61c033
    * PhpStorm (standalone): https://gist.github.com/sc0ttkclark/213fe88f9eacbd5ae58a
    * PhpStorm (Toolbox): https://gist.github.com/sc0ttkclark/tbd
    * PhpStorm (Toolbox): https://gist.github.com/sc0ttkclark/213fe88f9eacbd5ae58a

    # Credits

  10. sc0ttkclark created this gist Jul 29, 2022.
    19 changes: 19 additions & 0 deletions 0-README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    Toolbox PhpStorm.app Mac integration with Tower.app for diff and merge

    # How to use this

    1. Add `CompareTools.plist` and `phpstorm-toolbox.sh` files in the `~/Library/Application Support/com.fournova.Tower3/CompareTools/` directory.
    You may need to `mkdir ~/Library/Application\ Support/com.fournova.Tower3/CompareTools` if the folder does not already exist
    3. Run `chmod +x ~/Library/Application\ Support/com.fournova.Tower3/CompareTools/phpstorm-toolbox.sh`
    4. Go into Tower.app Preference > Git Config > Select "PhpStorm" for "Diff tool" and "Compare tool", you can optionally enable "Perform directory diff"

    # Other variations

    * WebStorm: https://gist.github.com/sc0ttkclark/07f293e092fbb04d57dac0c2ed61c033
    * PhpStorm (standalone): https://gist.github.com/sc0ttkclark/213fe88f9eacbd5ae58a
    * PhpStorm (Toolbox): https://gist.github.com/sc0ttkclark/tbd

    # Credits

    While I went and figured out how to do all of this, this integration is based on the one I found for Beyond Compare's beta integration:
    https://github.com/tednaleid/git-tower-beyond-compare-shim
    23 changes: 23 additions & 0 deletions CompareTools.plist
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <array>
    <dict>
    <key>ApplicationIdentifier</key>
    <string>com.jetbrains.PhpStorm</string>
    <key>ApplicationName</key>
    <string>PhpStorm</string>
    <key>DisplayName</key>
    <string>PhpStorm</string>
    <key>LaunchScript</key>
    <string>phpstorm-toolbox.sh</string>
    <key>Identifier</key>
    <string>phpstorm</string>
    <key>SupportsMergeTool</key>
    <true/>
    <key>SupportsDiffChangeset</key>
    <true/>
    </dict>
    </array>
    </plist>
    67 changes: 67 additions & 0 deletions phpstorm-toolbox.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    #! /usr/bin/env bash

    # Shell script shim to let PhpStorm.app to integrate with Tower.app
    #
    # Tower.app gives us these parameters:
    LOCAL="$1"
    REMOTE="$2"

    APPLICATION_PATH=/Applications/PhpStorm.app
    CMD="$APPLICATION_PATH/Contents/MacOS/phpstorm"

    # Sanitize LOCAL path
    if [[ ! "$LOCAL" =~ ^/ ]]; then
    LOCAL=$(echo "$LOCAL" | sed -e 's/^\.\///')
    LOCAL="$PWD/$LOCAL"
    fi

    # Sanitize REMOTE path
    if [[ ! "$REMOTE" =~ ^/ ]]; then
    REMOTE=$(echo "$REMOTE" | sed -e 's/^\.\///')
    REMOTE="$PWD/$REMOTE"
    fi

    MERGING="$4"
    BACKUP="/tmp/$(date +"%Y%d%m%H%M%S")"

    if [ -n "$MERGING" ]; then
    BASE="$3"
    MERGE="$4"

    # Sanitize BASE path
    if [[ ! "$BASE" =~ ^/ ]]; then
    BASE=$(echo "$BASE" | sed -e 's/^\.\///')
    BASE="$PWD/$BASE"

    if [ ! -f "$BASE" ]; then
    BASE=/dev/null
    fi
    fi

    # Sanitize MERGE path
    if [[ ! "$MERGE" =~ ^/ ]]; then
    MERGE=$(echo "$MERGE" | sed -e 's/^\.\///')
    MERGE="$PWD/$MERGE"

    if [ ! -f "$MERGE" ]; then
    # For conflict "Both Added", Git does not pass the merge param correctly in current versions
    MERGE=$(echo "$LOCAL" | sed -e 's/\.LOCAL\.[0-9]*//')
    fi
    fi

    sleep 1 # required to create different modification timestamp
    touch "$BACKUP"

    "$CMD" merge "$LOCAL" "$REMOTE" "$BASE" "$MERGE"
    else
    "$CMD" diff "$LOCAL" "$REMOTE"
    fi

    if [ -n "$MERGING" ]; then
    # Check if the merged file has changed
    if [ "$MERGE" -ot "$BACKUP" ]; then
    exit 1
    fi
    fi

    exit 0