^U will clear the buffer - super convenient for retrying botched passwords.
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.
What typing ^D does on Unix (2009)
101–110 of 162 posts
Re: What typing ^D does on Unix (2009)
#102As a corollary, typing ^D twice on a non-empty line will also send EOF on the input, allowing you to provide a program with input not ending with \n from the command line. I knew about this behavior, but not why it worked, but this article's explanation clarifies this behavior as well. The first ^D terminates the read() call, passing the line so far, without terminating \n, to the program. The second causes read() to…
http://stackoverflow.com/questions/15666923/sys-stdin-does-n...
Re: What typing ^D does on Unix (2009)
#103Earlier 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.
For the vi-adherents out there, `set -o vi` will let you navigate your prompt and history with vi-like keybindings. I'm amazed by how many vi users don't know this.
Re: What typing ^D does on Unix (2009)
#104Earlier 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.
To add to that, C-P will go up in your history and C-N down. It is extra useful when using GDB in TUI mode (which is activated using C-x,a), which will capture your UP/DOWN arrow to navigate the source... Actually, just go read http://ss64.com/bash/syntax-keyboard.html or something, once per day, integrate a new one each time, and you will improve your productivity on the command line (as well as comfort).
Nice link - reminds me to try to use the history stuff like ! and ^ more.
Re: What typing ^D does on Unix (2009)
#105Neat. So when my terminal is spewing output because I ran "cat massivefile" instead of "cat massivefile | head", I can hit ctrl-D to stop it instead of repeatedly hitting ctrl-C and despairing.
Here's the rest in one place:
eof VEOF EOF character
eol VEOL EOL character
eol2 VEOL2 EOL2 character
erase VERASE ERASE character
erase2 VERASE2 ERASE2 character
werase VWERASE WERASE character
intr VINTR INTR character
kill VKILL KILL character
quit VQUIT QUIT character
susp VSUSP SUSP character
start VSTART START character
stop VSTOP STOP character
dsusp VDSUSP DSUSP character
lnext VLNEXT LNEXT character
reprint VREPRINT REPRINT character
status VSTATUS STATUS character
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = ;
eol2 = ; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
stop = ^S; susp = ^Z; time = 0; werase = ^W;Re: What typing ^D does on Unix (2009)
#106Earlier quoted context omitted.
^\ is actually sigquit, which is a bit different from sigkill, since programs can catch QUIT and perform some cleanup.
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?
If it's part of a script, your script probably wants to trap SIGINT.
Re: What typing ^D does on Unix (2009)
#107Earlier quoted context omitted.
+++ATH0
How did modems deal with pluses in data? Was there a way to escape the escape sequence, or was there just an ATSnnn or similar sequence to disable escapes?
Many years ago, modem maker Hayes Microcomputer Products held a patent dealing with that issue. The clever bit was in looking for
+++
to effect the escape.Hayes tried to collect royalties, but this caused quite a kerfuffle. Cheap modem makers didn't bother looking for pauses. "Hilarity" ensued. Other solutions were found.
https://en.wikipedia.org/wiki/Time_Independent_Escape_Sequen...
Re: What typing ^D does on Unix (2009)
#108Earlier quoted context omitted.
It is also very convenient to remap up/down keys to not just list history, but to do completion based on already typed characters: if [[ $- == *i* ]] then bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward' fi (fix: grammar)
Debian and Ubuntu typically have a commented-out mapping for this in /etc/inputrc as pgup/pgdn that I always enable in my ~/.inputrc. Editline supports something similar in .editrc IIRC.
What's the point to type a half-command and then replace input line with one from history if I press up? That somewhat resembles ugly cmd.exe, which every windows user imagines when someone says 'cli'.
Re: What typing ^D does on Unix (2009)
#109I wish articles like this would say what ^D means. I remember when I was new to Unix it took me a while to realize that I wasn't supposed to type a literal caret (^) followed by a D. For reference it means Ctrl+D, unless you you have a strange keyboard from Sun or something.
Reminds me of how many time I went crazy trying to close a telnet session on memcached ("Escape character is '^]'.") :)
So many games don't even allow you to open the console, because they assume that your key next to 1 is ~, and so don't work for § (next to 1) or altgr+¨ (the layout's ~). Or switch between looking at characters or scancodes depending on the context, and thus work in some cases but not all.
Re: What typing ^D does on Unix (2009)
#110Earlier 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+\?