<commit_before>function screenshot --description="When using `sway`: Takes screenshot, uploads to Dropbox and copies link to clipboard."
    set SCREENSHOT_DIR $SCREENSHOT_DIR
    set WAIT_TIME 5
    set TIMEOUT 3

    # define colours to use when printing messages
    set cRed (set_color red)
    set cGrn (set_color green)
    set cBlu (set_color blue)
    set cRst (set_color $fish_color_normal)

    function print_help
        echo "Usage: screenshot [options]"
        echo "Options:"
        echo (set_color green)"-l"(set_color $fish_color_normal)": Only output URL to clipboard (default outputs image to clipboard and URL to primary)"
        echo (set_color green)"-o"(set_color $fish_color_normal)": Open URL in browser after upload"
    end

    # default values (that can be changed via args)
    set OUTPUT_MODE image
    set OPEN_URL 0
    set WM sway
    set DEPENDENCIES grim slurp wl-copy

    argparse --name screenshot 'h/help' 'i-i3' 'l/linkonly' 'o/openafter' -- $argv
    or return 1 #error

    if set -lq _flag_help
        print help
        return
    end

    if set -lq _flag_i3
        set DEPENDENCIES slop scrot xclip
        set WM i3
    end

    if set -lq _flag_linkonly
        set OUTPUT_MODE linkonly
    end

    if set -lq _flag_openafter
        set OPEN_URL 1
    end

    set DEPENDENCIES $DEPENDENCIES dropbox-cli
    for dependency in $DEPENDENCIES
        if not type -q $dependency
            echo $cRed"You must have $dependency installed."$cRst
            return 1
        end
    end

    set FILENAME (string join "" $SCREENSHOT_DIR "/" (date +%Y%m%d_%Hh%Mm%Ss) ".png")

    if test $WM = "sway"
        slurp | grim -g - $FILENAME
    else if test $WM = "i3"
        set FILENAME (scrot $FILENAME -q 100 -a -e 'echo $f')
    end

    function getstatus
        set SYNC_STATUS (dropbox-cli filestatus $FILENAME)

        if test (string match $SYNC_STATUS = 'up to date')
            return 0
        else
            return 1
        end
    end

    getstatus
    set TIME_ELAPSED 0<commit_msg>Exit if selection is cancelled<commit_after>function screenshot --description="When using `sway`: Takes screenshot, uploads to Dropbox and copies link to clipboard."
    set SCREENSHOT_DIR $SCREENSHOT_DIR
    set WAIT_TIME 5
    set TIMEOUT 3

    # define colours to use when printing messages
    set cRed (set_color red)
    set cGrn (set_color green)
    set cBlu (set_color blue)
    set cRst (set_color $fish_color_normal)

    function print_help
        echo "Usage: screenshot [options]"
        echo "Options:"
        echo (set_color green)"-l"(set_color $fish_color_normal)": Only output URL to clipboard (default outputs image to clipboard and URL to primary)"
        echo (set_color green)"-o"(set_color $fish_color_normal)": Open URL in browser after upload"
    end

    # default values (that can be changed via args)
    set OUTPUT_MODE image
    set OPEN_URL 0
    set WM sway
    set DEPENDENCIES grim slurp wl-copy

    argparse --name screenshot 'h/help' 'i-i3' 'l/linkonly' 'o/openafter' -- $argv
    or return 1 #error

    if set -lq _flag_help
        print help
        return
    end

    if set -lq _flag_i3
        set DEPENDENCIES slop scrot xclip
        set WM i3
    end

    if set -lq _flag_linkonly
        set OUTPUT_MODE linkonly
    end

    if set -lq _flag_openafter
        set OPEN_URL 1
    end

    set DEPENDENCIES $DEPENDENCIES dropbox-cli
    for dependency in $DEPENDENCIES
        if not type -q $dependency
            echo $cRed"You must have $dependency installed."$cRst
            return 1
        end
    end

    set FILENAME (string join "" $SCREENSHOT_DIR "/" (date +%Y%m%d_%Hh%Mm%Ss) ".png")

    if test $WM = "sway"
        slurp | grim -g - $FILENAME
    else if test $WM = "i3"
        set FILENAME (scrot $FILENAME -q 100 -a -e 'echo $f')
    end

    if test $status -ne 0
    or not test -e $FILENAME
        return 1
    end

    function getstatus
        set SYNC_STATUS (dropbox-cli filestatus $FILENAME)

        if test (string match $SYNC_STATUS = 'up to date')
            return 0
        else
            return 1
        end
    end

    getstatus
    set TIME_ELAPSED 0
{'fraction_non_alphanumeric': 0.06949071870537839, 'fraction_numerical': 0.00809138505473584, 'mean_word_length': 2.26066718386346, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '966569', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1350, 'n_words': 488}