Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash loop to post twtxt ‘tweets’ forever
#!/bin/bash
MY_PROMPT='twtxt> '
my_ruler () {
local ruler=''
local length=8
local ten='----+----|'
local maxlen="${COLUMNS:-140}"
[[ ${maxlen} -gt 140 ]] && maxlen=140
while [[ ${length} -lt $((${maxlen}-10)) ]]
do
ruler="${ruler}${ten}"
length="${#ruler}"
done
clear
printf " ${ruler}\n"
}
my_tweet () {
local tweet=''
my_ruler
read -e -p "${MY_PROMPT}" -i "${tweet}" tweet
while :
do
read -n1 -e -p "$(printf "Post \x1b[1m[\x1b[0m${tweet}\x1b[1m]\x1b[0m? [Y]es/[N]o/[E]dit: ")" answer
case "${answer}" in
y | Y ) break ;;
n | N ) return ;;
e | E )
my_ruler
read -e -p "${MY_PROMPT}" -i "${tweet}" tweet
;;
esac
done
twtxt tweet "${tweet}" && echo "${tweet}"
}
my_main () {
while :
do
read -n1 -e -p 'Press any key to continue (Q to quit): ' answer
case "${answer}" in
q | Q )
return
;;
* )
: pass
;;
esac
my_tweet
done
}
clear
my_main
# eof
@kseistrup

This comment has been minimized.

Show comment
Hide comment
@kseistrup

kseistrup Feb 25, 2016

The script is meant to run in the lower tmux pane that has been minimized to 2 lines, while a timeline loop runs in the upper pane.

Reminder:

^b "    # create a new pane
^b ;    # jump to other pane
^b ↓    # resize pane
Owner

kseistrup commented Feb 25, 2016

The script is meant to run in the lower tmux pane that has been minimized to 2 lines, while a timeline loop runs in the upper pane.

Reminder:

^b "    # create a new pane
^b ;    # jump to other pane
^b ↓    # resize pane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment