CuTt3: Useful terminal shortcuts II

Copper’s Tips & Tricks #3: Useful terminal shortcuts

Note: I use iTerm. If you’re here you’re probably computer savvy enough to adapt the instructions to your terminal tool of choice.

Miraculously (or through the hard work of people who thought a lot about things in the past) bash has the integrated ability to move word by word, delete word by word or line by line, and move to the beginning and end of a line, much like on any other text editor. However, while you’d expect that by 2017 it’d be smart enough to use the current keyboard shortcuts that are used everywhere else by default, it’s not smart enough to use the current keyboard shortcuts that are used everywhere else by default. So, to fix that:

In order to move forwards a word at a time, you need to press ESC+f (*Insert Jackie Chan WTF face here*)

In order to move backwards a word at a time, you need to press ESC+b

With that knowledge, you can go ahead and add that to your iTerm shortcuts; for the uncunning, there’s a screenshot of dubious usefulness as the featured image of this post.

Note: To be honest, some servers do this by default (I assume by editing .bashrc or a similar file?), like the one we have at the office, but none other that I’ve SSH’d to has. And the terminal on my up to date Mac doesn’t, so it’s better to be safe than sorry and add this shortcut to iTerm, so it’s available/working everywhere.

What’s that? I mentioned deleting words as well? Oh right, of course. The difference for these ones is that these aren’t inputtable by keyboard (I think, I mean I could be wrong and you can maybe have a keyboard that sends custom hex codes if you want but you’d be in an uncomfortable minority in that case and why are you reading this?), they’re hex codes:

In order to delete a word at a time: 0x17

In order to delete a line at a time: 0x15

On Macs on iTerm, you can press fn+left or fn+right to move to the start or end of a command respectively. If you’re unlucky, poor, a hipster, unique, or similar category, you can use these hex codes instead:

In order to move to the beginning of a line: 0x01

In order to move to the end of a line: 0x05

Happy terminal moving/deleting/whathaveyou!

Source: https://coderwall.com/p/ds2dha/word-line-deletion-and-navigation-shortcuts-in-iterm2
Recursive source: http://stackoverflow.com/questions/15733312/iterm2-delete-line
Source: https://coderwall.com/p/h6yfda/use-and-to-jump-forwards-backwards-words-in-iterm-2-on-os-x

Don’t Stop Here

More To Explore