Sunday, October 18, 2015

Deleting a line or word in iTerm2

In OSX, ⌥+⌫ and ⌘+⌫ are the shortcuts for deleting a word and deleting a line respectively. ⌘+ ← and ⌘+ → are for going to the beginning and end of lines. By default, iTerm2 isn't configured this way, and there are a lot of misleading guides online. The following is what I've found to work on my machine.

1. Open the preferences (⌘+,) and go to the Keys tab.
2. Add a global shortcut key, and just type in your shortcut
3. In the Action dropdown, select Send Hex Code

The hex codes for...

* Deleting a word: 0x17.
* Deleting a line: 0x15.
* Moving to the beginning of the line: 0x01.
* Moving to the end of the line: 0x05.

Just open a new tab, and it should work!

Here is a screenshot, for clarity. [Picture]

Shortcuts to go to line starting and end in iTerm2

Here are the shortcuts that will work in Terminal app.

Home: control + A

End: control + E

Next Word: esc, then f

Previous word: esc, then b

How to rename the tab name in iTerm2

I like this one:

#setup terminal tab title
function title {
if [ "$1" ]
then
unset PROMPT_COMMAND
echo -ne "\033]0;${*}\007"
else
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'
fi
}
title


It will let you toggle the name of a tab between a custom name and a default of your CWD.

title -> your tab title will be ~/YOUR_CWD/

title hey there -> your tab title will be hey there

How to a command to multiple tabs in Iterm2

iTerm 2 is a replacement application for the default terminal on OSX. It's highly popular due to allowing advanced features such as tabs, split panes, simpler theming and custom keyboard bindings.

[iTerm 2 split panes]

If you find the need to enter the same commands into multiple panes at the same time, simply hit "⌘Command + ⇧Shift + I". You will recieve a small notification about sending input to all panes, the next text you type will physically begin typing into all open panes for your current tab and is executed once you hit "⏎ Return".

Pretty neat!.

Thanks & Regards,
RK