20 Bash Tricks in 5 Minutes - Spencer Krum

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'm a big user of the bash shell my name is Spencer kromm I work on the OpenStack team at IBM I'm from Portland I'm nib eliezer basically everywhere on the Internet and so what I want to talk I've wanted to give this talk for a long time about these cool little tricks I started doing and at first it was fun and then it got a little out of hand these are patterns don't actually do what I do take the patterns and use those and there's a git repo that I'm sure I'll get a lot of pull requests on with your stupid tricks too so this is mostly aliases and functions and the way those work is by adding new commands to your path and I can't type so what I'll do is I'll make SL equal LS no matter what else happens I don't want to type vagrant anymore so I just type V I don't want to type git I type G I don't want to type git push origin master I type a four-letter thing that doesn't mean anything to anyone but this is personal configuration so that doesn't matter no one's reading my pseudo the logs anyways be honest another thing I'll do is I will make a really long command with semicolons and I'll put that all in there so if I'm just like screw this I'm pushing it screw you all BSC you get it you said you wanted it push early push off and let's do it you also see a validate command all right so I don't know the alphabet so I have a bash alias that will dump the alphabet I have a bash alias that will dump Unicode so that I can paste it into chat and it turns out the ASCII tables on man ASCII but I don't want to use a pager so I have something that'll dump it straight into my terminal you can put regular expressions into bash aliases and then use them in grep you can put environment variables into aliases and make new commands UTC date will dump the date in your servers timezone I have a lot of git repos that are full of yeah Milland JSON and so I have these two commands that will validate JSON and yamo before I run a fifteen-minute acceptance suite I'm sure I'm the only one that forgets the final comma I'm not gonna tell you how this works but I strongly encourage you to find some way of dynamically reprogramming your prompt so adding get turning it off adding your directory turning that off inspecting which SSH file system you're using turning on our VM or uninstalling it forever this is a simple little function this is our first bash function this will set up an SSH tunnel and then fire up Windows because I write for a press and not O'Reilly so I have to use sharepoint sorry this is probably the thing you want the most your your five directories deep inside a git repo you're scared and alone and you just want to go back to the top and this will take you to the top of the git repo and then it will set old PWD so CD - will take you home github integration so this is something I stole but what it does is essentially you're in some get repo and you type PR 17 and it'll check out the 17th PR so you can run the tests or get grep or whatever you're trying to do there's there's more getup integration on the next step I don't want to go press the fork button I don't want to press the pull request button so bash utilities have existed for a while that allow you to do this in the command line I highly recommend you add that to your workflow because otherwise you're just kind of wasting time um so you can override things that are already in your path where's bath functions so user been CD record is in your path and you write a function called CD record and it'll run this instead of that and that means that it can eject which is what it's supposed to happen after you burn a CD umm I have stuff that I used this is the most open stack slide in the entire deck I have this long designate command that like tells me how many route 53 entries I have and I got tired of remembering it so I put it in a bash alias if you have something you're always inspecting your history for you should probably get it Garret is a Java server with an SSH API which is really weird to use so I wrote a bash function so that it'll just eat everything with that dollar star and then just dump it into this and so Garret on my command line behaves like a real UNIX utility and then it got crazy because I decided I could do my own argument interpretation in if statements inside the Garret function and add commands to Garrett that weren't there to begin with and so you can get further you can go read case statement and you can have cascading commands and alright so this is the number one thing or this is the the fancy thing if you type vim plus 24 filename it will open up that file on the 24th line that second thing will give you the last command you typed and Grit grep n will give you this colon number colon and so I override it vim and so whenever I type them it says was the last command you type get grep did you give me something with colon line number colon if so I'll open up that file to the line number that matched your most recent grep thank you my name is Spencer Crum I work at IBM on OpenStack I'd love to talk to any of you later about any of this thank you
Info
Channel: O'Reilly
Views: 41,252
Rating: undefined out of 5
Keywords: O'Reilly Media (Publisher), Spencer Krum, Bash (Software), velocity ignite, velocity 2015, bash patterns, bash tricks, coding tricks
Id: pEN4WnFNMx0
Channel Id: undefined
Length: 5min 5sec (305 seconds)
Published: Tue Oct 20 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.