Fossil Forum

LowRess 1 month, 1 week ago

Post: Fossil Integration for PhpStorm/IntelliJ (clean & OS independent)

The Fossil-not-Plugin for PhpStorm (and other JetBrains IDEs)

JetBrains Integration Script for Fossil (Clean, Lightweight & macOS/Bash 3.2 Compatible)

Hi everyone,

There have been a couple of attempts to build a native JetBrains plugin for Fossil over the years, but unfortunately, all of them have been dead for a decade or longer. I don’t know anything about Java or what else you need to write a full JetBrains plugin, but I absolutely was craving Fossil integration. After using PhpStorm for a few days, I came up with this idea. I tried my best to generalize and automate it so the Fossil community doesn't have to wait until judgment day for a working IDE integration.

jetbrains-fossil.sh is designed to bridge JetBrains IDEs (like IntelliJ, PhpStorm, WebStorm) with a Fossil custom scope and a set of External Tools injected into your toolbar and context menus.

It dynamically checks for local or remote setups, encapsulates directory switching safely, and handles everything with a tiny footprint.

Key Features:

  • Zero Boilerplate: Radically refactored down to just ~2.9 KB of raw, efficient Bash code.
  • Easily customizable: change visibilty or #disable commands to your liking by editing the COMMAND CONFIGURATION section.
  • Mac & Legacy Ready: Fully compatible with macOS's default Bash 3.2 (no modern associative arrays, robust subshell scoping).
  • should also run on Windows: as long as you wrap WSL, MSYS2 or something alike around it.
  • Safe Input Handling: Fully handles whitespace and special characters in user inputs (like commit messages) across SSH via an optimized Here-Doc execution pattern.
  • Smart Local Overrides: Automatically bypasses SSH overhead if $SRV is empty or 'localhost'.

Code Stats:

  • Core Logic: 2916 Bytes
  • Formatted: 2988 Bytes
  • Full Production (with exhaustive comments): 7527 Bytes

[ SOURCE CODE ATTACHED BELOW ] I have attached the fully commented, production-ready script to this post. Feel free to check it out, test it on your machines, or drop any feedback regarding Fossil workflow automation!

Setup:

see comments inside script. First step: Save as ~/bin/jetbrains-fossil.sh Z

stephan 1 month, 1 week ago

I have attached the fully commented, production-ready script to this post

No you didn't ;). This specific forum doesn't yet allow attachments except for admins. Can you please post a link to it?

LowRess 1 month, 1 week ago

Ah, sorry about that! I noticed the locked attachment button right after posting.

I don't have a dedicated webspace for it at the moment. Instead, I pasted the full code into the collapsible box below.

jetbrains-fossil.sh (fully commented 7527 Bytes Version)
#!/bin/bash
# ==============================================================================
# JETBRAINS-FOSSIL: The Fossil-not-Plugin for PhpStorm
# Copyright (c) 2026 by LowRess
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# ==============================================================================
# INSTALLATION & SETUP:
# 1. Save this script as ~/bin/jetbrains-fossil.sh on your local IDE machine.
# 2. Make it executable: chmod +x ~/bin/jetbrains-fossil.sh
# 3. Create a symlink for Java visibility:
#   sudo ln -s ~/bin/jetbrains-fossil.sh /usr/local/bin/jetbrains-fossil
# 4. Configure your connection options below (under CONNECTION CONFIGURATION).
# 5. Adjust the visibility options in the COMMANDS definition to your liking.
#   Be careful NOT to remove any configured 'u' flag!
# 6. Initialize the environment: jetbrains-fossil init (Windows users: see NOTE #4)
#   -> Automatically provisions the "Fossil" IDE tools menu suite.
#   -> Dynamically populates the "Fossil Changes" shared project scope.
# 7. Customize your interface (Optional): in PhpStorm
#   - Right-click the main top toolbar -> Customize Toolbar.
#   - Navigate to Main Toolbar > Left -> Add... ->
#   - Type in "Fossil" to navigate to External Tools > Fossil.
#   - Tip: Grab the Fossil logo (fossil3.gif), convert to PNG or SVG, and assign it
#   - move the new tool where you want it - I replaced "VCS group".
#   - add keyboard shortcuts where applicable.
# ==============================================================================
# NOTES
#   1. works great on my system (Linux, SSH mode); no guarantees for yours!
#   2. tested with PhpStorm 2026.1; but may also work with other JetBrains products.
#      reconfigure IDE_NAME to find out - and let me know!
#   3. some of the commands may be configured incorrectly or incompletely.
#      If you find errors, please let me know.
#   4. Windows users: put this script anywhere in your path, wrap
#      git bash, WSL or MSYS2 around it, and run with 'init' argument.
#   5. Should you alter this script, PLEASE keep the code as tidy as it is - and share it!
# ==============================================================================

# ==============================================================================
# CONNECTION CONFIGURATION
# ==============================================================================
SRV="localhost"             # name or IP address of your development server; may be empty for "localhost"
KEY="-i ~/.ssh/id_ed25519"  # "-i "+path to your private SSH key file
# ==============================================================================
IDE_NAME="PhpStorm"

# ==============================================================================
# COMMAND CONFIGURATION
# ==============================================================================
flag() { case $1 in
    m) a="showInMainMenu";;
    c) a="showInContextMenu";;
    t) a="showInToolwindowContextMenu";;
    p) a="showInProjectConnectionContextMenu";;
    u) a="synchronizeAfterRun";;
    *) echo "skipping unknown flag '$1'" >&2;return 1;;
esac; }

declare -a COMMANDS=(
    "add:cpu:\$FilePathRelativeToProjectRoot\$"
    "rm:cpu:\$FilePathRelativeToProjectRoot\$"
    "addremove:umpt:\$FilePathRelativeToProjectRoot\$" # Toolwindow, Main, Project + IDE Sync

    "status:mcut:"                                  # combines info and changes
    "info::"                                        # Info works great on the current file (Context) or globally
    "changes:u:"                                    # Global changes overview
    "timeline:mt:"                                  # Global project timeline
    "diff:mct:\$FilePathRelativeToProjectRoot\$"    # Diff for the selected file or global diff
#   "gdiff:mtc:\$FilePathRelativeToProjectRoot\$"   # Graphical diff
#   "ls:mt:"                                        # List files

    "commit:mcu:"                                   # Sync, show in Main Menu, Context Menu
#   "branch:mt:"                                    # Branch management
#   "push:mt:"                                      # Push usually runs globally from Main or Toolwindow
#   "pull:mtu:"                                     # Pull needs Sync after run to update the IDE state
    "sync:mtu:"                                     # Sync bidirectional. Needs IDE Sync after run

    "update:mtu:\$SelectedText\$"                   # Update to a version. SelectedText could be the tag/branch
    "checkout:mtu:\$SelectedText\$"                 # Checkout version. Needs IDE Sync
    "merge:mtu:\$SelectedText\$"                    # Merge branch. Needs IDE Sync

    "undo:mtu:"                                     # Undo local changes. Needs IDE Sync
    "redo:mtu:"                                     # Redo local changes. Needs IDE Sync
)

# probably never supported:
#fossil clone URL repository-filename
# definitely never supported:
#fossil init repository-filename && mkdir -p ~/src/project/trunk && cd ~/src/project/trunk && fossil open repository-filename && fossil add bootstrap.php index.php && fossil commit

# ==============================================================================
# THE ACTUAL CODE
# ==============================================================================
error() { t=""; [ -n "$2" ] && t=" on $2"; echo "$0$t: $1" >&2; exit 1; }
fos() {
    if [ -z "$SRV" ]; then
        (cd "$DIR" && fossil "$@")
    else
        ssh $KEY "$SRV" "sh -s" <<EOF
cd "$DIR" && fossil "$@"
EOF
    fi || error "fossil $* failed" "$SSH_TARGET"
}

DF=".idea/deployment.xml"; [ ! -f "$DF" ] && error "$DF not found";
DIR=$(grep -oP 'deploy="\K[^"]+' "$DF" | head -n 1)
[ -z "$DIR" ] && error "deploy target in $DF is empty"
[ -z "SRV" ] && [ ! -d "$DIR" ] && error "'$DIR' does not exist"

if [ -z "$1" ]; then error "requires at least one argument"
elif [ "init" = "$1" ]; then
    # INIT setup: compile XML
    xml() {
        IFS=: read -r cmd flags args <<<"$1"
        name="${2:-$(tr '[:lower:]' '[:upper:]' <<<${cmd:0:1})${cmd:1}}"
#       name="${2:-${cmd^}}" in bash 4
        attr="";[ -n "$3" ] && attr=" description=\"$3\""
        for (( i=${#flags}; i--; )); do flag "${flags:$i:1}" && attr+=" $a=\"true\""; done
        echo '
    <tool name="'"$name"'"'"$attr"' useConsole="true"><exec>
        <option name="COMMAND" value="jetbrains-fossil" />
        <option name="PARAMETERS" value="'"$cmd $args"'" />
        <option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
    </exec></tool>'
    }

    OUT='<toolSet name="Fossil">'"$(xml 'scope:mpu:' 'Scope Sync' 'Sync remote changes to local scope')"
    for item in "${COMMANDS[@]}"; do OUT+="$(xml "$item")"; done
    OUT+=$'\n</toolSet>'

    # INIT exploit: locate active JetBrains configuration and flush generated output to disk
    JB=$(find ~/.config/JetBrains -maxdepth 1 -type d -name "$IDE_NAME*" 2>/dev/null | sort -V | tail -n 1)
    [ -z "$JB" ] && error "$IDE_NAME config directory not found."
    TX="$JB/tools/Fossil.xml"; mkdir -p "$(dirname "$TX")"; echo "$OUT" > "$TX"

    echo "Successfully installed tool definitions to $TX."
    "$0" scope
    echo "Please restart $IDE_NAME to load the new menus."
elif [ "scope" = "$1" ]; then
    # SCOPE setup: grab fossil changes and reformat to JetBrains scope pattern"
    OUT=$(fos changes) || exit 1
    OUT=$(awk '{printf "file:%s||", $2}' <<< "$OUT" | sed 's/||$//')
    # SCOPE exploit: save $OUT to scope file
    mkdir -p ".idea/scopes"
    echo '<component name="DependencyValidationManager">
    <scope name="Fossil Changes" pattern="$OUT" />
</component>' > ".idea/scopes/Fossil_Changes.xml"
    echo "Fossil Project Scope Successfully (Re)built."
else
    # if CMD is defined -> Fossil call
    for item in "${COMMANDS[@]}"; do if [[ "$item" == "$1:"* ]]; then
        fos "$@"
        # if update flag is set -> rebuild scope
        CF="${item#*:}"; CF="${CMD_FLAGS%:*}"; [[ "$CF" == *u* ]] && "$0" scope
        exit 0
    fi; done
    error "unsupported command '$1'"
fi
LowRess 1 month, 1 week ago

Ah, sorry about that! I noticed the locked attachment button right after posting.

Quick update: I realized I forgot to mention a crucial setup detail.

  • The script must be initialized from within the root directory of a JetBrains project watched by Fossil (the location of your .idea directory).

I updated the internal documentation to reflect this, fixed some indentation issues and uploaded the updated script to jetbrains-fossil.sh (7535 bytes)

anonymous 1 month, 1 week ago

I'm not sure if you took a look at Fossil Integration for IntelliJ IDEA 15, WebStorm 11 etc.. Indeed, it's first release was ca 2015, yet there's source code available https://github.com/irengrig/fossil4idea.

LowRess 1 month, 1 week ago

Thanks for the link!

As I mentioned in my initial post, I know (almost) nothing about Java. I just know it's bulky, slows down my machine, and frankly, I have no desire to dive into it.

That plugin hasn't seen an update since late 2015, and it hasn't been working for at least five years. And even if I knew Java better, the underlying extension points are long deprecated and probably completely incompatible with modern JetBrains iterations.

That's exactly why I built this lightweight "not-plugin". Instead of fighting a decade-old Java codebase, this tiny 2.9 KB Bash script just works out of the box, uses zero extra RAM, and bypasses the IDE plugin-API hell entirely.

  • Locations change? Modify the parsing.
  • XSD changed? Modify the XML snippets. Worst case: rewrite the injection.
  • Variables renamed? modify the command config.

I like to build code that lasts.

LowRess 1 month, 1 week ago

The Fossil-not-Plugin for PhpStorm (and other JetBrains IDEs)

JetBrains Integration Script for Fossil - Clean, Lightweight & OS independent

Hi everyone,

There have been a couple of attempts to build a native JetBrains plugin for Fossil over the years, but unfortunately, all of them have been dead for a decade or longer, and afaik no solution for about five years. I don’t know anything about Java or what else you need to write a full JetBrains plugin, but I absolutely was craving Fossil integration. After using PhpStorm for a few days, I came up with this idea. I tried my best to generalize and automate it so the Fossil community doesn't have to wait until judgment day for the next working IDE integration.

jetbrains-fossil.sh is designed to bridge JetBrains IDEs (like IntelliJ, PhpStorm, WebStorm) with a Fossil custom scope and a set of External Tools injected into your toolbar and context menus.
It dynamically checks for local or remote setups, encapsulates directory switching safely, and handles everything with a tiny footprint.

Key Features:

  • Zero Boilerplate: Radically shrinked to less than 3 KB of raw, efficient, readable Bash code.
  • Easily customizable: change visibilty or #disable commands to your liking by editing the COMMAND CONFIGURATION section.
  • Mac & Legacy Ready: Fully compatible with macOS's default Bash 3.2 (no associative arrays, robust subshell scoping).
  • should also run on Windows: as long as you wrap WSL, MSYS2 or something alike around it.
  • Safe Input Handling: Fully handles whitespace and special characters in user inputs (like commit messages) across SSH via an optimized Here-Doc execution pattern.
  • Smart Local Overrides: Automatically bypasses SSH overhead if $SRV is empty or 'localhost'.

Code Stats:

  • Core Logic: 2916 Bytes
  • Formatted: 2988 Bytes
  • Full Production (with exhaustive comments): 7527 7535 Bytes

Download:

The fully commented, production-ready script can be downloaded from gmx.
Feel free to check it out, test it on your machines, or drop any feedback regarding Fossil workflow automation!

Setup:

see comments inside script. First step: Save as ~/bin/jetbrains-fossil.sh Z

LowRess 1 month, 1 week ago

The Fossil-not-Plugin for PhpStorm (and other JetBrains IDEs) - clean, lightweight, OS independent

Hi everyone,

There have been a couple of attempts to build a native JetBrains plugin for Fossil over the years, but unfortunately, all of them have been dead for a decade or longer, and afaik there has been no solution for more than five years. I don’t know anything about Java or what else you need to write a full JetBrains plugin, but I absolutely was craving Fossil integration. After using PhpStorm for a few days, I came up with this idea. I tried my best to generalize and automate it so the Fossil community doesn't have to wait until judgment day for the next working IDE integration.

The bash script is designed to bridge JetBrains IDEs (like IntelliJ, PhpStorm, WebStorm) with a Fossil custom scope and a set of External Tools injected into your toolbar and context menus.
It dynamically checks for local or remote setups, encapsulates directory switching safely, and handles everything with a tiny footprint.

Key Features:

  • Zero Boilerplate: Radically shrinked to less than 3 KB of raw, efficient, readable Bash code.
  • Easily customizable: change visibilty or #disable commands to your liking by editing the COMMAND CONFIGURATION section.
  • Mac & Legacy Ready: Fully compatible with macOS's default Bash 3.2 (no associative arrays, robust subshell scoping).
  • should also run on Windows: as long as you wrap WSL, MSYS2 or something alike around it.
  • Safe Input Handling: Fully handles whitespace and special characters in user inputs (like commit messages) across SSH via an optimized Here-Doc execution pattern.

Code Stats:

  • Core Logic: 2916 Bytes
  • Formatted: 2988 Bytes
  • Full Production (with exhaustive comments): 7527 7535 Bytes

Download & Setup:

Download the fully commented, production-ready script. Save as ~/bin/jetbrains-fossil.sh. Look inside for further instructions.
Feel free to check it out, test it on your machines, or drop any feedback regarding Fossil workflow automation! Z

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button