28
10x Command Line-F u How to look cooler a t Starbucks How to unders tand more XKCD comics ht tps://github.com/epylinkn/itp-command-fu

10x Command Line Fu

Embed Size (px)

Citation preview

Page 1: 10x Command Line Fu

10x Command Line-FuHow to look cooler at StarbucksHow to understand more XKCD comics

https://github.com/epylinkn/itp-command-fu

Page 2: 10x Command Line Fu
Page 3: 10x Command Line Fu

Why am I here? Why practice command-fu?

4 You use the command line at work

4 You use it to bootstrap your code projects

4 Automating tasks you do frequently

4 Anthony seems like a cool guy I wonder what he has to say

Page 4: 10x Command Line Fu

The command line is incredibly expressive and powerful. It can help you be

more productive and automate mundane tasks.

Page 5: 10x Command Line Fu

Our Roadmap

4 standard unix bash commands

4 chaining, pipes and output redirection

4 alias, shell functions, and your first shell script

4 scripting with javascript

4 cron, .bashrc, and .bash_profile

4 homebrew - the package manager for OSX

Page 6: 10x Command Line Fu

/bin/bash

Mac's run Unix.Developers love Unix.Unix is awesome.You can be awesome.

Page 7: 10x Command Line Fu

Standard unix bash commandsThe basics

cd - change directoryls - list filespwd - current working directorycp - copymv - movemkdir - make directoryrm - removecat - concatenate

Page 8: 10x Command Line Fu

Standard unix bash commandsMore advanced commands

sayhistoryhead / tailcurltimewatchgrepfindxargsssh

Page 9: 10x Command Line Fu

Structure of a command

$ command --option option_argument x (y z ...)

Page 10: 10x Command Line Fu
Page 11: 10x Command Line Fu

tar czvf myTarball.tar.gz .

Page 12: 10x Command Line Fu

say cheese

Simple command to make terminal say something.

say why cant we be friends

Extra credit:say --voice ?say --voice "Bad News" The light you see at the end of the tunnel is theheadlamp of a fast approaching train.

Page 13: 10x Command Line Fu

history repeats itself

historyecho goodbye worldhistory!-2history

Page 14: 10x Command Line Fu

heads or tails

head camp.txthead -n50 camp.txttail camp.txt

Extra Credit:

tail -f camp.txtecho foo >> camp.txt

Page 15: 10x Command Line Fu

alias and your first shell script!

Page 16: 10x Command Line Fu

curly fries

curl itpcalendar.herokuapp.com/calendarcurl wttr.inopen -a "Google Chrome" http://wttr.incurl -I ideas.ted.com

Extra Credit

curl -XPOST slack webhookcurl -o itp-calendar.html http://itp.nyu.edu/camp2016/session/238# copy a cURL command from chrome inspector

Page 17: 10x Command Line Fu

Steal an entire site with wget

http://www.linuxjournal.com/content/downloading-entire-web-site-wget$ wget \ --recursive \ --no-clobber \ --page-requisites \ --html-extension \ --convert-links \ --restrict-file-names=windows \ --domains blankslate.io \ --no-parent \ blankslate.io

Page 18: 10x Command Line Fu

Chaining commands

false || echo "Oops, fail"# => Oops fail

true || echo "Will not be printed"# =>

true && echo "Things went well"# => Things went well

false ; echo "This will always run"# => This will always run

Page 19: 10x Command Line Fu

Output redirection<# The < will take and send the input from the file on the right to theprogram on the left.

># The > takes the output of the command on the left, then writes itto the file on the right.

>># The >> takes the output of the command on the left, then appends itto the file on the right.

|# The | takes the output from the command on the left, and "pipes" it tothe command on the right.

Page 20: 10x Command Line Fu

pipe

"pipe" the output of one command into the input of a second command

cat ~/.bash_history | grep say | tail -n20

Page 21: 10x Command Line Fu

crontab -e

# Examples*/1 * * * * say 'super duper'

# Use a login shell so that our ~/.bash_profile gets loaded*/1 * * * * /bin/bash -lc "/Users/anthony/me/itp/command-fu/03-superbole.js"

Page 22: 10x Command Line Fu
Page 23: 10x Command Line Fu

HomebrewThe missing package manager for OS X

Page 24: 10x Command Line Fu
Page 25: 10x Command Line Fu

Some homebrew recommendations

Some homebrew recommendations:brew updatebrew install wgetwget https://cdn.rawgit.com/epylinkn/itp-command-fu/master/commandfu.pdfbrew install treetree .brew install jqcurl itpcalendar.herokuapp.com/calendar | jq '.[].title'

# faster and more configurable command-line searchbrew install the_silver_searcher

Page 26: 10x Command Line Fu

Brew Cask

brew install caskbrew cask info p5brew cask install p5open -a 'p5'brew cask uninstall p5

brew cask search unitybrew cask install unity

Page 27: 10x Command Line Fu
Page 28: 10x Command Line Fu

Resources4 https://github.com/jlevy/the-art-of-command-line

4 https://github.com/veltman/clmystery