How to go to new line in iTerm2 without executing command?

Don't flag this as duplicate to answers that say append \ because I am not asking for line continuation.

I want something equivalent to Command . from default terminal in ITerm2. I want to treat line as a comment.

Just want to go to a new line without executing. And I don't want to erase the command as well.

$ hello world
$ previous line was not executed and its still there without showing errors
$ ls -la

This has nothing to do with iTerm, but rather the shell that you're using and whether or not the option interactive_comments is enabled or not. To treat the line as a comment, you have to start the line with a comment character.

Bash Reference Manual (Chapter 3.1.3) - Comments

In a non-interactive shell, or an interactive shell in which the interactive_comments option to the shopt builtin is enabled (see The Shopt Builtin), a word beginning with ‘#’ causes that word and all remaining characters on that line to be ignored. An interactive shell without the interactive_comments option enabled does not allow comments. The interactive_comments option is on by default in interactive shells.

$ shopt -s interactive_comments          <-------- Enable interactive_comments
$ shopt -u interactive_comments          <-------- Disable

To make this permanent, put the command in your ~/bash_profile or ~/bashrc. It's enabled by default in Bash

Zsh Reference Manual (Chapter 6.7) - Comments

In non-interactive shells, or in interactive shells with the INTERACTIVE_COMMENTS option set, a word beginning with the third character of the histchars parameter (‘#’ by default) causes that word and all the following characters up to a newline to be ignored

% setopt interactive_comments         <------ Enable interactive_comments
% unsetopt interactive_comments       <------ Disable

To make the setting permanent, place the appropriate command in your ~/.zshrc. It's disabled by default in Zsh.


All Cmd. does is sending CtrlC to the shell running in the current Terminal tab/window.

enter image description here

So you can get the same effect in iTerm2 by just typing CtrlC.

enter image description here