aboutsummaryrefslogtreecommitdiffhomepage
path: root/threadcat-read.sh
blob: 5cdcdc07ff6a8b3845a7d8102810a13f75db06d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash

BOARD_NAME=$1
THREAD_NAME=$2

if [ -z "${THREAD_NAME}" ]; then
    THREAD_NAME=$BOARD_NAME
else
    THREAD_NAME=$BOARD_NAME/$THREAD_NAME
fi

if [ ! -z "${THREAD_NAME}" ]; then
    readarray -t lines < <(ssh $THREADCAT_USER "cat /opt/threadcat/$THREAD_NAME")
    for line in "${lines[@]}"; do
        if [[ $line =~  ^=== ]]; then
            echo -e "\e[0;36m$line\e[0m"
        else
            echo "$line";
        fi
    done
else
    echo You did not provide a thread name.
    echo USAGE: "threadcat read [BOARD] THREAD"
fi