Cracking the Shell

Command-line for the Drupaler

Bob Kepford

Lead Architect



Mediacurrent Dropcast

About Mediacurrent

Mediacurrent is a full-service digital agency that implements world class open source software development, strategy and design to achieve defined goals for enterprise organizations seeking a better return on investment.

What is the Shell?

A shell is a user interface for access to an operating system's services.

CLI (command-line interface)

Text command lines

Strengths of the CLI

Light on Resources


Scriptable for Automation

Weaknesses of the CLI

Commands are not obvious

Not beginner friendly

Why you should learn to use the Shell

It's a Unix system

67.8% to 98.3% of the Servers on the Net are using Unix or Unix like systems

"I have never regretted learning to use a command line tool."

~ Me

CLI's are everywhere







Every JavaScript project

Scripts / Automation

Customization / Personalization

Make your computer work in the way you want it to.

This is getting serious

.dot files

Configuration files.

Begin with a .

Live in ~

Making the most of Dotfiles

Symlink to a single directory

Track in Git

You can take your customizations with you.

Look at other dotfiles and steal liberally

Add small bits at a time and learn how to use them


Pointer to an actual file.

ln -s ~/.source_file ~/bin/dotfiles/target_file

What configuration do we add to our dotfiles repo?

Only floss the teeth you want to keep.

~ My Dentist (Probably stole this line)

The Shell

Bash -
the GNU Project's shell and is what I use.

a shell designed for interactive use, although it is also a powerful scripting language

Fish -
a smart and user-friendly command line shell for OS X, Linux, and the rest of the family.

Environment / $PATH

Add things to your path

    export PATH=~/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin

# Type
    $ someapp
# Instead of
    $ ~/some/dir/drush/someapp.php


Shortcuts for longer more complex commands.

            alias h='history'
            alias l='ls -lhGt'  # -l long listing, most recent first -G color
            alias g='git status'


          function take() {
              mkdir -p "$1"
              cd "$1"


Secure Socket Shell


Save yourself from trying to remember IP addresses and port numbers

      Host server1
          User        napolean
          Port        22
      Host server2
          User        kip
          Port        22

Privacy and Security

Don't put sensitive info in your Git repo if you plan to make it public.


Don't use a GUI

Learn to use the commands

Git config


Git aliases

Ignoring files

Per machine: ~/.gitconfig

Per project: .gitignore file in the repository

Per repo instance: .git/info/excludes

Git Hooks


Customizing Git - Git Hooks


Code linting.

Post commit

Do tasks like copy your commit message to your clipboard?


# Copy last commit message copied to clipboard
git log --pretty=format:"%s %n%b" -1 HEAD | pbcopy


But I forget to add those to my repo


In your ~/.gitconfig

    init = init --template ~/.git_template

  templatedir = ~/.git_template

A good tutorial for setting this up. Logging Git commits with doing.

Git tools


Text-mode interface for git.


A heads up display for your Git repos.


Why Vim?

I plan on coding for many years (What editor was hot two years ago again?).

I'm already in the shell.

Open source and available on all systems.

It will NEVER die.

I love using the keyboard (Vim is designed for the keyboard first).

Can Vim do ____?


Plugins of Note

Vim Fugitive - Git

Gitgutter - Git

Vdebug - Debugging

Vim Surround

Vim Plugin For Drupal

Vim Fugitive - Git

A Git wrapper so awesome, it should be illegal.

Gitgutter - Git

Vdebug - Xdebug Client for Vim

Vim Plugin For Drupal


Fast local server

Download and enable modules

Backup and import databases

Perform updates

Watch logs

Log in as any user and much much more!

Drush serve

      drush serve

Serve Drupal locally using PHP's built in server.

Drush aliases

Drush commands against a specific Drupal site, even remote sites.

drush @youralias somecommand -y
drush use @youralias
drush updb -y

Drupal Watchdog Log

drush ws --tail

Drupal Console

Another CLI for Drupal.

Generate boilerplate code

Interact with and debug Drupal.

Drupal Console

Debug routes.

Build modules, themes, plugins and more.

Generate content.

Much more.

Tmux - Bringing it All Together

tmux is a terminal multiplexer

Why Tmux

dance fight

Seriously, Why

Detach and attach to terminal sessions without loosing state.

Isolate your terminal sessions.

Script terminal session layout based on project needs.





Tmux Sessions

Tmux Windows

Tmux Panes


Script and automate Tmux sessions.

Create and manage tmux sessions

Projects are Yaml files

Switch projects quickly


My Dot files -

dotfiles - Unofficial guide to dotfiles on GitHub (

ShellDevel -

Craft your own IDE in the shell - Wynn Netherland - (

Git - Resources

Git Ready -

Learn Git branching -

Got 15 minutes and want to learn Git? -

Git precommit hooks -

Vim - Resources

Vim Casts -

Learning Vim in a Week -

Let Vim Do the Typing -

Vim adventures -

VimGolf -

Tmux Resources

Efficient Drupal Development with Tmux and Tmuxinator

Tmux - Upcase - Paid but worth the cost.

A Tmux Crash Course

Thank You!


What Did You Think?

Locate this session at the DrupalCon Nashville website:

Take the Survey!

Cracking the Shell