![]() ![]() Set -o viinto the shell, to put it in vi mode temporarily. But instead of :x or :wq to save and quit, you just hit enter when the command looks right. Most vi "visual" commands work as you would expect. When the shell is reading lines in vi mode, you just hit escape and your shell prompt turns into a one line vi window. Each of those things will remember your typing-into-them history. The Bash shell, the Python interactive interpreter, the mysql "monitor," even the lowly FTP client. Set editing-mode viAny program that uses the GNU Readline library will now read lines in vi mode, not emacs mode. So the first thing I do with a new Linux system is add this line to /etc/inputrc Its visual command language is in muscle memory. I've been using vi (elvis, nvi, vim.) since it was new. I use that reverse history search all the time. ![]() The ability to locate and reissue commands is extremely useful, especially when recovering a rarely used command or a command that was hard to create in the first instance. ![]() With a little practice all the above approaches become quite instinctive to use and can make your terminal session more powerful and efficient. There may come a time where you need to keep a command out of your history, and if that scenario ever occurs, all you need to do is preface the command with a single press of the spacebar.įor example here are two ls commands, the second has a single space, hiding it from the history file. sudo !! Hiding Your Commands from Linux History In the following example we append the first ls command to be reissued with sudo. To do this we can preface the previous command with sudo. Sometimes we may try to reuse a command that requires elevated privileges, for example editing a file outside of our home directory. Note that the previous command is listed and performed. Run the ls command to set this as the example to test. We can achieve this simply using the !! command.ġ. Often we will want to simply rerun the last command we issued. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |