Live data from Hacker News

Shortcuts to Move Faster in Bash Command Line

teohm.github.com

21–26 of 26 posts

Re: Shortcuts to Move Faster in Bash Command Line

#22
post #7

Earlier quoted context omitted.

Beat me to it. (My first thought upon seeing the headline was, "wow, faster than vi mode?") I haven't actually put the set into my .bashrc yet, I just end up typing it when I realize I'm about to navigate a lot.

Semi-related, but what's the fastest vi way to get to the space right after the first word? For example, I might type > ls /etc/foo/bar and have my cursor at the end when I realize I want to type ls -l instead. I know there's got to be a faster way than what I'm currently doing, but I'm blanking. (Yes, I know sometimes tacking on the command line switch at the end will work, but that's not true for all commands).

Shift-T (the opposite of up`t`o) and then `s`.

You can hit `;` if there are multiple incidences of 's'.

Re: Shortcuts to Move Faster in Bash Command Line

#23
post #7

Earlier quoted context omitted.

Beat me to it. (My first thought upon seeing the headline was, "wow, faster than vi mode?") I haven't actually put the set into my .bashrc yet, I just end up typing it when I realize I'm about to navigate a lot.

Semi-related, but what's the fastest vi way to get to the space right after the first word? For example, I might type > ls /etc/foo/bar and have my cursor at the end when I realize I want to type ls -l instead. I know there's got to be a faster way than what I'm currently doing, but I'm blanking. (Yes, I know sometimes tacking on the command line switch at the end will work, but that's not true for all commands).

jj0W

that should work for commands without spaces in them.

I remap jj to escape so it is faster than moving my hand.

in ~/.inputrc

  set editing-mode vi

  $if mode=vi
      #normal mode
      set keymap vi-insert
      "jj": vi-movement-mode
  $endif

Re: Shortcuts to Move Faster in Bash Command Line

#24

One of my most life-changing bash configurations is having history-search-backward / history-search-forward bound to the up and down arrows. Put the following in your ~/.inputrc "\e[A": history-search-backward "\e[B": history-search-forward "\e[C": forward-char "\e[D": backward-char set show-all-if-ambiguous on set completion-ignore-case on Now if you type, say: cat You will cycle through commands in your history tha…

I use this with the fish shell, and it seems to do a better job of searching than the ^R in bash. Not sure of the difference, but I think bash only searches from the front of the string.

Re: Shortcuts to Move Faster in Bash Command Line

#25
post #17

Earlier quoted context omitted.

"cd -"

This is much more sophisticated than just jumping back to your previous directory. It keeps a weighted history of dir's you cd into most and uses those first for autocompletion etc.

I know. "cd -" is available on every system I use, though.

Re: Shortcuts to Move Faster in Bash Command Line

#26

Also install the awesome autojump: https://github.com/joelthelion/autojump If I was previously sitting in directory: ' /home/user/code/github.com/cookbooks/cassandra/recipes ' and I wanted to jump back to that dir from anywhere on the file system I could just type ' j cass rec ' and it would autocomplete and jump to this location. Super helpful.

Or fasd, a derivative
Post reply on HN