Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Tools
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker
Hunter Gillane

Terminal: Beyond Ctrl + A and Ctrl + E

Hunter Gillane
Saturday, November 12, 2011

Update: I had some of the Ctrl and Option commands switched. Fixed now.

As Rails developers, we spend most of our day in two places: an IDE/text editor and the command line. While we spend much time learning shortcuts that help us write and refactor our source code more quickly, many of us are perfectly okay just learning Ctrl + A and Ctrl + E and holding down the arrow keys to place the cursor where we want to get to on the command line.

Don’t do that. With only a handful of additional commands, your day to day interaction with the terminal can be much more pleasant. Here are a few ways to do that using terminal and the bash shell.

A Command Line Editing Starter Pack

Here’s a quick list of commands that you’ll get a lot of day to day usage from, if you aren’t already:

  • Ctrl + A: Move cursor to the beginning of the line
  • Ctrl + E: Move cursor to the end of the line
  • Ctrl + K: Delete from cursor to the end of the line
  • Option + F: Move cursor one word forward
  • Option + B: Move cursor one word backward
  • Option + D: Delete next word
  • Option + Delete: Delete previous word

Note: You’ll need to set your meta key to Option before the commands that use Option will work (see below).

These seven simple commands will help you move more nimbly when editing text on the commands line. There is certainly plenty more you can do, which you can find in the bash manual.

A Word on Modes

By default, the bash shell run in emacs mode. This means that emacs shortcuts are enabled by default.

Emacs mode uses a Meta key for some commands, and the Option key is a good choice. In Terminal on OS X, you’ll need to enable this by going to Preferences > Settings > Keyboard and checking “Use option as meta key.”

You can also tell bash you want to use vi mode for command line editing with set -o vi, if for some reason you want to type i before every cd or ls you write.

End

Nothing new or overwhelmingly exciting here, and there is certainly much more to dive into if you are so inclined. However, this small set of commands will have you covered for the majority of your day to day command line editing needs and is what I would consider constitutes a minimum level of proficiency.

Give your arrow keys a break!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Automatic invocation of multiple OS X terminal windows

Pivotal Labs
Tuesday, March 20, 2007

As the righteous wave of Intel iMacs surges into the Pivotal Labs offices, more Pivots are finding themselves working with multiple OS X Terminal windows. The opening and positioning of terminal windows often follows the same pattern: cd into project directory, run mongrel, open next window, cd into project directory, tail the test log, etc.. To avoid violating DRY, I’ve hacked up some simple ruby scripts that automate the process. See my original post for details and links to the scripts.

Now it’s just a matter of running one command:

$ terminals.rb myproject

This opens up all of the standard windows from the project in their specified positions and running the right processes.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (783)
  • rails (117)
  • testing (90)
  • ruby (85)
  • ruby on rails (71)
  • jobs (62)
  • javascript (59)
  • techtalk (44)
  • ironblogger (42)
  • rspec (39)
  • bloggerdome (34)
  • productivity (34)
  • activerecord (30)
  • rubymine (30)
  • git (29)
  • gogaruco (29)
  • nyc (27)
  • design (24)
  • mobile (23)
  • pivotal tracker (22)
  • process (21)
  • cucumber (21)
  • jasmine (19)
  • ios (18)
  • tracker ecosystem (17)
  • webos (17)
  • objective-c (17)
  • fun (16)
  • android (16)
  • palm (16)
  • ci (16)
  • "soft" ware (16)
  • bdd (15)
  • tdd (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • css (14)
  • gem (13)
  • mouse-free development (12)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • api (12)
  • keyboard (11)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
Subscribe to terminal Feed
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Tools
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >