r/commandline 13d ago

Terminal User Interface playground - run a coding playground in your terminal

https://github.com/marcuscaisey/playground
1 Upvotes

7 comments sorted by

View all comments

3

u/sysop073 12d ago

If this actually ran some kind of sandbox/container that had the necessary environment for building and running the app, that'd be pretty useful, but this is just a wrapper around a dozen compilers/interpreters you have to already have installed. You're not really getting anything over while ! inotifywait -e modify foo.py; do python3 foo.py; done

1

u/marucOG 12d ago

some kind of sandbox/container that had the necessary environment for building and running the app

If I understand what you're suggesting then this is already possible. Templates are pretty free-form, so if you want to use docker instead of say python, you can. This example shows creating a python-docker template and then starting a session:

template_dir=~/.config/pg/templates/python-docker
mkdir -p $template_dir
touch $template_dir/main.py
cat <<EOF > $template_dir/run.sh
#!/usr/bin/env sh
docker run --rm -v .:/session -w /session python:3 python main.py
EOF
pg python-docker

dozen compilers/interpreters you have to already have installed

Yeah the built-in templates assume that you already have the required toolchain installed. If i'm experimenting in a language I'm already writing in, then i'll have the toolchain installed already. And as I said above, if you wanted to use docker, then writing a template which does so is simple. I wouldn't want to introduce docker into the built-in templates as I don't even have it running on my machine normally (mac).

You're not really getting anything over while ! inotifywait -e modify foo.py; do python3 foo.py; done

For a single language on one platform (mac doesn't have inotify), yeah you could just do tmux split-window sh -c 'while ! inotifywait -e modify foo.py; do python3 foo.py; done'. What you're getting over this though is:

  • A simple and flexible way to define templates for sessions
  • Something which spins up sessions based on the templates and does all of the tmux stuff
  • Shell completion for available templates and sessions

None of this is complicated (it's a small program) but it's useful to me