# -----------------------------------------------------
# AUTOSTART
# -----------------------------------------------------

# The 'finder' command (Fuzzy Finder)
finder() {
    # Run the script and capture the result
    local result=$($HOME/.config/ml4w/bin/ml4w-finder)

    # Check if the script told us to CD
    if [[ "$result" == TYPE_DIR:* ]]; then
        local target_dir="${result#TYPE_DIR:}"
        cd "$target_dir" && ls
    elif [[ "$result" == TYPE_FILE:* ]]; then
    # Check if we have a file
        ${EDITOR:-nano} "${result#TYPE_FILE:}"
    else
    # Return an error
        echo "Could not read $result" >&2
        return 1
    fi
}

# -----------------------------------------------------
# Fastfetch
# -----------------------------------------------------
if [[ $(tty) == *"pts"* ]]; then
    if [ ! -f $HOME/.config/ml4w/settings/hide-fastfetch ]; then
        fastfetch
    fi
fi
