intellij-ideaideintellij-14

IntelliJ IDEA visual (not inspection) profiles?


I frequently have several different feature branches under simultaneous development. To minimize confusion I'd like to be able configure the IDEA UI to use different visual cues such as background color when I'm editing different branches.

I'm aware that IDEA has selectable "inspection" profiles, which are groups of settings to draw a user's attention to certain coding practices. The "Project Default" profile is always selected; optionally one may define other such profiles, and activate them when required.

This approach would also satisfy my issue if it could be applied to settings governing visual aspects of the user interface, but to my knowledge this feature does not exist.


Solution

  • Introduction

    What comes to mind is maybe adding a trigger / git-hook and detecting with the branch is changed.

    When this happens, run a script to replace your config file, and then restart inteliJ. You could also go further and generate a config file on the fly (e.g. calculate different colors depending on the name of the branch - based on a template).

    But let's start with a proof of concept.

    Create a sample script

    #!/bin/bash
    
    BRANCH=$(git rev-parse --abbrev-ref HEAD)
    CONFIG_FILE="path_to_intellij_config"
    
    if [ "$BRANCH" == "develop" ]; then
        cp develop.xml $CONFIG_FILE
    elif [ "$BRANCH" == "master" ]; then
        cp release.xml $CONFIG_FILE
    elif [ "$BRANCH" == "release" ]; then
        cp master.xml $CONFIG_FILE
    fi
    
    open -a "IntelliJ IDEA.app" --args --restart
    

    Add the git hook

    Put your script as the following file in the following location:

    .git/hooks/post-checkout