In the last 4–5 weeks, I have really started to get comfortable in Go and TypeScript, but also…in my terminal. As new devs, I think we tend to forget the power of efficiency that your terminal gives you. How efficiently and quickly you get your tasks done sometimes boils down to how little you touch your mouse. I recently took a 4 week course from John Hopkins University on Unix on Coursera, and it was fantastic. Here are my favorite tools that I use daily in my work:
- The most basic and most useful:
cdIf changing directories isn’t the first thing you learn in your command line, I don’t know what is. The power of moving through all your files and folders seamlessly without needing to visually search: *chef’s kiss*. Don’t forget
cd ..to move back/up and
cd ~to get back to your home directory.
- Another basic:
Forget what’s in your current directory? Type ls and see all the files and directories you can head into.
In my bootcamp, I saw a lot of my instructors creating folders and files from VSCode. Of course, this isn’t a bad way to do it. And it’s pretty quick as well. But what’s faster?
mkdir. In your terminal, type
mkdir <directory-name>. A nice
lswill show you that you just made a new folder with that directory name.
If you change your mind,
rmdir <directory-name>removes that directory.
Going along with
touchcreates files. I notice myself using this a lot in React. Rather than creating components and containers after components and containers in VSCode, a simple
touch <file-name>in your terminal does the same thing. Use a relative path or
cdinto the right directory if needed. Use
rm <file-name>to remove.
This will add the file right where you want it:
Some people use command+K to clear our their terminal, but I like
clear. With clear, if you need to, you can always scroll up and see what you were just doing. For anxious-folk like myself, it can be a real lifesaver where command+K would be a real nightmare. But if you’re already used to command+K, the next one is your friend.
Ever wondered what were your last command line commands? Yes, the up and down arrows show you them one by one, but
historyshows you all the commands you’ve written in this current shell. A life saver when you need a command you used an hour ago and can’t remember for the life of you what dependencies you used. Now, instead of re-googling that command,
historywill show you right away.
The terminal’s own
I don’t actually know what to call this, but it’s NOT “greater than” (The command line has
-gtfor greater than).
>lets you add lines to files, or add files into files. Say you want the line “There will be ice cream” in a file. No need to open that file and type it in there. From your terminal, type
echo "There will be ice cream" > file-nameand there you go. That line is now in your file.
Speaking of adding things into files, say you want a whole file’s content to also be in another file.
cat file-name > other-file-name.
OR, you have a small file you need to read the contents of:
cat file-name. There’s the file’s content right in your terminal.
Move. You want to move a file into a different directory?
mv file-name directory-name. Simple as that.
Copy. You want a file to stay in it’s current directory, but also be in a different directory.
cp file-name directory-name.
Saving the best for last, say you want to see what other commands are out there for you in your terminal,
manis your directory of command line commands. If you have a specific command that you forget what dependencies you can add to it to get the exact action you want,
man command-nameto see that specific command’s definition and possible dependencies.
As junior developers, we are always searching for the next language/framework to learn or the next data structure and algorithms course to take to ace our interviews. But I’d like to challenge all of us to take a breather and think about what would make me the most effective programmer right now? The truth is, you’ll always have to continue learning, whether you have a job or are searching for one. But as time goes on in your career, you’ll have less time to code the same amount of work, so get good at being as efficient as possible from the beginning and embrace your command line.