The Computer Oracle

What's the meaning of the "set -o emacs" command?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Industries in Orbit Looping

--

Chapters
00:00 What'S The Meaning Of The &Quot;Set -O Emacs&Quot; Command?
00:19 Accepted Answer Score 13
01:16 Thank you

--

Full question
https://superuser.com/questions/562182/w...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#bash #emacs

#avk47



ACCEPTED ANSWER

Score 13


set -o emacs tells the shell to understand Emacs editing commands.

That is, you can use Emacs commands at your shell prompt and they will work as expected. For example:

  • CtrlK deletes a line.
  • CtrlT transposes two chars.
  • MetaP deletes a word.
  • CtrlP goes to the previous line, that is, the previous command.

(More commands here, note that not all will work because not all make sense at the command line.)

set -o emacs works with bash, ksh and zsh, the default shell starting with macOS 10.15 Catalina. Other Bourne-based shells may include this functionality, too.

For bash and zsh, emacs is the default editing mode. You can also choose vi mode with set -o vi (in this case, you will probably want to set Option as the Meta key in the Keyboard tab of your Terminal profile).