Ctrl-D for REPLs always bites me with GHCi. My usual approach to quitting GHCi is: - Press Ctrl-D, like normal - Get confused when nothing happens - Remember that it doesn't work in GHCi, so run `:q` instead - Get an error message about "lexical error at character '\EOT'", due to Ctrl-D inserting an invisible char at the start of the input - Try `:q` again, without any invisible prefix - GHCi successfully quits
You think that's hard, try getting out of vi when you're on a keyboard from an unfamiliar country.
"Rules" that terminal programs follow
61–70 of 153 posts
Re: "Rules" that terminal programs follow
#62> rule 3: REPLs should quit when you press Ctrl-D on an empty line If memory serves, this behavior depends on the OS. On Windows I believe the norm there is to type " "
Re: "Rules" that terminal programs follow
#63“rule 5.1: Ctrl-W should delete the last word […] I can’t think of any exceptions to this other than text editors but if there are I’d love to hear about them!” mysql(1) only links to editline instead of readline, where Ctrl-W by default deletes everything to the start of the line, not just the last word. It drove me mad in the period where I had to use it; you just see your entire nice query disappear. :-)
It could be worse! Back in college, I had the misfortune to decide to try to use sqlplus, Oracle's CLI to try to connect to their database. Not only did terminal shortcuts like Ctrl-W not work at all, but you couldn't even move the cursor earlier in the line, and there was no history navigation to get to the previous command, so any typo forced you to retype the entire thing from scratch. Entering a single forward sl…
On Unixes of course, don't know what VMS/MVS/.... did.
Re: "Rules" that terminal programs follow
#64Ctrl-D for REPLs always bites me with GHCi. My usual approach to quitting GHCi is: - Press Ctrl-D, like normal - Get confused when nothing happens - Remember that it doesn't work in GHCi, so run `:q` instead - Get an error message about "lexical error at character '\EOT'", due to Ctrl-D inserting an invisible char at the start of the input - Try `:q` again, without any invisible prefix - GHCi successfully quits
Re: "Rules" that terminal programs follow
#65I just checked to see if Ctrl-F and Ctrl-B work, and found that the former kills one word forward and the latter acts like Ctrl-W ought to?
Re: "Rules" that terminal programs follow
#66Additional suggestions: * Respect the user's default foreground and background color. Don't change them without good reason. * If you use colors, make them legible regardless of what the default background and foreground colors are, and regardless of the terminal's color map. * Don't use color as the only indication of something. The user's terminal might not display it, and it probably won't be preserved in copy&pas…
Re: "Rules" that terminal programs follow
#67 func main() {
if _, err := os.ReadFile("~/.bashrc"); err != nil {
log.Fatal(err)
}
fmt.Println("ok")
}
Meanwhile over in shell land: $ echo ~/~/~
/home/jrockway/~/~
The behavior is actually kind of amazing.I mention it because while "yourprogram ~/path/to/file" always works, having a repl that asks for a filename might not work. I've seen a lot of software where this DOES work, so I think it counts as a "most TUI programs do this" thing.
Re: "Rules" that terminal programs follow
#68I'd add "long-running processes should reload their configuration on SIGHUP". :)
Re: "Rules" that terminal programs follow
#69What does "cooked" mode mean in the context of this article?
Raw means send characters immediately, literally. Cooked imply some some of the flags are on, specifically (from memory) icanon, echo, among the `lflags`. Plus others.
Further down among `cchars` you'll see werase = ^w and kill = ^u. Here kill means kill (erase) the line, not send a signal.
Re: "Rules" that terminal programs follow
#70I'd add "long-running processes should reload their configuration on SIGHUP". :)