Let’s
Learn
Git.
No
Excuses!
@mcdwayne on Twitter
Slides at mcdwayne.com
Bash Is Magic
# No It’s Not
Pantheon.io
Open Source Sales and Marketing since 2005
Founder of�Process Digital Consulting
Some things I enjoy:
Slides at: mcdwayne.com
Pantheon.io
https://processdigitalconsulting.com
Turning Strategic Vision Into Tactical Wins
Slides at: mcdwayne.com
Pantheon.io
Poll time
Pantheon.io
How do I get the most from this talk?
fi
Pantheon.io
Pantheon.io
Pantheon.io
"What Bash does is the point of Open Source. Leveraging smart tools other smart people have built."
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Using the graphical
user interface
is all you know.
You want to do more
faster.
Pantheon.io
You feel like you are repeating
the same steps
over and over and over and over and over and
over and over and over and over and
over and over and over and over and over and ..
Pantheon.io
“I have a tool for that. Just clone my repo.”�--Every dev on Github
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Stephen R. Bourne
Created Unix sh in 1979 at Bell labs
Pantheon.io
In 1988 Richard Stallman and Brian Fox rewrote Bourne’s Shell as the ‘Bourne Again SHell’ under the GNU project
Pantheon.io
Bash is a command processor that typically runs in a text window where the user types commands that cause actions. Bash can also read and execute commands from a file, called a shell script.
Pantheon.io
Bash is a command processor that typically runs in a text window where the user types commands that cause actions. Bash can also read and execute commands from a file, called a shell script.
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
ADD WINDWS - Linus quote that won
Pantheon.io
Pantheon.io
Pantheon.io
Mac and Linux:
A Bash terminal came included
Windows 10 Professional Edition:�Windows Subsystem for Linux
Other Windows:
Git-Bash
Pantheon.io
Standard Commands
Applications/Tools
Aliases
Scripting and Logic
Pantheon.io
Pantheon.io
The default command line prompt in Mac OS X is something like:
ComputerName:CurrentDirectory User$
�~ = $HOME = default home directory for user
Pantheon.io
Standard Commands
Pantheon.io
pwd
Present Working Directory
“Hey Bash, Show me where I am.”
Pantheon.io
ls
List Directory Contents
“Hey Bash, What’s in this folder?”
Pantheon.io
ls -a
List Directory Contents -All
“Show me everything in the folder?”
Pantheon.io
man [command name]
Display The Manual Pages
“Show me the manual for [command]”
Pantheon.io
cd
Change Directory
“Move into the specified directory”
Pantheon.io
cd ..
Change Directory One Level Up
“Move into the .. directory (one level up)”
Pantheon.io
mkdir
Make A New Directory
“Make me a new folder where I say”
Pantheon.io
cp
Copy
“Make a copy and put it where I say”
Pantheon.io
mv
Move
“Move this to where I say”
Pantheon.io
rm
remove
“Go ahead and forget that thing”
Pantheon.io
rm -rf
Remove file and everything in the file
“FORGET THIS FOLDER AND ALL IT CONTAINS!!!”
Pantheon.io
cat
concatenate and print files
“Print the file to the screen”
Pantheon.io
which
locate a program file in the user's path
“Where is the tool actually installed?”
Pantheon.io
history
Show the history of commands
“What did I type to do that?”
Pantheon.io
clear
Clear the screen
“Give me a fresh view for this session”
Pantheon.io
open
Open files and directories
“Let’s open this file or app”
Pantheon.io
Applications/Tools
Pantheon.io
Some are built in (on most systems)
Pantheon.io
grep
file pattern searcher
“Where does this string appear?”
Pantheon.io
curl
transfer a URL
“Go get something from this URL”
Pantheon.io
vi
Vi IMproved, a programmer's text editor
“Edit this file with the default text editor”
Pantheon.io
vi minimal tutorial:
‘i’ to insert to write
‘esc’ to get to Command Mode
‘:wq’ to write & quit �‘:q!’ quit right now without saving
‘man vi’ to read the rest
Pantheon.io
nano
Nano's ANOther editor
“Edit this file with a simpler editor than vi”
Pantheon.io
Many, many more tools you can install
Pantheon.io
Pantheon.io
brew install [package name]
Package manager for macOS
“Install this application on my machine”
Pantheon.io
calc
arbitrary precision calculator
“Do some math for me Bash”
Pantheon.io
git
the stupid content tracker
“Envoke version control”
Pantheon.io
telnet
User interface to the TELNET protocol
“Let me get online with text only”
Pantheon.io
ddgr
DuckDuckGo over the command line
“Search for docs without a browser”
Pantheon.io
Thousands more tools to install per instructions from where you get the code
Pantheon.io
drush
Command line shell for Drupal
“Let me manipulate my Drupal site”
Pantheon.io
wp
The WP-CLI
“Let me manipulate my WordPress site”
Pantheon.io
composer
Dependency Manager for PHP
“Assemble these code files for me”
Pantheon.io
Docksal
All-purpose web-development environment based on Docker
Pantheon.io
behat
Behavior-Driven Development framework
“Did my PHP code change break my site?”
Pantheon.io
backstop
BackstopJS automates visual regression
“How are A’s pixels different than B’s?”
Pantheon.io
AND LITERALLY THOUSANDS MORE...
Pantheon.io
Aliases
Pantheon.io
.bash_profile and .bashrc
aliases
setting environment variables
Pantheon.io
alias term=’phrase term will represent’
Built in tool to alias strings
“When type say this, do that”
Pantheon.io
export PATH=$PATH:$HOME/bin
Path to where executables are located
“When I invoke a tool, find it at this file”
Pantheon.io
source ~/.bash_profile (.bashrc)
Use the changes made in this terminal
“Put those changes into effect now”
Pantheon.io
Scripting
Pantheon.io
Pantheon.io
#!/bin/bash
#! = Shebang
The part after the #! tells the system what program to use to run it.
Pantheon.io
#
# This is a comment and will be ignored
“Don’t execute this line Bash”
Pantheon.io
scriptFileName.sh
.sh is standard file extension
“Bash, run these commands in this order”
Pantheon.io
chmod 755 scriptFileName.sh
change file modes or Access Control Lists
“Let my script be executable”
Pantheon.io
./scriptFileName.sh
./
“Run this script if you can”
Pantheon.io
~/bin/
Local user folder for scripts to run as user
“Wherever I am, run this script by name”
Pantheon.io
Examples
Pantheon.io
Show theme and plugin status on these sites
Pantheon.io
Open these websites in Chrome
Pantheon.io
Make a new post with CSSCMS.club
Pantheon.io
Post content and test it with Behat and BackstopJS before pushing to production
Pantheon.io
Tips and Tricks
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
Pantheon.io
http://redsymbol.net/articles/unofficial-bash-strict-mode/
� #!/bin/bash
set -euo pipefail
IFS=$'\n\t'
Pantheon.io
Pantheon.io
Pantheon.io
For everything else!
@mcdwayne
Pantheon.io
ADDD TELEHACK SLIDE
@mcdwayne
Pantheon.io
Official Documents:
https://www.gnu.org/software/bash/manual/
Cheat Sheets!
https://devhints.io/bash
https://learncodethehardway.org/unix/bash_cheat_sheet.pdf
https://www.ullright.org/ullWiki/show/bash-shell-scripting-cheat-sheet
Articles I Like:
https://zwischenzugs.com/2018/01/06/ten-things-i-wish-id-known-about-bash/
https://twitter.com/McDwayne/status/1099046563605733376
"In the Beginning was the Command Line" http://cristal.inria.fr/~weis/info/commandline.html
Bash Cookbook; https://www.amazon.com/bash-Cookbook-Solutions-Examples-Users/dp/1491975334
http://osxdaily.com/2006/12/11/how-to-customize-your-terminal-prompt/
https://ryanstutorials.net/bash-scripting-tutorial/bash-script.php
Advanced:
3 pillars of good bash:
1) google shell style guide - https://google.github.io/styleguide/shell.xml
2) shellcheck - https://www.shellcheck.net/
3) bash unofficial 'strict mode' (`set -eou pipefail`) - http://redsymbol.net/articles/unofficial-bash-strict-mode/
1000s of ‘how to’ guides, docs and articles
@mcdwayne
Pantheon.io
Pantheon.io
Open Source Sales and Marketing since 2005
Founder of�Process Digital Consulting
Some things I enjoy:
Slides at: mcdwayne.com
Pantheon.io
Q & A
Pantheon.io