DEV Community

Discussion on: Stop pressing the up (arrow) to find a previous command

Collapse
 
wulymammoth profile image
David • Edited

You're not wrong, ProDigit. On most keyboards, it's a bit of a stretch to reach for the left ctrl with one's pinky. You'll have to decide for yourself whether this is more difficult than moving your entire right hand off the home row of your keyboard to the arrow keys unless you've remapped. What if you need to edit the previous command? Your hand is now oscillating between your jkl; keys and the arrow keys. I'm often modifying the argument to my previous command either because I made a typo or I when I need to edit it

$ gt commit -am WIP
-bash: gt: command not found

Many will perform the following sequence of actions:

  1. move hand off onto arrow keys
  2. press the up arrow
  3. hold the left arrow until arriving at the letter t, maybe miss it because key-repeat was cranked all the way up to adapt to these slow scenarios (especially for typos in long commands)
  4. type the letter i
  5. hit enter

Alternatively...

  1. ctrl-p
  2. ctrl-a
  3. option-f
  4. ctrl-w
  5. type git
  6. hit enter

One additional step, but I can almost guarantee that this is faster and more precise than less keys and trying to eyeball and correct for inaccuracy

Lastly, this is actually far easier for a subset of us that are touch typists, but we typically also have some or all of the following configurations:

  • caps-lock is mapped to ctrl (to reduce the pinky reach) as it's a fairly useless key (like really used less frequently than almost any other key on the keyboard)
  • I have a 60% keyboard which does not have arrow keys at all, but this is a trade-off I've made for portability

If you've read beyond the first tip, everything that I've mentioned is about efficiency in one's terminal and shell, but use your own discretion.

Collapse
 
prodigit80 profile image
ProDigit • Edited

I don't know. Click 3 times up, and then enter,
Or click multiple times ctrl + p and then enter.
Arrow keys also are faster when you need to modify the command. You can immediately go to the end, middle or beginning with left/right arrows right next to it.
I prefer the arrows, and for anything else ctrl + R.
The only way I would consider something else than the arrows, is if I'm running a pet or c64, without direct arrow keys (there you still have to press shift + arrow).

Thread Thread
 
wulymammoth profile image
David

Just another tool in the box. I'm not opposed to arrow keys at all. my hjkl keys are are my arrow keys, but requires me to depress the function key to activate and do, at times, rely on it, particularly in applications where these readline key combos don't work.

Did you just name drop C64 as in Commodore64? Are we diggin' 'round the attic for antiques?