<commit_before>function prm --description "Simple project management tool"
    set -l func_to_call "__prm_$argv[1]"

    if functions -q $func_to_call
        if not set -q prm_fish_dir
            if set -q PRM_FISH_DIR
                set -g prm_fish_dir $PRM_FISH_DIR
            else
                set -g prm_fish_dir $HOME/.prm-fish
            end
        end

        if not test -d $prm_fish_dir
            mkdir -p $prm_fish_dir
        end

        if not test -d $prm_fish_dir/.common
            mkdir -p $prm_fish_dir/.common
        end

        set -l scargs

        if test (count $argv) -gt 1
            set scargs $argv[2..-1]
        end

        eval $func_to_call $scargs
    else
        prm help
    end
end

function __prmcleanup --on-event __prm_clean_process
    rm -f $prm_fish_dir/.active-$argv[1].tmp
    rm -f $prm_fish_dir/.path-$argv[1].tmp
end

function __prm_active --description "List active projects and shell process id"
    cd $prm_fish_dir
    for instance in (ls .active*)
        set -l pid (echo $instance | sed 's/.active-\([0-9]*\).tmp/\1/')
        ps cax | grep $pid > /dev/null

        if test $status -eq 0
            echo $pid (cat $instance)
        else
            emit __prm_clean_process $pid
        end
    end
    prevd
end

function __prm_add --description "Creates new project(s)"
    if test (count $argv) -lt 1
        echo "No name given"
        return 1
    end

    for project_name in $argv
        set -l project_dir "$prm_fish_dir/$project_name"

        if not test -d $project_dir
            mkdir -p $project_dir
        else
            echo "Project $argv[1] already exists."
        end

        printf "# This script will run when STARTING the project \"$project_name\"
# Here you might want to cd into your project directory, activate virtualenvs, etc.
# Don't forget that functions loaded here will NOT be removed until restarting the shell or explicitely deleting them.

" > $project_dir/start.fish

        printf "# This script will run when STOPPING the project \"$project_name\"
# Here you might want to deactivate virtualenvs, clean up temporary files, etc.
# Don't forget that functions loaded here will NOT be removed until restarting the shell or explicitely removing them with 'functions -e function_name'.

" > $project_dir/stop.fish

        eval $EDITOR $project_dir/start.fish; and eval $EDITOR $project_dir/stop.fish

        echo "Added project $project_name."
    end
end

function __prm_edit --description "Edit existing project(s)"
    if test (count $argv) -lt 1
        echo "No name given."
        return 1
    end

    for project_name in $argv
        set -l project_dir "$prm_fish_dir/$project_name"

        if test -d $project_dir
            eval $EDITOR $project_dir/start.fish; and eval $EDITOR $project_dir/stop.fish
            echo "Edited project $project_name."
        else
            echo "$project_name: No such project."
        end
    end
end

function __prm_list --description "List existing projects"
    if not test (find $prm_fish_dir -type d | wc -l) -gt 1
        echo "No projects exist."
    else
        # set -l pid (echo $instance | sed 's/.active-\([0-9]*\).tmp/\1/')
        for d in (ls -d $prm_fish_dir/*)
            echo (basename $d)
        end
    end
end

function __prm_remove --description "Remove existing project(s)"
    if test (count $argv) -lt 1
        echo "No name given."
        return 1<commit_msg>Check that $EDITOR is set<commit_after>function prm --description "Simple project management tool"
    set -l func_to_call "__prm_$argv[1]"

    if functions -q $func_to_call
        if not set -q prm_fish_dir
            if set -q PRM_FISH_DIR
                set -g prm_fish_dir $PRM_FISH_DIR
            else
                set -g prm_fish_dir $HOME/.prm-fish
            end
        end

        if not test -d $prm_fish_dir
            mkdir -p $prm_fish_dir
        end

        if not test -d $prm_fish_dir/.common
            mkdir -p $prm_fish_dir/.common
        end

        set -l scargs

        if test (count $argv) -gt 1
            set scargs $argv[2..-1]
        end

        eval $func_to_call $scargs
    else
        prm help
    end
end

function __prmcleanup --on-event __prm_clean_process
    rm -f $prm_fish_dir/.active-$argv[1].tmp
    rm -f $prm_fish_dir/.path-$argv[1].tmp
end

function __prm_active --description "List active projects and shell process id"
    cd $prm_fish_dir
    for instance in (ls .active*)
        set -l pid (echo $instance | sed 's/.active-\([0-9]*\).tmp/\1/')
        ps cax | grep $pid > /dev/null

        if test $status -eq 0
            echo $pid (cat $instance)
        else
            emit __prm_clean_process $pid
        end
    end
    prevd
end

function __prm_add --description "Creates new project(s)"
    if test (count $argv) -lt 1
        echo "No name given"
        return 1
    end

    for project_name in $argv
        set -l project_dir "$prm_fish_dir/$project_name"

        if not test -d $project_dir
            mkdir -p $project_dir
        else
            echo "Project $argv[1] already exists."
        end

        printf "# This script will run when STARTING the project \"$project_name\"
# Here you might want to cd into your project directory, activate virtualenvs, etc.
# Don't forget that functions loaded here will NOT be removed until restarting the shell or explicitely deleting them.

" > $project_dir/start.fish

        printf "# This script will run when STOPPING the project \"$project_name\"
# Here you might want to deactivate virtualenvs, clean up temporary files, etc.
# Don't forget that functions loaded here will NOT be removed until restarting the shell or explicitely removing them with 'functions -e function_name'.

" > $project_dir/stop.fish

        if not set -q EDITOR
            echo "'EDITOR' variable not set. You rill not be able to add, copy or edit projects."
            return 2
        end

        eval $EDITOR $project_dir/start.fish; and eval $EDITOR $project_dir/stop.fish

        echo "Added project $project_name."
    end
end

function __prm_edit --description "Edit existing project(s)"
    if test (count $argv) -lt 1
        echo "No name given."
        return 1
    end

    for project_name in $argv
        set -l project_dir "$prm_fish_dir/$project_name"

        if test -d $project_dir

            if not set -q EDITOR
                echo "'EDITOR' variable not set. You rill not be able to add, copy or edit projects."
                return 2
            end

            eval $EDITOR $project_dir/start.fish; and eval $EDITOR $project_dir/stop.fish
            echo "Edited project $project_name."
        else
            echo "$project_name: No such project."
        end
    end
end

function __prm_list --description "List existing projects"
    if not test (find $prm_fish_dir -type d | wc -l) -gt 1
        echo "No projects exist."
    else
        # set -l pid (echo $instance | sed 's/.active-\([0-9]*\).tmp/\1/')
        for d in (ls -d $prm_fish_dir/*)
            echo (basename $d)
        end
    end
end

function __prm_remove --description "Remove existing project(s)"
    if test (count $argv) -lt 1
        echo "No name given."
        return 1
{'fraction_non_alphanumeric': 0.08348232705267501, 'fraction_numerical': 0.006051437216338881, 'mean_word_length': 2.0099337748344372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3412040', 'n_tokens_mistral': 2272, 'n_tokens_neox': 2194, 'n_words': 817}