Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Working the Command Line
Working the Command Line
Working the Command Line
Ebook103 pages59 minutes

Working the Command Line

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Don't fear the terminal. No, really. However you've wound up face-to-face with the cool glow of a terminal window, Remy Sharp is here to help. Gain command-line shortcuts and processing techniques, install new tools and diagnose problems, and fully customize your terminal for a better, more powerful workflow.

LanguageEnglish
PublisherA Book Apart
Release dateDec 8, 2016
ISBN9781962491013
Working the Command Line
Author

Remy Sharp

Remy Sharp has been working commercially on the web since 1999 and blogging for over a decade. He runs his own consultancy, has been writing JavaScript long before it was cool, and founded the web conference ffconf in 2009. Remy tends to attract bugs and he enjoys squishing them. He uses the terminal daily.

Related to Working the Command Line

Related ebooks

Computers For You

View More

Related articles

Reviews for Working the Command Line

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Working the Command Line - Remy Sharp

    1

    JUST OPEN THE TERMINAL…

    AT SOME POINT IN YOUR LIFE, dear reader, you may have opened the terminal and found yourself staring into a black void—or, if you’re of the Mac persuasion, a white void (FIG 1.1).

    A flashing cursor and a dollar symbol invite you to enter a command. But then what? What does this void want from you?

    In my first experiences with a terminal, I remember typing words like Hello. Run. Open. I tried entire sentences. I’m not even kidding. And, no, none of it worked.

    This book is for those of you who are new—or even not so new—to the terminal. Maybe you’re a front-end developer or a designer who has read countless blog posts that start with this magical incantation: Just open the terminal… Or perhaps you have a few command-line skills, but have found yourself sucked into the void, stuck inside a command, unable to quit—ever.

    By the end of this book, you’ll feel quite comfortable firing up the terminal, and you’ll be able to speak enough terminal black-void gobbledygook that you may very well start telling other people to just run echo pling dollar.

    WHY USE THE TERMINAL?

    Damn good question. Who in their right mind would punish themselves by using the terminal instead of a beautifully designed app with an interface that would make Jony Ive shed a tear?

    The answer is that decades of development have gone into the tools available from the terminal and the command line (or the command-line interface, or CLI, as it’s also known). Lots and lots and lots of tiny tools—programs that are built to do one simple thing well, but that often join forces to solve more complex problems. This practice of designing tiny tools is known as the Unix philosophy.

    There is no single, standardized statement of the philosophy. But if it had to be described with only a single word, that word would be modularity, which refers to a system that is composed of components (i.e., modules) that can be fitted together or arranged in a variety of ways. —The Linux Information Project

    FIG 1.1: Faced with a dollar symbol and nothingness, you’d be forgiven for bailing out immediately.

    Consider a tiny command-line utility called cat, which allows you to print the contents of a file to the screen. On its own, cat is fine, if somewhat limited—but it can be used as part of a larger system. Now, if I combine cat with grep, I can quickly find out on which line the words black void appear in my manuscript. I can even count how many times I’ve used the phrase black void, simply by combining these two tools. Then I can plug that output into another program and manipulate the text, or do something else entirely. (We’ll return to the grep tool in Chapter 3.)

    One can’t easily plug something like Adobe Photoshop into Sublime Text and then into another application. But in the terminal, such acrobatics are common practice.

    TERMINAL APPLICATIONS

    You really only need one terminal application to get to the command line. You can apply customization and personalization to any and all terminals—even remote machines. I personally look for a few key features that make working with the terminal application more productive:

    Tabs . We’re used to tabbed browsers, and tabs have become a standard requirement for terminal applications these days, too.

    Split screens . Some of us are fortunate enough to work with large screens. Being able to split the terminal to view more than one task at a time is very powerful.

    Select-to-copy . If you’ve never had this feature, it might sound strange, but being able to quickly double-click (to select) any text in the terminal and then paste (so it goes straight into the prompt) is very powerful and quickly becomes muscle memory.

    If you’re a Linux desktop user and have Gnome Terminal, then you’re pretty much set, since it includes all of these great features by default. Both Windows and Mac include terminal applications by default, but you’d be wise to upgrade away from them because of their inherent limitations. The default Mac terminal is pretty good, but it’s not ideal; if you want to use a split screen, or a feature as simple (and powerful) as select-to-copy, consider using something else. The default Windows terminal is called Command Prompt; it has a number of restrictions, including not being able to resize the window.

    Let’s take a closer look at the Mac and Windows terminals.

    Mac terminal

    Out of the box, the Mac operating system comes with a terminal application called, aptly enough, Terminal. It’s a passable terminal, but being a Mac user myself, I highly recommend installing iTerm2, a free, open-source app that includes all sorts of great features. iTerm2 will be the terminal app I’ll continue to use throughout this book (FIG 1.2).

    Let me suggest a few tweaks that make working with iTerm2 extremely slick. Go to the app’s preferences:

    • In General, uncheck "Use Lion-style

    Enjoying the preview?
    Page 1 of 1