liverepl

Evaluer ses scripts en temps réel (dangereux ⚠️) - retour accueil

git clone git://bebou.netlib.re/liverepl
Log | Files | Refs | README |

commit b8b9956d217adabb6065840121d6c228bbdf835a
parent 2e3faee6511e4630b9e4aed765e5071ca2d49f78
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Thu, 29 Aug 2024 13:00:25 +0200

Ajout d'une fonction pour se reco dans un pipeline

Fonction par défaut
Si la session tmux n'existe pas on la créer
nb de pane par défaut = 3

Diffstat:
Mpipeline | 22++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/pipeline b/pipeline @@ -5,10 +5,10 @@ while getopts "c:t:n:" opt;do done create() { - nb="${1:-1}" - title="$2" + title="$1" + nb="${2:-3}" tmpd="/tmp/$title" - mkdir "$tmpd" + mkdir -p "$tmpd" tmux new-session -d -s "$title" "./liverepl -o $tmpd/1 -s $tmpd/1-cmd" tmux send-keys -t "$title" "seq 10" for i in $(seq 2 $nb);do @@ -19,6 +19,16 @@ create() { tmux attach -t "$title" } +pipelineexists() { + title="$1" + tmux ls | cut -d':' -f1 | grep -qE "^$title$" +} + +join() { + title="$1" + pipelineexists "$title" && tmux attach -t "$title" || create "$title" ${n:-3} +} + printp() { title="$1" find /tmp/$title/ -name '*-cmd' | @@ -41,11 +51,11 @@ makescript() { chmod +x $title } -case "$c" in - (create) create $n $t;; +case "${c:-join}" in + (create) create $t $n;; + (join) join $t ;; (print) printp $t ;; (exec) execute $t ;; (make) makescript $t ;; esac -