Control-C vs Control-D
When starting to use the terminal, it’s inevitable that you come across running
a command that remains running and the direction is to press Control-C
to
stop it.
And sometimes, you may be directed to press Control-D
.
But what’s the difference? Why did one work one time and not the other?
A simple question you can ask yourself:
Has the command prompted for input?
Demonstration time
So, does this command prompt for input?
$ npm start
> school-locator@0.1.0 start /Users/travis/work/tps/school-locator
> react-scripts start
Starting the development server...
Compiled successfully!
You can now view school-locator in the browser.
Local: http://localhost:3001/
On Your Network: http://192.168.1.65:3001/
No. It’s just a running development server. So Control-C
.
^C
Think of it as “Cancel”.
Let’s try another.
Does this command prompt for input?
$ pgcli
Server: PostgreSQL 13.0
Version: 3.0.0
Chat: https://gitter.im/dbcli/pgcli
Home: http://pgcli.com
travis@/tmp:travis>
Yes. It’s expecting me to input some SQL queries. So Control-D
.
^D
Goodbye!
I don’t have a handy mnemonic but I remember it as part of the C
/D
pair.
To re-enforce using Control-D
to quit a prompt, consider a typical
terminal: It’s a prompt, and waiting for your input.
$
^D
My iTerm2 window closed. But Terminal.app may just say:
[Process completed]
Summary
Control-C
if it’s just running, doing it’s thing.Control-D
if it’s waiting on you.
References
#JustCommit
Today I'm stepping out of my comfort zone and committing to doing lightning talks at Tulsa Web Devs. After last nights meeting, while others were doing so, I realized that I should also be sharing the things that interest me. Maybe someone else will find something I have to say interesting.