Terminals are awkward, scary and old. Are you trying to be a try hard?
No.
Learning how to use the command line opens up a new avenue to using computers.
You can easily automate manual tasks with text compared to clicking buttons around
The power to chain commands together is so powerful, people get paid to do it ๐
If you want to use a remote server that a cloud platform provides, interacting with the command line is optimal because sending graphics over the internet can be pretty slow.
You don’t want to miss out on some cool open source projects
Many of those applications do not come with a GUI
shells
by the sea shoreA shell is the program that interprets the commands that you input. By default,
OS | Default shell |
---|---|
MacOS | zsh |
Windows | powershell |
Linux | bash (varies by distro) |
Popular shells, such as zsh have frameworks that can add some pizazz to your shell.
with oh-my-zsh
The following are alternative shells:
ls
cd
mv
cat
touch
rm
Flags modify how a program behaves.
When you pass a -a
flag to ls
, it will also include hidden files, A.K.A dotfiles since they start with dots
-r
keyword-rf
keyword.
But
Before you copy paste and run the command, be sure it’s not a troll and you have some basic understanding of the flags provided.
For some commands, such as git
, there is an option called dry-run
that tells you what would happen but not actually do it.
Kind of like a sandbox
$ bash -n <script>
The |
(pipe) operator allows you to perform some interesting combos with commands.
Another operator, >
(redirect) allows you to redirect the output of the command somewhere else.
$ cat exercise_4.py | lolcat -a -s 60
Your significant other gets mad at you if you don’t send them a “Good morning” text every morning, precisely at 7:00 AM. with a compliment.
With the power of automation, you can easily do so!
-- Taken from: https://stackoverflow.com/questions/11812184/how-to-send-an-imessage-text-with-applescript-only-in-provided-service
on run {targetBuddyPhone, targetMessage}
tell application "Messages"
set targetService to 1st service whose service type = SMS
set targetBuddy to buddy targetBuddyPhone of targetService
send targetMessage to targetBuddy
end tell
end run
Installing applications from this:
A package manager downloads, installs, uninstalls and automagically configures your system to be able to run the command that you want to install.
Language | Package manager |
---|---|
Python | pip |
JavaScript | yarn or npm |
Rust | cargo |
Go | go modules |
Disclaimer: I don’t main Windows
Distro | Package manager |
---|---|
Arch based | pacman |
Debian based | apt |
Fedora | yum |
CLI applications are highly configurable to suit your needs.
Warning: The rabbit hole of customization is a deep one
cd
at the speed of your thoughts
Using cd
to go to places takes too long ๐ซ
I introduce…
cd
in styleranger is a great TUI file manager with vi keybinds and file previews
When it sees a .java file, it prints ๐ฉ
Default terminal emulators can get the job done but there are free alternatives that can enhance the terminal experience.
Some terminal emulators are cross-platform, which is nice if you want to keep the same configuration across different systems.
If you haven’t upgraded to Windows 11, then the Windows Terminal is amazing.
My daily driver at the moment is kitty. I love it for the following reasons:
Notable ones that I’ve used in the past
You just bought a brand new 14“ Macbook Pro with an M2 Pro, 32GB Unified Memory, and 1TB SSD Storage ๐
What shell does it ship with?
echo $SHELL
๐คทYou have 5 seconds to delete all .mp4 files from your ’homework’ folder before your parents take your laptop but you also don’t want to delete your actual homework.
What do you do?
rm *.mp4
touch *.mp4
After toiling away for days, you finish your data structures assignment 1 hour before it’s due. You close the hundred of tabs that you used to research for the solution. You admire your elegant recursive solution. You save all your files and you close your editor. You happily go to blackboard to upload the files but it’s not at the usual spot.
cat
.fd
or find
command.You want to save the error output of your program to a file but it’s \(\left({{\sum\limits_{k=0}^\infty {\left({2 \over {3}}\right)^{k}}} - (\cos^2x + \sin^2x)}\right) \times {{-4e^{\pi i}}} + {\sum\limits_{k=0}^\infty {\left({1 \over {2}}\right)^{k}}}\) lines long.
What do you do?
./program > error.log
./program | error.log
On the first day of your programming class, your professor asks you to install Java but they make you remotely log in to a Debian Linux server on campus and it doesn’t have a GUI. What command do you enter?
scoop install java
apt install java
brew install java
pacman -Syu java