Live data from Hacker News

What typing ^D does on Unix (2009)

utcc.utoronto.ca

141–150 of 162 posts

Re: What typing ^D does on Unix (2009)

#141

Earlier quoted context omitted.

Also ^| (as in, "control pipe") which is a synonym for ^\. At least for me, | is faster to hit than \ And since we're on this topic: if I write a for loop in bash that runs a slow command 1000 times (ImageMagick comes to mind), and I realise something has gone wrong, is there an easy way of breaking the outer loop?

> Also ^| (as in, "control pipe") which is a synonym for ^\. At least for me, | is faster to hit than \ How? Do you have a keyboard where | isn't Shift+\?

I have a Norwegian keyboard, where as you can see, pipe has its own key to the left of "1" (above Tab):

https://en.m.wikipedia.org/wiki/File:Keyboard_Layout_Norwegi...

Re: What typing ^D does on Unix (2009)

#142
post #74

Earlier quoted context omitted.

Something I use extensively in terminals is ^L and ^M. ^L clear the screen and ^M for a line return.

May I ask why you find more convenient to press ^M for a line return instead of the line return key?

As someone else who also uses ^M for line return here's my reason.

I have the Caps key mapped to control, so ^M is 2 small finger movements as opposed to reaching for the return key which means either moving my (weak in my case) right wrist or moving my whole right forearm. It's a small movement to the return key but I find eliminating it really helps to reduce strain related pain when typing.

I also use ^H for backspace and ^I for tab for similar reasons. This also keeps my fingers on the home row.

Re: What typing ^D does on Unix (2009)

#143
post #54

^U will clear the buffer - super convenient for retrying botched passwords.

Fun trick: If somebody is watching you type in your login password or SSH pubkey password, spaz wildly on the keyboard, frantically typing random characters, and then hit ^U and type in your real password. Then you give them a puzzled look once you successfully log in as if nothing out of the ordinary just happened and say something like "What, don't you have a sufficiently complex password?".

> "What, don't you have a sufficiently complex password?"

I actually had a sufficiently complex password, but this one time I was in a massive hurry to demo something to my teammates, I made a mistake somewhere near the end of it, quickly typed ^U, fed it all over again, made another mistake near the end, another quick ^U, and third time was the charm.

They didn't notice that I reset the password field twice, to them it was just a mega-super-duper-long password (the actual password is 20+ characters), and one of them burst out saying, "Woah! He just wrote a short story!"

Re: What typing ^D does on Unix (2009)

#144

Earlier quoted context omitted.

... There's a program called SSH to get to another CPU. Tilde is the escape, it's doubled to send it through, And "quit" is tilde-. I think you know how the rest goes...

What does this reference?

I am not sure, but it looks vaguely familiar. There is a text-based game called adventure game called Dunnet where you come across a CPU card, and do some stuff with it later on. As far as I remember, the game predates SSH, so the game either had Telnet or FTP. My memory fades.

Re: What typing ^D does on Unix (2009)

#145
post #13

Earlier quoted context omitted.

So ^U will let a partial password linger in memory longer than it needs to if you use it as suggested by the GP?

To elaborate on yebyen's answer: these shortcuts can be handled in different layers of your stack. By default, ^U will be handled by your terminal emulator, and it will only delete the buffer, it won't remember what you've deleted. However, programs can ask the terminal emulator to pass ^U through to them so they can handle it themselves. This happens if you use libeditline (or libreadline), and these libraries imple…

Actually, NAK in canonical mode is handled by the line discipline in the pseudo terminal device rather than by the emulator.

Re: What typing ^D does on Unix (2009)

#146
post #15
post #13

Earlier quoted context omitted.

So ^U will let a partial password linger in memory longer than it needs to if you use it as suggested by the GP?

No, I don't think so. Not unless you are accustomed to typing your password directly into the terminal prompt. Kill buffers don't pass from one application to another and they don't all behave the same in every context, either. (For example, if I type some stuff and then ^U to kill the password buffer at an SSH password prompt, typing ^Y after that seems to put the whole process in the background. Not sure what that'…

In canonical mode, EM is the usual "delayed suspend" special character.

Re: What typing ^D does on Unix (2009)

#147
post #43

Earlier quoted context omitted.

^D, Ctrl+D and C-d are all different ways of saying the same thing. There's nothing particularly neutral about Ctrl+D, any more than there is about using the word 'water' to mean the substance of which the oceans are mostly comprised — it's just another dialect's term.

The button on the keyboard literally says "control" or "ctrl" on it. How could that possibly not be easier to figure out than "^" or "C-"?

Look at the confusion that surrounds "Strg" for this very same key.

Also note that on some keyboards it has the U+2638 character engraved.

Re: What typing ^D does on Unix (2009)

#148
post #83

Earlier quoted context omitted.

You're incorrect, especially for the typical reader here. A good chunk (maybe not over 50%, but its gotta be close) of the regular readers on this site use Macs. Most Mac keyboards, including the ones on the Macbook Pro, spell it out. Same for most non IBM/IBM-PC compatible keyboards.

I'm typing on a MacBook Pro that has "ctrl". Not sure I've ever seen a Mac keyboard that said "control", but maybe that's because I've mostly seen Finnish keycaps.

Enjoy this picture of an Apple keyboard that says "control": https://commons.wikimedia.org/wiki/File:Apple_Keyboard.JPG

Re: What typing ^D does on Unix (2009)

#149
post #40
post #25

Earlier quoted context omitted.

In readline, ^U will only clear from the cursor to the start of the line, leaving anything on the right. ^K is the converse. I'm not sure you are speaking about readline though. Another very useful thing I use daily is Alt-F/B, to move forward/backward in the line one word at a time. Control does the same, one letter at a time. D will delete an element instead.

There's a lot of unexpected gems in the readline defaults. I recommend people try paging through "bind -p" in bash some time to see what's there. Personal favorites are C-r to search back in history and C-x C-e to edit the current command line in an external editor.

Yes some of these useful functions should be bound by default IMHO. Here are my settings to bind ctrl-{left,right} and {up,down} to more useful defaults. I.E. jump as the shell tokenizes the line, and search history for what's already typed respectively

Re: What typing ^D does on Unix (2009)

#150

Earlier quoted context omitted.

... There's a program called SSH to get to another CPU. Tilde is the escape, it's doubled to send it through, And "quit" is tilde-. I think you know how the rest goes...

I don't - and in fact I finally got around to creating a HN account in order to ask you. Googling that just leads me back to this discussion. What's it from?

It's parodying "the TELNET song," by Guy L. Steele.
Post reply on HN