skynet/shell/bashrc.d/99-load-tmux.sh

21 lines
580 B
Bash
Raw Normal View History

2022-04-07 19:41:00 -05:00
#!/usr/bin/env bash
if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ linux ]] && [ -z "$TMUX" ]; then
exec tmux
fi
# robot quote
if [ -x "$(command -v botsay)" ]; then
len=1642 #$(jq '. | length' ~/skynet/quotes.json)
idx=$(( RANDOM % len))
quote=()
while read -r value; do
quote+=("$value")
done < <(jq -r ".[$idx] | .quoteText, .quoteAuthor" ~/skynet/shell/quotes.json)
quoteText="${quote[0]}"
if [ -n "${quote[1]}" ]; then
quoteText="$quoteText --${quote[1]}"
fi
echo "$quoteText" | botsay -c -
fi