Command-line for the Drupaler
Lead Architect
Publisher
Podcaster
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.
A shell is a user interface for access to an operating system's services.
Text command lines
Light on Resources
Concise
Scriptable for Automation
Commands are not obvious
Not beginner friendly
"I have never regretted learning to use a command line tool."
~ Me
PHP
MySQL
Drupal
Composer
Node
Sass
Every JavaScript project
Make your computer work in the way you want it to.
Configuration files.
Begin with a .
Live in ~
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
Only floss the teeth you want to keep.
~ My Dentist (Probably stole this line)
Bash - gnu.org/software/bash:
the GNU Project's shell and is what I use.
ZSH - zsh.org:
a shell designed for interactive use, although it is also a powerful scripting language
Fish - fishshell.com:
a smart and user-friendly command line shell for OS X, Linux, and the rest of the family.
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
HostName 192.168.68.122
User napolean
Port 22
Host server2
HostName 192.168.68.123
User kip
Port 22
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
~/.gitconfig
Per machine: ~/.gitconfig
Per project: .gitignore file in the repository
Per repo instance: .git/info/excludes
.git/hooks
Customizing Git - Git Hooks
git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
Code linting.
Do tasks like copy your commit message to your clipboard?
#!/bin/bash
# Copy last commit message copied to clipboard
git log --pretty=format:"%s %n%b" -1 HEAD | pbcopy
In your ~/.gitconfig
[alias]
init = init --template ~/.git_template
[init]
templatedir = ~/.git_template
A good tutorial for setting this up. Logging Git commits with doing.
brettterpstra.com/2014/03/20/logging-git-commits-with-doing
Text-mode interface for git.
A heads up display for your Git repos.
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).
A Git wrapper so awesome, it should be illegal.
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
Serve Drupal locally using PHP's built in server.
Drush commands against a specific Drupal site, even remote sites.
drush @youralias somecommand -y
drush use @youralias
drush updb -y
drush ws --tail
Another CLI for Drupal.
Generate boilerplate code
Interact with and debug Drupal.
Debug routes.
Build modules, themes, plugins and more.
Generate content.
Much more.
Detach and attach to terminal sessions without loosing state.
Isolate your terminal sessions.
Script terminal session layout based on project needs.
Sessions
Windows
Panes
Script and automate Tmux sessions.
My Dot files - github.com/kepford/dotfiles
dotfiles - Unofficial guide to dotfiles on GitHub (dotfiles.github.io).
Craft your own IDE in the shell - Wynn Netherland - (vimeo.com/84183973)
Learn Git branching - pcottle.github.io/learnGitBranching/
Got 15 minutes and want to learn Git? - try.github.io
Git precommit hooks - github.com/andrewmriley/drupal-site-precommit
Learning Vim in a Week - mikecoutermarsh.com/boston-vim-learning-vim-in-a-week
Let Vim Do the Typing - youtube.com/watch?v=3TX3kV3TICU
Efficient Drupal Development with Tmux and Tmuxinator
Locate this session at the DrupalCon Nashville website:
https://events.drupal.org/nashville2018/sessions/cracking-shell-command-line-drupaler
Take the Survey!
https://www.surveymonkey.com/r/DrupalConNashville