.history/pwsh-wakatime_20210223105508.ps1

# wakatime for powershell
#
# include this file in your "~/.bashrc" file
#
# Don't forget to create and configure your "~/.wakatime.cfg" file.

## PROMPT MANAGEMENT ###########################################################

<#
    .SYNOPSIS
        Modifies the current prompt to send wakatime a tick.
    .EXAMPLE
        Add-CondaEnvironmentToPrompt
 
        Causes the current session's prompt to display the currently activated
        conda environment.
#>


# We use the same procedure to nest prompts as we did for nested tab completion.
if (Test-Path Function:\prompt) {
    Rename-Item Function:\prompt WakaTimePromptBackup
} else {
    function WakaTimePromptBackup() {
        # Restore a basic prompt if the definition is missing.
        "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) ";
    }
}

# hook function to send wakatime a tick
pre_prompt_command() {
    version="1.0.0"
    entity=$(echo $(fc -ln -0) | cut -d ' ' -f1)
    [ -z "$entity" ] && return # $entity is empty or only whitespace
    $(git rev-parse --is-inside-work-tree 2> /dev/null) && local project="$(basename $(git rev-parse --show-toplevel))" || local project="Terminal"
    (wakatime --write --plugin "bash-wakatime/$version" --entity-type app --project "$project" --entity "$entity" 2>&1 > /dev/null &)
}

PROMPT_COMMAND="pre_prompt_command; $PROMPT_COMMAND"