My Authors
Read all threads
Hello again, class.

I'm still Mr. @Quinnypig, and I'm still your substitute teacher until your usual teacher gets discharged from the psychiatric unit.
Today's lesson is on the shell. This all works in zsh or bash. If you're using another shell your answers will lie elsewhere, preferably far away from me or my mentions.
Let's start with pyramids.
Note how beautifully symmetrical this is? It unlocks magic such as "cd ...." to go up four directory levels.
"-" is a special variable that stands for "the previous directory you were in." In other words, "cd -" takes you back to where you were before you ran the previous command.
Two other useful variables are "!!" and "!$" The former is "the entire previous command" and the latter is "the last argument of your previous command."
"sudo !!" saves you from a lot of retyping when you yet again forget to run things as root.
Type a password into your shell? Now it's in your history--or maybe it isn't. "kill -9 $$" whacks your current shell without giving it a chance to write its history to disk.
In zsh if you want to run a command without it writing to your history, prepend it with a space.

If you want to see your entire history in zsh, `history 0` is the invocation.
tmux is great for long running processes. Combined with mosh, you can have a persistent logged in session regardless of what your local machine is doing.
screen is great for getting yelled at by weird nerds insisting you should be using tmux instead.
"wc -l" tells you how many lines something is. You can redirect output to it. For example, "env | wc -l" tells me I have 59 environment variables set, which is goddamned horrifying.
"wc -l .zshrc" tells me that my zsh configuration file is a disturbing 579 lines.
"find .zsh/ | xargs wc -l" tells me I have an additional 947 lines of configuration in sourced functions, which is complete madness.
"bash_completion" or "zsh_completion" is a handy tool that in theory lets you tab complete different commands, but in practice is completely broken all the time.
"echo alias git=hub >> .zshrc" sets up @GitHub's command line tool to extend git.
"echo alias git=hub > .zshrc" instead completely massacres your week unless you have backups. See the difference?
Storing sensitive data in your .zshrc is a bad plan. I instead store mine in ~/.zshrc.local, which doesn't leave the machine.

My config sources that file explicitly if it exists.
When building this thread I'm discovering crap like "[[ -d $AWS_RDS_HOME/bin ]] && PATH=$PATH:$AWS_RDS_HOME/bin" which is a good reminder to remove crap that doesn't need to exist anymore since @awscloud folks have learned to communicate internally.
"alias v=vim" is handy to save typing, but will leave you tripping all over your goddamned self as soon as you use any machine without your "clever" modifications installed.

Choose wisely.
This handy function serves as a reminder that Perl still haunts us.
Oh, right. I did some work in a ruby shop this one time. I'm super glad I don't need to remember what the hell this does, but comments do assist.
If you're on a Mac, this paired function set will let you interoperate sanely with Finder.

"f" opens the directory you're in in Finder, whereas "cdf" changes your working directory to that of the topmost Finder window.
I would show you how I handle @awscloud profile switching, but that's a nightmare for another class.
When the CEO treats "master" as his personal feature branch there's precious little you can do on your end to compensate.
This delightful trio of aliases enables something glorious. Can you tell what?
wow; such commit; very push
This concludes your whirlwind tour through my terrifying perspective on shell.
If you want to learn this stuff way better, check out wizardzines.com by @b0rk; she's got a way of making masterclasses eminently approachable.
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with HydroxyCoreyQuinn

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!