commit 80ef552dd189ef44a6f3eadfe18329020eb9061f Author: dusk Date: Mon Aug 23 22:06:48 2021 +0200 First diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/pipechat b/pipechat new file mode 100644 index 0000000..46cb039 --- /dev/null +++ b/pipechat @@ -0,0 +1,42 @@ +#!/bin/sh +basedir="/tmp/pipechat" +[ -d $basedir ] || { + mkdir $basedir + chmod 777 $basedir +} + +[ -p $basedir/${USER} ] || { + mkfifo $basedir/${USER} + chmod 622 $basedir/${USER} +} + +while true; do cat $basedir/$USER; done & + +listen_pid=$! + +choice="" +choice2="" +while [ "$choice" != "q" ] +do + echo "Available users: (Type 'q' to exit)" + ls $basedir + read choice + [ -p $basedir/$choice ] && { + clear + echo "Chat with $choice. -Type :quit to exit" + while true + do + read choice2 + case $choice2 in + :quit) break ;; + :help) echo "Type :quit to quit." ;; + #*) printf "\e[0;36m${USER}: $choice2\e[m\n" > $basedir/$choice ;; + *) printf "${USER}: $choice2" > $basedir/$choice ;; + esac + done + } + + [ -p $basedir/$choice ] || [ "$choice" = "q" ] || echo "$choice is not an available user" +done + +kill $listen_pid