1. 17

  2. 2

    Funny, I built exactly the same thing using neovim’s built-in terminal emulator instead of tmux, and it suffers from exactly the same issues (except for multiline prompts, which work fine)!

    The only thing I can think of that would allow making this feature without ugly hacks would be to a have terminal escape sequences that would let the shell notify the terminal about the different sections being printed. Making that work would certainly require immense amounts of synchronization between shell and terminal developers though, so I’m not surprised nobody’s done it yet.

    1. 1

      That’s what iTerm does, actually. I haven’t tried it, so I’m not sure how well it works, but it sounds like it can do a bunch of cool stuff:


      I have another idea, which is to write my own shell TUI and run it as a full-screen program, instead of tmux + my shell’s native interactive mode. Run each command within a pty… it’s a bit of a nuclear option, but I’d finally get to make my tab completion work just the way I want it…

    2. 1

      Awesome post, but frightening.

      The code sample after this line “, which means that if you ever hit enter without typing a command:” confuses me, because for me it displays exactly correct. Is that a html issue or am I overlooking something?

      ~/src ➜ echo hi
      ~/src ➜
      ~/src ➜
      ~/src ➜ echo bye
      1. 1

        Er, yeah, this could be more clear in the post.

        The issue is that, on the empty prompt lines, the newline occurs immediately after the arrow. On the lines with actual commands, there is a space after the arrow. The PS1 contains the space, but tmux (or maybe zsh! I don’t know) chomps it off when you hit enter, for some reason.

        1. 1

          yeah that’s what I got from the text, then I selected it and inspected the source to be confused. Overthinking.. but maybe helpful to add some sort of placeholder to show ‘SPACE HERE’ :)