Live data from Hacker News

Ask HN: What do you love/hate about terminals? Would you change them?

news.ycombinator.com

181–190 of 204 posts

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#181
I spent yesterday rewriting my ZSH config. A lot of the time I spent on figuring out how to map random key combos to unused control characters. So if I could implement both the terminal and the shell from scratch (or make a significant addition), I would implement a scenario like this:

  1. Program informs the terminal that it supports "extended keyboard input". This would be done with an escape code, much like bracketed paste.
  2. Terminal informs the program that it is now enabled.
  3. Terminal informs the program of the initial modifier key state.
  4. When the user presses a key (including modifiers), it is sent in a format that standardizes over all the commonly used key codes. Also, if the key represents a Unicode codepoint, that is sent as well. E.g. (mod-status-at-key-press)(key-code)(utf8-char-or-null)(null-terminator).
  5. When the user releases a key, a similar message would be sent.
  6. When the program exits (or a shell runs another program), it asks the terminal to disable "extended keyboard input"

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#182
post #64
post #42

Earlier quoted context omitted.

changing terminal-titles is just a google search away. or perhaps i am missing something fundamental. may you please elaborate? thanks!

Yes I'm aware of the ansinescape sequence to _set_ the termtitle. But you can't _restore_ previous termtitle without knowing them (or existing current program). In my case with IPython I want a termtitle that say "busy" when computation is in progress otherwise get back to it's initial value of before starting IPython. I can't do that, because I would have to exit my IPython shell for bash to set the previous value.…

> Without a getter (which is a security issue) or introducing global state or passing the values all around you can't set a temporary value for the title. Is that clearer ?

yes, it is. thank you ! one simple solution might be to wrap this thingy within an 'xprop(1)' invokation. for example, i can do the following:

    signal11@fatcat networking % xprop -id 0x2c00022 | grep WM_NAME
    WM_NAME(STRING) = "fatcat:~/source-code/c/networking"
    signal11@fatcat networking % cd ~/source-code/c/quick-hacks 
    signal11@fatcat quick-hacks % xprop -id 0x2c00022 | grep WM_NAME
    WM_NAME(STRING) = "fatcat:~/source-code/c/quick-hacks"
    signal11@fatcat quick-hacks % 
WM_NAME(STRING) points to the current title. and when i change the directory, i can query the new name. fitting this mechanism for aforementioned usecase is left as an exercise for the reader :) fwiw, the value for '-id' argument comes from 'xwininfo(1)'

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#183

Earlier quoted context omitted.

While plain `cat` does not work, using escape sequences and providing support in the terminal emulator allows already to display images inline. See the iTerm2 implementation here: https://www.iterm2.com/documentation-images.html Making plain `cat` work too should not be too big of a problem with some small support from the running shell. iTerm2 also knows when a command is starting to run/exits, parsing the output it…

Then it's not cat anymore. The purpose of cat is to output the inputs unchanged and concatenated. If you need magic, that's a task for another program.

`cat` is doing exactly that. It is up to another program, namely the terminal emulator to interpret its output.

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#184

I think that the autocomplete story is abysmal. Modern IDEs can tell me exactly what can follow after a certain piece of text, and even the best tab completion in terminals is limited, ugly, and text-mode for no good reason. Some protocol for a real dropdown rendered in the style of the OS, plus a standard data format that allows tool builders to specify options, their meanings and the kinds of allowed parameters in…

You might be interested in this: https://news.ycombinator.com/item?id=15138613

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#185

Earlier quoted context omitted.

Then it's not cat anymore. The purpose of cat is to output the inputs unchanged and concatenated. If you need magic, that's a task for another program.

`cat` is doing exactly that. It is up to another program, namely the terminal emulator to interpret its output.

The terminal emulator does not (and should not, according to my strong opinion) interpret the output of different programs differently.

In fact it's not currently technically possible for a terminal emulator to know which program is writing into it. It maybe many programs simulatenously, or it may be the kernel asynchronously, etc... If you want to change that you would have to make the architecture tremendously more complicated and less flexible.

And the same goes for shells. You don't want to complicate the architecture just so that a lawyer could attest you that "it was cat" who drew the image und some weird interpretation. Nothing would be gained, and nobody would be able to understand what's happening anymore.

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#186
post #64

Earlier quoted context omitted.

Yes I'm aware of the ansinescape sequence to _set_ the termtitle. But you can't _restore_ previous termtitle without knowing them (or existing current program). In my case with IPython I want a termtitle that say "busy" when computation is in progress otherwise get back to it's initial value of before starting IPython. I can't do that, because I would have to exit my IPython shell for bash to set the previous value.…

> Without a getter (which is a security issue) or introducing global state or passing the values all around you can't set a temporary value for the title. Is that clearer ? yes, it is. thank you ! one simple solution might be to wrap this thingy within an 'xprop(1)' invokation. for example, i can do the following: signal11@fatcat networking % xprop -id 0x2c00022 | grep WM_NAME WM_NAME(STRING) = "fatcat:~/source-code/…

That is a nice hack thanks! Though it is not really portable to all OS, and AFAIU not working if you ssh to a remote host ! It may give a potential way to work partially around that limitation. I feel like an actual push/pop solution would be better.

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#187

Earlier quoted context omitted.

> Without a getter (which is a security issue) or introducing global state or passing the values all around you can't set a temporary value for the title. Is that clearer ? yes, it is. thank you ! one simple solution might be to wrap this thingy within an 'xprop(1)' invokation. for example, i can do the following: signal11@fatcat networking % xprop -id 0x2c00022 | grep WM_NAME WM_NAME(STRING) = "fatcat:~/source-code/…

That is a nice hack thanks! Though it is not really portable to all OS, and AFAIU not working if you ssh to a remote host ! It may give a potential way to work partially around that limitation. I feel like an actual push/pop solution would be better.

> ... and AFAIU not working if you ssh to a remote host !

X being a network protocol at heart, it positively is weird. i tried that thingy on both local machine, and ssh'ed xterm to remote-machine (with X sessions correctly forwarded locally), and it all seems to work just fine for me.

edit-001 : these are linux machines at both ends, so, i dunno...

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#188

I would like to be able to use modifier/control keys over terminal similarly to GUIs, e.g. use Shift+arrows to mark text, impossible on current terminals. I guess transmitting the state of all modifier keys with every keystroke would be a simple fix.

It has been possible on terminals for about three decades -- since the DEC VT220 at least.

Applications know when shift+arrow is pressed because they receive a different control sequence. Modifier keys are reported as an extra parameter in the control sequence for function keys and extended keys. Dickey xterm has been doing the same since 1999. The PuTTY changelog does not indicate when it gained this, but it has had it for years, too.

* http://invisible-island.net/xterm/xterm.log.html#xterm_94

And indeed you will find that TUI applications such as VIM and NeoVIM recognize these control sequences and can distinguish arrow from shift+arrow. See :help cursor-up and (on VIM) :help xterm-modifier-keys . (NeoVIM handles the TUI differently, is terminfo-only, and has modifier recognition always on.)

If some other application does not, then it is not the terminals that need fixing.

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#189

Earlier quoted context omitted.

That is a nice hack thanks! Though it is not really portable to all OS, and AFAIU not working if you ssh to a remote host ! It may give a potential way to work partially around that limitation. I feel like an actual push/pop solution would be better.

> ... and AFAIU not working if you ssh to a remote host ! X being a network protocol at heart, it positively is weird. i tried that thingy on both local machine, and ssh'ed xterm to remote-machine (with X sessions correctly forwarded locally), and it all seems to work just fine for me. edit-001 : these are linux machines at both ends, so, i dunno...

Yes, I'm on Mac OS so that's likely it, and the server I was trying had no X anyway. Thanks for investigating.

Re: Ask HN: What do you love/hate about terminals? Would you change them?

#190

I don't know if it's solvable at the terminal level only, but I would love a terminal that never gets messed up so that I never have to type reset or close the window and open it up again.

It was solved more than six years ago. The cost is that you lose support for applications that make use of switchable 7-bit character sets: on the gripping hand a price that most people seem willing to pay nowadays.

* https://news.ycombinator.com/item?id=16014824

Post reply on HN