automate yo self
TRANSCRIPT
![Page 1: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/1.jpg)
Automate Yo' Self!OpenWest 2016 Sandy UT
John SJ Anderson @genehack
if anybody has any questions or i'm going too fast, please throw up a hand and ask -- or i'm here all week, grab me
on the hallway track
![Page 2: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/2.jpg)
Hi, I'm John.
hi, i'm john
![Page 3: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/3.jpg)
@genehack
i go by genehack most places on line.today i'm going to talk to you today about some tools and tricks i have for being productive while developing. but before i do that, i need to explain a bit about why i needed it. my life is busy.
![Page 4: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/4.jpg)
Sammy
i've got a dog.
![Page 5: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/5.jpg)
@sammygenehack
dog's got a twitter account.
![Page 6: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/6.jpg)
Two kids
two daughters
![Page 7: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/7.jpg)
A Wife
and a wife that i like to hang out with
![Page 8: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/8.jpg)
long-suffering conference widow
A Wife
![Page 9: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/9.jpg)
photobomber is not impressed.
A Wife
long-suffering conference widow
![Page 10: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/10.jpg)
Job
I've also got a job
![Page 11: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/11.jpg)
Hobbies
and i have a few hobbies -- maintain some Perl modules,
![Page 12: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/12.jpg)
Hobbies
Trying to learn Swift, check out Angular 2,
![Page 13: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/13.jpg)
Lots of
Hobbies
reading, hiking, cooking,
![Page 14: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/14.jpg)
I've got a lot of balls in the air
don't have time for trivial nonsense, so i use a lot of automation and other "lifehacks"
![Page 15: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/15.jpg)
AUTOMATE YO' SELF
occasionally, you just have to automate yo' self!
![Page 16: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/16.jpg)
Basic Principles
whenever i'm trying to do this, there are some basic principles that i try to keep in mind
![Page 17: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/17.jpg)
Don't Make Me Think
none of this automation stuff should require me to think -- if i have to think about it, it's not really saving me any time
![Page 18: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/18.jpg)
This is my "you made me think" face.
the whole point is not having to think.
![Page 19: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/19.jpg)
Consistency is Good.
so, in those terms, one thing that's essential: make everything the same. have a standard directory layout under $HOME. you shouldn't have to think about what system you're on, what shell, what project. things should just be the same -- or at least *correct* -- all the time
![Page 20: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/20.jpg)
Idempotence is better!
Idempotence: the property of certain operations in mathematics and computer science, that can be applied multiple times without changing the result beyond the initial application
![Page 21: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/21.jpg)
App::MiseEnPlace
so, here's an example of idempotence, a utility i wrote to manage symlinks and directories in my home directory
![Page 22: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/22.jpg)
App::MiseEnPlace
"everything in its place"
"mise en place" is a French phrase meaning "everythng in its place" -- it comes from cooking, and the principle that you should have all your ingredients prepped and ready to go before you start cooking. i wanted something to make sure i always had my standard directory layout under $HOME as well as setting up various symlinks
![Page 23: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/23.jpg)
% cat ~/.mise --- manage: - doc - etc - private - proj/* - src/* create: directories: - bin - proj - proj/go/src/github.com/genehack - src - var links: - Desktop: var/tmp - Desktop: tmp
here's what the top level config for mise looks like -- it goes in .mise in your home directory. we have a list of
directories we want to manage (more on that in a minute) and a set of directories and symlinks to create. links are source:target
![Page 24: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/24.jpg)
% cat proj/emacs/.mise --- create: links: - DIR: ~/.emacs.d - bin/build-most-recent-emacs: BIN - bin/e: BIN - bin/ec: BIN - bin/git-blame-from-line-num: BIN - bin/map-test-lib: BIN
this is a per-project config file. mise has a couple special keywords DIR and BIN, that refer to the directory
containing the .mise file and ~/bin, respectively the advantage of this is you don't need to have a huge gnarly $PATH with a bunch of project directories in it,
everything is just symlinked into ~/bin
![Page 25: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/25.jpg)
% mise [LINK] created ~/proj/emacs -> ~/.emacs.d [LINK] created ~/proj/emacs/bin/build-most-recent-emacs -> ~/bin/build-most-recent-emacs [LINK] created ~/proj/emacs/bin/e -> ~/bin/e [LINK] created ~/proj/emacs/bin/ec -> ~/bin/ec [LINK] created ~/proj/emacs/bin/git-blame-from-line-num -> ~/bin/git-blame-from-line-num [LINK] created ~/proj/emacs/bin/map-test-lib -> ~/bin/map-test-lib
% mise
% rm ~/bin/e
% mise [LINK] created ~/proj/emacs/bin/e -> ~/bin/e
when we run mise for the first time, you can see it creates all those links. if we run it again, it does NOTHING.
Idempotency for the win! If you remove a link and run it again, it creates _just_ that link
![Page 26: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/26.jpg)
App::MiseEnPlace
get it from your favorite CPAN mirror
available on CPAN, minimal dependencies, works on any perl from this decade.
![Page 27: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/27.jpg)
smartcd
ok, so that handles getting a consistent directory structure, and linking project binaries. what if you have other per-project stuff that you want to set up? environment variables or other stuff?
![Page 28: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/28.jpg)
smartcd
Automatically run code when entering or leaving directories or sub-directories
enter smartcd, which hooks the 'cd' command and then runs scripts when you enter or leave a directory (or even a subdirectory)
![Page 29: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/29.jpg)
% smartcd show enter /Users/genehack/.smartcd/scripts/Users/genehack/fake-node-proj/bash_enter exists ------------------------------------------------------------------------- ######################################################################## # smartcd enter - /Users/genehack/fake-node-proj # # This is a smartcd script. Commands you type will be run when you # enter this directory. The string __PATH__ will be replaced with # the current path. Some examples are editing your $PATH or creating # a temporary alias: # # autostash PATH=__PATH__/bin:$PATH # autostash alias restart="service stop; sleep 1; service start" # # See http://smartcd.org for more ideas about what can be put here ########################################################################
autostash NODE=4.2.3 autostash PATH=$PATH:__PATH__/node_modules/.bin/ nvm use $NODE -------------------------------------------------------------------------
smartcd has 'edit' and 'show' subcmds (and a bunch of others), and 'leave' and 'enter' scripts. here's an enter script
for an arbitrary node project. the autostash keyword sets up an environment variable that will be *unset* when you leave this directory. you can also run arbitrary commands; the 'nvm' command here selects a version of node to use
![Page 30: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/30.jpg)
% cd ~/fake-node-proc Now using node v4.2.3 (npm v2.14.7)
% echo xx$NODE xx4.2.3
% cd ..
% echo xx$NODE xx
here's what it looks like when you cd into that directory. and you can see the env var is set. if we change back out of
the directory, the environment variable is unset.
![Page 31: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/31.jpg)
smartcd
https://github.com/cxreg/smartcd
pretty cool, available on github. works with bash and zsh. really easy to install.
i can pay this the highest possible compliment: i haven't forked it or needed to patch it in any way, i just use a checkout from the upstream repo
![Page 32: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/32.jpg)
App/Env Builders
are your
friends
speaking of per-project settings, let's talk for a minute about application builders.
![Page 33: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/33.jpg)
perlbrew plenv nvm
App::GitGitr
build-most-recent-emacs
here are some of the ones i've used or use now. perlbrew and plenv let you have multiple perls. nvm does the same thing for node. similar tools exist for python, ruby, etc.
then there's GitGitr, which I wrote while maintaining Git wrapper library. I needed to be able to quickly install arbitrary Git versions while responding to bug reports -- so I wrote a little tool that does that.
Similarly, I'm an Emacs user. If a new version is released, I want to upgrade, across all my systems - so I scripted that.
![Page 34: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/34.jpg)
Consistency Corollary: Don't trust system binaries
Back at the beginning, I said "consistency is good". Now, if you're developing on MacOS and deploying to Linux (or dev-ing on Ubuntu and deploying to Debian), you're probably not going to have the same version of tool from the OS (and if you do now, it's not going to last). Even if the versions are the same, there may have been vendor patches applied.
![Page 35: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/35.jpg)
Automate building your critical tools.
No, if you really want to be consistent, the best approach is to build the tools that are most critical for your project. ("Build" in this case may just mean automating the install; it doesn't have to mean "build from source".) Note: only do this for the *important* stuff. (include examples)
![Page 36: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/36.jpg)
The Silver Searcher
Speaking of tools, here's a tool that has literally improved my entire development life -- the silver searcher. Anybody
here using this?
![Page 37: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/37.jpg)
grep?
ok, so, grep -- everybody knows grep, right? let's you search for text inside files, which is something you do a lot
while developing code.
![Page 38: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/38.jpg)
grep?powerful, speedy, indiscriminate
so, grep is super powerful in terms of what you can search for, and it's pretty quick, but it's not very selective. you
can list all the files you want to search, or search whole dir trees, but you quickly realize this sucks, because of things like .git directories. anybody ever do a recursive grep on a big git checkout? yeah.
![Page 39: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/39.jpg)
ack?
anybody here use ack? ack is a grep-like tool written in perl.
![Page 40: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/40.jpg)
ack?powerful, selective, slow
it's just as powerful as grep in terms of what you can search for, but it's recursive by default (which is what you want)
and it's smart about ignoring .git and SVN stuff. the problem is, it's pretty slow, particularly to start up (because Perl)
![Page 41: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/41.jpg)
ag!
enter ag (which is what the binary for the silver searcher is called.
![Page 42: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/42.jpg)
ag!powerful, selective, FAST
ag works much like ack (not _exactly_, but close enough), but it's written in C and it's oh so fast.
![Page 43: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/43.jpg)
The Silver Searcher
https://github.com/ggreer/the_silver_searcher
available on Github, also packaged in several Linux distros. again, no higher compliment than to say I just build
from a checkout of the upstream. have never needed to fork or patch
![Page 44: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/44.jpg)
My biggest productivity/automation tip
so, here's my single biggest tip in this whole talk. are you ready? brace yourselves.
![Page 45: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/45.jpg)
Revision control $HOME
this is it. anybody know what this is?
this is your home directory under revision control
![Page 46: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/46.jpg)
Why bother?
no, but seriously. it's a little bit of a pain to develop the discipline but once you get used to having _everything_ under revision control, it's nice. you don't have to worry about experimenting with anything, backing stuff up, or dealing with cross-machine variation in your environments
![Page 47: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/47.jpg)
say automation again
originally i had series of kludgy shell scripts to manage repo updates and checkoutssuper ugly and not worth sharingand then, inspiration: Ingy döt Net talking about App::AYCABTU @ PPW2010
![Page 48: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/48.jpg)
Ingy döt Net
this is ingy - he's a crazy awesome open source hacker guy who has done a whole bunch of stuff. probably best
known for being one of the inventors of YAML
![Page 49: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/49.jpg)
Things I wanted to steal
the thing ingy had developed had a bunch of stuff i wanted to steal: The basic ideaThe interfaceInfo about repositories in config fileFlexible ways of selecting repos for operations – by #, by name, by tag
![Page 50: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/50.jpg)
Things I wanted to add
Support for more than just GitLocate repositories in arbitrary locationsEasily add and remove repositoriesAbility to easily extend with more subcommandsMost importantly: better name!
![Page 51: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/51.jpg)
App::AYCABTU?!?!‽
and finally, the name. what even is this.
![Page 52: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/52.jpg)
GitGot
Thus was born GitGothttp://search.cpan.org/dist/App-GitGot/Installs a ‘got’ commandUses Moo and App::Cmd under the coversAdd new subcommands by writing a single class!
![Page 53: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/53.jpg)
Whirlwind Tour
Let's take a whirlwind tour of how got works
![Page 54: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/54.jpg)
got add
you tell got about repos using the 'add' command, from inside the git repo
![Page 55: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/55.jpg)
% got add Name: foo URL: Path: /Users/genehack/foo Tags: bar
it'll prompt you for required info, and supply sensible defaults. note that you can also apply tags (space-delimited)
![Page 56: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/56.jpg)
got add -D
or you can just add the '-D' switch and it'll automatically use the defaults
![Page 57: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/57.jpg)
got clone <REPO URL>
you can also clone a remote repo, which will check it out into the working directory and add it to got, prompting
you for details
![Page 58: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/58.jpg)
% got clone [email protected]:genehack/app-gitgot.git Name: [app-gitgot]: Path: [/Users/genehack/app-gitgot]: Tags: : Cloning into '/Users/genehack/app-gitgot'...
it'll prompt you for required info, and supply sensible defaults. note that you can also apply tags (space-delimited)
![Page 59: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/59.jpg)
got clone -D <REPO URL>
got clone also respects the '-D' switch
![Page 60: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/60.jpg)
got fork <GITHUB URL>
finally, you can give got a github url, and it will fork that project under your github id, then check it out into the
current directory and add it to got
![Page 61: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/61.jpg)
~/.gitgot
all the info about the repos managed by got lives in this .gitgot file in your home directory
![Page 62: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/62.jpg)
- name: App-Amylase path: /Users/genehack/proj/App-Amylase repo: [email protected]:genehack/App-Amylase.git type: git - name: Git-Wrapper path: /Users/genehack/proj/Git-Wrapper repo: [email protected]:genehack/Git-Wrapper.git tags: git type: git - name: HiD path: /Users/genehack/proj/HiD repo: [email protected]:genehack/HiD.git type: git - name: Perl-Build path: /opt/plenv/plugins/perl-build repo: git://github.com/tokuhirom/Perl-Build.git type: git
it's just a simple YAML formatted line, totally hand-editable (although you shouldn't _need_ to do that, you can)
note that repos can be located anywhere on the disk, don't have to under a common dir or in your home or
whatever. anywhere you can write to is fair game
![Page 63: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/63.jpg)
But now what?
ok, so you've added all your git repositories to got. what now?
![Page 64: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/64.jpg)
got list
well, you can get a list of them
![Page 65: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/65.jpg)
got ls
which you can shorten to this
![Page 66: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/66.jpg)
1) App-Amylase git [email protected]:genehack/App-Amylase.git 2) Git-Wrapper git [email protected]:genehack/Git-Wrapper.git 3) HiD git [email protected]:genehack/HiD.git 4) Perl-Build git git://github.com/tokuhirom/Perl-Build.git 5) Perl-Critic git [email protected]:genehack/Perl-Critic.git 6) STAMPS git [email protected]:genehack/STAMPS.git 7) advanced-moose-class git ssh://[email protected]/train/advanced-moose-class.git 8) app-gitgitr git [email protected]:genehack/app-gitgitr.git 9) app-gitgot git [email protected]:genehack/app-gitgot.git
that'll get you this sort of listing.
![Page 67: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/67.jpg)
got ls -q
if you don't want to see the upstream repo info, you can use the '-q' or '--quiet' switch
![Page 68: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/68.jpg)
1) App-Amylase 2) Git-Wrapper 3) HiD 4) Perl-Build 5) Perl-Critic 6) STAMPS 7) advanced-moose-class 8) app-gitgitr 9) app-gitgot
and that'll get you this output.
note the numbers - those will give you a way to select repos for other commands
![Page 69: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/69.jpg)
got ls [repos]
easiest way to demo that is with an example. you can restrict the listing
![Page 70: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/70.jpg)
got ls 5
this will just list repo #5 for example
![Page 71: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/71.jpg)
5) Perl-Critic
also, note that the list is always sorted the same way, so the numbers will be stable (unless you add new repos)
![Page 72: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/72.jpg)
got ls 5-8
you can also give a range of repos
![Page 73: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/73.jpg)
5) Perl-Critic 6) STAMPS 7) advanced-moose-class 8) app-gitgitr
and that'll give you that range, like you would expect
![Page 74: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/74.jpg)
got ls HiD
you can also specify repos by name
![Page 75: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/75.jpg)
3) HiD
![Page 76: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/76.jpg)
got ls -t git
or by using tags. can specify multiple tags with multiple '-t' switches. they combine with 'or' semantics.
![Page 77: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/77.jpg)
2) Git-Wrapper 8) app-gitgitr 9) app-gitgot
here are all the repos tagged with 'git' (at least in our example)
![Page 78: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/78.jpg)
got ls 5-8 HiD 21 -t git
finally, you can combine all of these selection methods together. here we're asking for repos 5 thru 8, the repo
named HiD, repo 21, and all repos tagged with git
![Page 79: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/79.jpg)
2) Git-Wrapper 3) HiD 5) Perl-Critic 6) STAMPS 7) advanced-moose-class 8) app-gitgitr 9) app-gitgot 21) etc
and this is what we get
note that most commands operate on all repos, and any that do, you can use these techniques to restrict the
command to a subset.
![Page 80: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/80.jpg)
What else you got?
That's cool.
![Page 81: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/81.jpg)
(no pun intended.)
![Page 82: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/82.jpg)
got status
you can check the status of your repos.
*all* your repos
![Page 83: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/83.jpg)
got st
or if you're into the whole brevity thing...
![Page 84: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/84.jpg)
1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : OK 4) Perl-Build : OK 5) Perl-Critic : OK 6) STAMPS : OK 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK
that'll get you output like this.
again, note the use of color to give quick visual cues
![Page 85: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/85.jpg)
1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : Dirty 4) Perl-Build : OK 5) Perl-Critic : OK 6) STAMPS : OK 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK
Dirty
got status will let you know if a repo has uncommitted changes.
super handy if, for example, working on one machine and are going to move to another one and want to see what
hasn't been committed.
![Page 86: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/86.jpg)
1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : OK 4) Perl-Build : OK 5) Perl-Critic : OK 6) STAMPS : OK Ahead by 1 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK
1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : OK 4) Perl-Build : Dirty 5) Perl-Critic : OK 6) STAMPS : OK 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK
Dirty
1) App-Amylase : OK 2) Git-Wrapper : OK 3) HiD : OK 4) Perl-Build : OK 5) Perl-Critic : OK 6) STAMPS : OK Ahead by 1 7) advanced-moose-class : OK 8) app-gitgitr : OK 9) app-gitgot : OK
Ahead by 1
it'll also tell you if you have local commits that haven't been pushed to the remote yet
![Page 87: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/87.jpg)
got st -q
finally, you can use the '-q' switch to hide the "uninteresting" stuff
![Page 88: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/88.jpg)
got st -q 3) HiD : Dirty
6) STAMPS : OK Ahead by 1
Dirty
Ahead by 1
which in this case is all the repos that don't have changes and are up to date
![Page 89: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/89.jpg)
got update
you can also run 'git pull' across all your repos
![Page 90: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/90.jpg)
got up
which abbreviates to 'up'
and yeah, i should have called it pull but i'm a dummy and we're stuck with it now.
![Page 91: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/91.jpg)
1) App-Amylase : Up to date 2) Git-Wrapper : Up to date 3) HiD : Up to date 4) Perl-Build : Updated Updating 7f25f89..72587c8 Fast-forward lib/Perl/Build.pm | 14 +++++++++++++- script/perl-build | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) 5) Perl-Critic : Up to date
Updated
it'll do pretty much what you expect (and it supports '-q' too)
![Page 92: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/92.jpg)
got update_status
finally, there's a command that combines both those, because it's something i do pretty frequent -- update
everything, then look at the status of everything
![Page 93: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/93.jpg)
got upst
surprise - you can abbreviate that one too
![Page 94: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/94.jpg)
got upst -q
and it also supports the '--quiet' option to only show you the interesting stuff
![Page 95: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/95.jpg)
How much would you pay?
so, how much would you pay?
![Page 96: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/96.jpg)
Wait, don't answer yet
![Page 97: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/97.jpg)
got fetch
if you're not a fan of the way 'git pull' works you can also run 'git fetch' via got.
![Page 98: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/98.jpg)
got push
you can even do a push across all your repos at once. (personally, this strikes me as insane but somebody sent in a
patch, so...)
![Page 99: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/99.jpg)
got gc
you can garbage collect all your repos
![Page 100: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/100.jpg)
got this
at some point, somebody sent in a patch to add 'got this' -- which tells you if the current directory is under got
control
![Page 101: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/101.jpg)
got that <DIRECTORY>
this provoked somebody else to send in a 'got that' command, which does the same thing, but takes a path to
check
![Page 102: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/102.jpg)
got chdir
finally, there are a number of commands that help you jump to the directory of a project. got chdir
![Page 103: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/103.jpg)
got cd
also spelled 'got cd', will change your current working directory to the given repo (note that this is one of the few
got commands that requires a single repo)
![Page 104: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/104.jpg)
got tmux
we also have tmux integration -- 'got tmux' will open a new tmux window with the working directory in your repo.
this _can_ be done with multiple repos. better, the tux window is persistent; as long as it's open 'got tmux' will just select the already open window, not open a new one
![Page 105: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/105.jpg)
got tmux -s
you can also spawn whole new tmux sessions if you prefer those to windows -- and again, those will be re-used as
long as they're around
![Page 106: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/106.jpg)
How much would
you paynow
?
![Page 107: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/107.jpg)
Good news!
It's free!
nothing!
![Page 108: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/108.jpg)
Works on any perl from the last 5 years
![Page 109: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/109.jpg)
cpan App::GitGot
installation is simple
![Page 110: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/110.jpg)
cpanm App::GitGot
can be even simpler
![Page 111: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/111.jpg)
BLATANT PUG If you're not sure what 'cpanm' is,
come to my Unfrozen
Paleolithic Perl Programmer talk tomorrow at 4pm!
blatant plug
![Page 112: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/112.jpg)
Find me at OpenWest and I'll help you install!
or you can find me on the hallway track and i'll help you get it installed on your machine
![Page 113: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/113.jpg)
Easy to extend
![Page 114: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/114.jpg)
package App::GitGot::Command::chdir;
# ABSTRACT: open a subshell in a selected project use 5.014;
use App::GitGot -command;
use Moo; extends 'App::GitGot::Command'; use namespace::autoclean;
sub command_names { qw/ chdir cd / }
sub _execute { my( $self, $opt, $args ) = @_;
unless ( $self->active_repos and $self->active_repos == 1 ) { say STDERR 'ERROR: You need to select a single repo'; exit(1); }
my( $repo ) = $self->active_repos;
chdir $repo->path or say STDERR "ERROR: Failed to chdir to repo ($!)" and exit(1);
exec $ENV{SHELL}; }
1;
![Page 115: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/115.jpg)
package App::GitGot::Command::chdir; # ABSTRACT: open a subshell in a selected project
use Moo; extends 'App::GitGot::Command';
![Page 116: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/116.jpg)
sub command_names { qw/ chdir cd / }
![Page 117: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/117.jpg)
sub _execute { my( $self, $opt, $args ) = @_;
unless ( $self->active_repos and $self->active_repos == 1 ) { say STDERR 'ERROR: You need to select a single repo'; exit(1); }
my( $repo ) = $self->active_repos;
chdir $repo->path or say STDERR "ERROR: Failed to chdir to repo ($!)" and exit(1);
exec $ENV{SHELL}; }
![Page 118: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/118.jpg)
package App::GitGot::Command::chdir;
# ABSTRACT: open a subshell in a selected project use 5.014;
use App::GitGot -command;
use Moo; extends 'App::GitGot::Command'; use namespace::autoclean;
sub command_names { qw/ chdir cd / }
sub _execute { my( $self, $opt, $args ) = @_;
unless ( $self->active_repos and $self->active_repos == 1 ) { say STDERR 'ERROR: You need to select a single repo'; exit(1); }
my( $repo ) = $self->active_repos;
chdir $repo->path or say STDERR "ERROR: Failed to chdir to repo ($!)" and exit(1);
exec $ENV{SHELL}; }
1;
![Page 119: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/119.jpg)
Suggestions welcome!
areas for improvement:
support for other VCSen better config management tools any other crazy workflow improvement you can think of!
![Page 120: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/120.jpg)
Thanks OpenWest organizers
Ingy döt NetYanick Champoux
Michael GrebRolando Pereira
Chris Prather
photo credits:
all photos by speaker except Ingy döt Net photo - https://www.flickr.com/photos/bulknews/389986053/
and pug - https://upload.wikimedia.org/wikipedia/commons/d/d7/Sad-pug.jpg and automate yo'self - somewhere on the net
![Page 121: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/121.jpg)
![Page 122: Automate Yo Self](https://reader034.vdocument.in/reader034/viewer/2022052515/587a89561a28ab58288b5565/html5/thumbnails/122.jpg)
Questions?
https://joind.in/event/openwest-2016/automate-yoself
as i said, i'm here all week and i *love* to talk to people about this productivity type stuff, so grab me on the
hallway track. i'm friendly.