Command Line Lightning Talk
Note: Slides from this lightning talk and other talks I have written can be found on my github.
I do most my development on a Macbook pro that is usually running macOS Sierra. (Sometimes it also runs Windows 10,Linux Ubuntu or Linux Mint). All of the tips in this post are set up on the macOS Sierra part.
I have used iTerm2 since I started on the command line and love it.
Color Theme: For the Fishies is a color theme I customized myself to make everything the way I wanted. I named it “For the Fishies” because I was setting my colors while looking at ASCIIQuarium (Bonus tip at bottom of article!)
I have OhMyZSH installed to allow me to use ZSH with some fun customizations.
I use a customized theme that I built inspired by various other themes I liked bits and pieces of. For all the included screenshots, I am using amichelle2. Not a very exciting name, but I added the ‘a’ to the beginning so it shows up at the top of my themes list, and the 2 at the end after I made dramatic changes from my first theme I built.
I use homebrew for installing all the things it will let me install.
My github repo: Some Configuration Files has more of my config files that I use and want to sync up between home and work computer.
Tip 1: Set a Friendly Creature Greeting
This was one of my earlier customizations. The idea was that the command line is kind of a scary place when you are just getting started and I wanted it to say “hi”. I looked into ways of running a script or command automatically at startup and found that was super easy. All you need to do is add a quick line with the command into your .zshrc file (or whichever file you use for your shell customization).
Originally I had a simple line that just used the built in “echo” command to simply print out “Hello Michelle!”. Kind of boring. I started looking into other ways to print out things to the console. Eventually I found a program called ‘cowsay’ which is a program that generates ASCII art cows saying things. As I was looking into it, I found that you can actually generate a number of ASCII creatures, not just cows.
Installation: (Using Homebrew)
$ brew install cowsay
List all available creatures you can use besides standard cow
$ cowsay -l
More helpful commands and information about cowsay can be found on the wiki page;
In the process of finding the cowsay program, I also came across a few other nifty little programs. One of those programs was ‘fortune’ which I don’t use but is kind of fun if you want to check it out. The other one I found was magical. It is called ‘lolcat’ and it makes all your outputs rainbow.
Installation: (Ruby Gem)
$ gem install lolcat
Lolcat is a super easy program to use, basically you can just pipe any text output into it and rainbow magic happens.
Take a look at lolcat’s github repo for more installation instructions and how-tos.
I use cowsay and lolcat together to generate my magical dragon friend that greets me when I open the terminal. I like to imagine that he is with me on all my terminal journeys to help me as needed.
Code I use to make this actually happen:
$ cowsay -f dragon "Greetings, Human!" | lolcat
This snippet lives in my .zshrc file. It will slightly slow down the time it takes for your terminal to open. Make sure to restart your terminal after installing these programs and adding your greeting to the profile file to make it work!
Tip 2: Taming the ‘rm’ Command
When I first learnt about this command it terrified me. Why was there a command that I could use that could potentially erase everything on my computer?? -insert minor panic attack here- I was so worried I would do it on accident somewhere or somehow type it in on accident. One way I found to control this fear was to use an alias to block me from being able to use the command. This should not be used as a long term solution! I used it as training wheels basically to help me think about it more before I would use this command, and to help me feel more comfortable as I was learning my way around.
Using an Alias is a powerful tool that you can use on the command line. Like many command line tools, it is extremely simple, but can do awesome things. It is essentially just a keyboard shortcut/ abbreviation. It is used as a means of avoiding typing a long command sequence over and over and over. (OhMyZSH has some really cool plugins you can enable that have a bunch of built-in alias’ set up for various commands. I love all the git alias’ I have now!)
One important note when setting up an alias: It is generally not a good idea to define an alias that overrides a built-in command. You might get used to a command doing one thing, then jump on someone else’s computer or a server and run that command expecting your changed thing to run only to have the command use the default behavior. This can definitely cause problems.
Tip 3: Making Mistakes Better / Dealing with Typos
The command line is intimidating and frustrating already. Typos just make things that much more annoying. I have three programs installed that help me deal with typos.
One of the most common commands I use on the command line is ‘ls’ which is used to list out all the folders and files at a specific location. Because I use this command so often, I often type it wrong.
- This program generates an ASCII art steam locomotor.
- Installation: (With Homebrew)
$ brew install sl
Another command I use all the time is all the ‘git’ commands. Similar to the ‘sl’ program, ‘gti’ creates an ASCII vehical (GTI Car) that zooms across the screen.
- Installation: (With Homebrew)
$ brew install gti
This one is amazing because it works for basically every typo I have ever made on the command line. It is great for when you get really annoyed, your boss isn’t looking, and you just need to curse a bit at the computer. This magnificent program is used to correct your previous console command.
- Checkout the github repo for installation and usage information.
I get so annoyed by the default response! It often even asks you if you meant the thing you actually meant. But you then have to either retype the thing, use the up arrow and then arrow through to the place you need to fix the typo. It is annoying and takes time.
TheFuck makes this all better because it allows me to type the response I probably want to say anyways. “fuck”!
Final Bonus Tip
This is probably the least useful, but I just really enjoy it. It is a nice thing to look at and calm down when the command line world gets too scary.
- You can install it with
$ brew install asciiquarium
- I have mine set up with an alias, so I just get to say ‘fishies’ and I get fish!
- More Info: site NOTE: Don’t listen to that site on how to install it on mac. You can just homebrew it!
Thanks for reading!