Question

Simply put, I know you can do ctrl+v+tab to insert a physically real tab character in a bash statement. But how do I do the same for iTerm?

Was it helpful?

Solution

The answer was to hit control+v, then tab afterwards, not all together! Hope this helps someone.

OTHER TIPS

It's not iTerm, but your shell that affects how you''re able to insert a tab.

First, make sure you're in BASH shell: Type the following command:

$ echo $RANDOM $BASH_VERSINFO
23714 3

The first is a random number, and the second should be the BASH Version number. If you get a blank line or just a random number, you're not in the BASH shell, and that's probably one of your issues.

Another thing is to execute this command:

$ set -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
[...]
privileged      off
verbose         off
vi              off
trace           off

The two lines of interest is the emacs and the vi lines. One of those should be on. If they're both off, you can't do the Ctrl-V-Tab to insert a tab character.

When the vi mode is on, it should be Ctrl-V-Tab like you said. With emacs mode on, it is either Ctrl-V-tab, or possibly Ctrl-Q-tab.

However, this isn't an iTerm thing, this is your shell that's doing it.

If by a "physically real tab character" you mean sending the tab hex code (0x09) to the shell, then you can do this in iTerm by pressing Ctrl + Tab (⌃ ⇥).

This is the default setting, although you can change it (as well as add other hex code values to send) in iTerm > Preferences > Profiles > Keys.

I'm not certain why you're comparing a "bash statement" with iTerm. You write bash scripts in iTerm. Which means, assuming you're writing your scripts in iTerm, you're already doing what you want.

I'll assume you mean scripting in vi vs command line. The way I get literal characters on the command line is by using vi editing mode. Do set -o vi. Then you can use ctrl+v followed by tab in the manner that you're used to.

IMO, using vi editing mode comes with a slew of other pluses like searching your history, faster navigation, etc. So you could just add it to your .bashrc if you wanted and use it all the time.

One should also try Ctl + V Ctl + I. It is working in konsole where Ctl+V+Tab deosn't work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top