Honestly I’d stop if I could, but I just get carried away. After making a compiler for tmux, then solving sudoku, then playing video I wasn’t planning on making a game. These things just happen to you. Well maybe not to you, but they happen to me. Unlike the video player, this isn’t just rendering Snake inside tmux. The entire game—input, game logic, and rendering—is done using tmux config files. You just load tmux with this config, and you’ll have Snake. Check out the code or have a look at me playing it in the video: VIDEO The display works the same as my video player. It uses many tested sessions to create a stack of status lines, each with enough windows to span the width of the screen. The “display” is updated by setting the style of the window to correspond with the window name, and then changing the name to the appropriate colour. In this case I’m only using two colours, whereas in the video I was using the full range of ANSI colours. There’s a big difference in how I initialise the screen, with the video player I used a recursive script to start all the nested tmux sessions, and since I knew the width upfront (it has to be static as the video needs to be scaled) I just generated the right number of new-window calls. Since I wanted this to be entirely tmux, I worked out a way of doing this without a shell script. Instead of recursively calling a shell script to fill the height, I set the default-command (run whenever you create a new window) to be: TMUX= tmux if-shell -F "#{e|>:#{window_height},1}" new-session Every time a new session is created, if the height of the window in that session is more than one row, we’ll create a new session. Once we’ve filled the height, the command will exit without creating another session. To fill each session with windows, I added a hook for session-created: set-hook -g session-created { run -C "set -g @width '#{e|/:#{window_width},2}'" run -d 1 -bC 'source-file create_windows.conf' } After a short delay, this will load crea...
First seen: 2025-03-29 19:29
Last seen: 2025-03-29 23:31