Live data from Hacker News

Bash One-Liners Explained, Part V: Navigating around

catonmat.net

31–35 of 35 posts

Re: Bash One-Liners Explained, Part V: Navigating around

#32
post #22

Earlier quoted context omitted.

You can enjoy the best of both worlds with something like zsh's edit-command-line . I'm very happy with Emacs keys in the shell, unless I need to make a non-trivial edit or type in a multi-line command. In those cases, C-x C-e drops me right into Vim with the current command-line ready for editing.

Anybody know how to do the equivalent of C-x C-e in vim mode?

Try ESC-v.

Re: Bash One-Liners Explained, Part V: Navigating around

#33
I knew most of these, but I learned about Ctrl-# (for commenting a command), and Ctrl-x+Ctrl-u (or Ctrl-/) for undoing changes.

One shortcut that used often is Ctrl-o. When you have a few commands in your history that you want to repeat in that seqeunce, search for the first command in the group, optionally edit it if you want, and press Ctrl-o instead of the ENTER key.

After this command is executed, the next command in the history is presented to you. Press Ctrl-o again to continue the sequence, or press ENTER once you reached the last command in the sequence.

If you want skip a command in the sequence, instead of Ctrl-o just press Ctrl-n (or down-arrow) to get the next one in sequence.

Re: Bash One-Liners Explained, Part V: Navigating around

#34
This seems to be written by someone who has no deep experience. For example, Ctrl-u does only delete the whole line, if the cursor stands at the end of that line, on my system (Ubuntu) this command generally deletes the characters left from the cursor. What's missing, is the complement to this command, which deletes the characters under and right from the cursor, namely Ctrl-k. Everybody who regularly uses Ctrl-u should know that.

Re: Bash One-Liners Explained, Part V: Navigating around

#35

Instead of searching through history, you can add this to your .inputrc "\e[B": history-search-forward "\e[A": history-search-backward And this to your .bash_proflie export HISTCONTROL=erasedups export HISTSIZE=100000 shopt -s histappend Now the up/down arrow keys auto search and complete backwards/forwards based on what's written. If the line is empty, it behaves as normal. This is also pretty neat, in your .bash_pr…

Regarding HISTFILESIZE the man page for bash says:

> When this variable is assigned a value, the history file is truncated

Which I read as meaning if you export the following then you should get infinite entries:

  export HISTFILESIZE=
I'm testing to see if it works for this also:

  export HISTSIZE=
Post reply on HN