

There’s a great cheat sheet on emacs readline commands at /emacs, which is a very useful reference if you want to dig deeper. You can enter this mode with set -o vi, I’ll likely come back to this in detail in a later article. There is in fact a ‘Vi Mode’ option for readline, which allows you to use vi commands to work with text. This means everything you’ve learnt applies to:Īll of these shortcuts should be familiar to Emacs users. The great thing about learning these shortcuts is that they will work in any prompt which uses GNU Readline. You can actually configure lower level details of how all shells which use readline work, with the. If you are ever looking to go deeper, then search the web for GNU Readline, which is the library used under the hood to handle the command line in many shells. I can’t see myself ever being able to remember the commands more quickly than just deleting the last two words or characters and re-typing them, but there you go! Closing Thoughts These were new to me when I was researching for this article.

Use Ctrl + t to transpose the last two letters: The Alt + t shortcut will transpose the last two words. If you’ve mastered all of the commands here and feel like adding something else to your repertoire, try this: This is an extremely useful command to use if you forget the specific keyboard shortcuts, or just want to see the shortcuts which are available. You can use the bindkey command to see a list of all keyboard shortcuts: $ set-mark-command Probably the shortcut I use the most is Ctrl + l, which clears the screen without trashing your current command.
#Licecap mobile how to
In a later article I’ll talk a little more about how to configure the default editor. Use Ctrl + x, Ctrl + e to edit-in place: These tips and tricks are helpful, but if you are working with a really long or complex command, you might find it useful just to jump into your favourite editor. Here are the same commands applied to the original example: Action Use the arrow keys to edit the command, press enter to execute it, or Ctrl + g to cancel the search. This is useful for searching in the current command, but can be also used to quickly search backwards and forwards through the command history:Īs you type, your command history is searched, the most recent commands coming first. This will search in the current command and then iteratively through previous commands: You can search backwards or forwards with Ctrl + r and Ctrl + s. Let’s assume we’ve run the following three commands: $ command1 param1 param2 param3 Once you have the basic navigation commands down, the next essential is searching. Select “Esc+” for the Left Option Key.įor Terminal, go to Profiles Tab > Keyboard Tab > check “Use Option as Meta key” at the bottom of the screen. There, you should see Left Option key and Right Option Key with three radio buttons. Note that if you are on a Mac, you might need to tweak your console to allow the ‘Alt’ key to work.įor iTerm2, go to settings (Command + ,) > Profiles Tab > select the profile you are using > Keys tab. Navigating around long lines of text is a slow process if you are only relying on the arrow keys, so take the time to learn the following shortcuts: Action Let’s assume we have a very simple command we are writing, which is going to write a quote to a text file:Įcho "The trouble with writing fiction is that it has to make sense,

This article, examples and diagrams are available at /dwmkerr/effective-shell. Here’s a quick reference diagram, the rest of the article goes into the details! In this article I’ll show some simple tricks for working with the command line more effectively. As you start to do more and more in the shell, text in the command line can quickly become hard to handle. I can’t think of a better place to start than navigating the command line. Part 7: The Subtleties of Shell Commands.Part 6: Everything You Don’t Need to Know About Job Control.Part 5: Interlude - Understanding the Shell.
#Licecap mobile series
This is the first part of a series I am writing which contains practical tips for using the shell more effectively.
