This post is for those who are scared of using the command line.
I have switched back and forth between Windows and various Linux distributions for the better part of 3 years.
Frustration about lack of hardware or software support, inability to play some games, and most importantly, using the terminal, were some of the biggest factors which made me go back to Windows from Linux every time.
It wasn't like I was not touching the terminal at all; installing NPM dependencies, changing directory, even simple editing with VI are not the challenges with using the terminal.
The issue was leaving the terminal to search for a command I just used 5 minutes ago or forgetting the correct flag for a certain command that did not have a detailed man page.
So I was stuck in eternal limbo, bouncing back and forth with operating systems and other command tools.
That was until I found the subreddit that changed my view of the terminal (literally) - r/unixporn
After spending way too much time researching and testing out various terminal emulators, colour themes, and fonts, this is my current terminal start-up view.
Let's dive into some programs which helped me use the terminal for programming!
You open a terminal, and bam, you're faced with a black screen with a blinking white line.
What do you do next? Why is the white line blinking? What do you type?
The oncoming feelings of confusion and helplessness can be overwhelming and many stop there.
Searching is familiar, we're all used to using a search engine to solve our problems, and most searches gives many matching options and even account for our spelling errors.
The default terminal doesn't have any of those, so here are my favourite programs that can help you find the file or line you need.
While fd (file finder) and ripgrep (text searcher) can be used by themselves, I felt the real power came from using them in conjunction with fzf, the fuzzy finder. The combination of these tools allows a filter-based workflow where you can change the search input and the results will dynamically change. My favourite is using it within Neovim.
Another useful tool for everyday use in the command line is auto-complete. Sometimes we just forget what we need to type or forgot the full command.
In these scenarios, zsh-autosuggestions come in handy. This plugin for ZSH by default checks your command history for a command that matches what you're typing and you can bind that to any keyboard short-cut to auto-complete.
If you mistype frequently and don't have the self-control to not press enter, here's a program which might tickle your fancy: thef*ck
Is The Fuck too slow? Try the experimental instant mode!
➜ apt-get install vim E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? ➜ fuck sudo apt-get install vim [enter/↑/↓/ctrl+c] [sudo] password for nvbn: Reading package lists... Done ...
➜ git push fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin master ➜ fuck git push --set-upstream origin master [enter/↑/↓/ctrl+c] Counting objects: 9, done. ...
➜ puthon No command 'puthon' found, did you mean Command 'python' from package 'python-minimal' (main) Command 'python' from package 'python3' (main)…
Thef*ck has an interesting history, originating from Twitter and gone on to amassing 56 thousand plus stars on GitHub. It's essentially an auto-correct for your previous command based on a set of rules for common CLI programs (you can find the full list of supported programs on their README). While I don't personally use this, it's really cool in the sense that it was inspired by the community and reminds me of what open-source is about.
This section is about blinging up your terminal. ✨
As you can tell, I already customized the colour scheme and fonts of my current terminal. However, this section is for the other parts of using the terminal which usually lacks coloured outputs such as
For starters, I use zsh-syntax-highlighting, a plugin to highlight commands and strings in your input. To be honest, I think this is why I don't need thef*ck most of the time, if I see the program command highlighted in red it either means I miss-typed it or it doesn't exist on my system.
Finally, a common workflow I found myself doing was running
git status and having to print the files out to see what I changed. Instead, there is a program known as forgit which gives interactive previews to common git operations. Powered by fzf and optionally bat, you can see the actual diffs of files before you add them or when looking at previous commits.
Wrapping up all my terminal programs is tmux, a split-screen, multi-tab, terminal session manager can be manipulated all in one window. It's basically how I can have "one" terminal window open all the time, only alt-tabbing for browser and other GUI apps.
Tmux honestly has too much going for it (including paired programming) that I am not really doing it justice saying it's just for split-screen and tabs.
For example, it has its own plugin ecosystem, including tmux-resurrect which can store and restore your session, tabs and splits included, allowing you to pick up your work where you left off!
So these are my favourite command-line programs which helped me start using the terminal on a day-to-day basis!
I hope you found something interesting and let me know if you have any suggestions in the comments!
Follow me on Twitter @justinhodev to keep up with my daily code bits!
To manage all of these program's configuration can be a massive pain. Instead, because all of the configurations are managed in files (usually preceded by a dot), people have figured out to just store them as a git repository to make it portable and all the other advantages. If you read posts from r/unixporn, you'll find people talking about "dots" or "dotfiles" which is referring to these configuration files. Here's an article I followed to set up my own dotfile repository: The best way to store your dotfiles: A bare Git repository.