Skip to content

Instantly share code, notes, and snippets.

@kseistrup kseistrup/twtxt-forever.sh
Last active Feb 25, 2016

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.

Copy link
Owner Author

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.