Sometimes I talk to friends who need to use the command line, but are intimidated by it. I never really feel like I have good advice (I’ve been using the command line for too long), and so I asked some people on Mastodon:
if you just stopped being scared of the command line in the last year or three — what helped you?
This list is still a bit shorter than I would like, but I’m posting it in the hopes that I can collect some more answers. There obviously isn’t one single thing that works for everyone – different people take different paths.
I think there are three parts to getting comfortable: reducing risks, motivation and resources. I’ll start with risks, then a couple of motivations and then list some resources.
I’d add ImageMagick for image manipulation and conversion to the list. I use it to optimize jpg’s which led me to learn more about bash scripting.
No need, GUIs are better for most tasks.
GUIs are easier to learn, but they are not always available. Many services only have a CLI client. If you are connecting to a remote server or, especially, a container to debug it, it may not have a window manager installed. If you know how to do something via the CLI, you can automate it with a shell script.
They basically aren’t?
If you’re doing one-off hobbyist stuff, maybe.
But literally anything in a professional setting should be in text that can be committed and searched in a source code repository. If you can’t commit it to git, it didn’t happen.
I’m not sure if you’re being funny, but of course committing the output of your program isn’t what I was saying.
It really depends. Maybe developing something like a game will require (almost) no CLI.
But do a little bit more server stuff, dev-ops, and you can literally not even do the job without cli.
Though in general, CLI is often better for the task, it often can easily be automated (via scripts etc.), which seems to be relevant for a lot of tasks programmers do…
Electroshock. I that is too “harsh” or “inhumane” then a cheat sheet.
At the end of the day the command line is a tool that you are using to do something. If I have to google “how to commit file changes to bitbucket using the command line”, I’m probably just going to use whatever GUI tool is available. Or I may do something really silly like manually copy the changes into bitbucket’s web interface. If I had a cheat sheet easily available, then I would just look at that. The rest is just practice and repetition.
Just throwing this out there. It really helps if everyone on the team is comfortable enough to ask for help. If you are a manager, it’s your job to create this kind of environment. And if you see some newbie data analyst that just learned python and is intimidated by a bunch of software engineers copying a bunch of changes into bitbucket’s web interface. Don’t tell them that they are doing it wrong or they don’t know what they are doing. Just say “hey, there is a much easier way to do that” and then show them. If a tool makes somebody’s job easier then they will use it.
Can’t live without oh-my-zsh, powerlevel10k and zsh autocomplete/autosuggestions plugins. It’s the first thing I install whenever I’m on a new computer.
And if I’m constrained to Windows (for work) then posh-git and PSReadLine is the next best thing.
Fish: look what they need to mimic a fraction of our power
I’ve seen quite a few articles on why you should never install oh-my-…s over the years. I’ve also never bothered to remember anything past “install the plugins and prompt separately or you will suffer”, so someone please link if you know what I’m talking about.
I’ve had ohmyzsh installed for years. TBH, I still don’t know what it gives me over bash. In your experience, what is the “killer feature” of zsh?
Not OP, but I very recently switched from bash. Autocomplete with suggestions is a way better exeperience on zsh than bash.
The way you can choose between options of the autocomplete/suggest interactively feels way better than bash.
I set it up to be case-insensitive, so I can type cd dow
and it will become cd Downloads
.
Gettig autocomplete for both kubectl
and its alias k
is seamless in zshrc but requires an extra line with a weird dunder function in bashrc.
This is just what I found in a few days of using it. There was no learning curve at all, everything just felt easier.
Can’t live without oh-my-zsh, powerlevel10k and zsh autocomplete/autosuggestions plugins. It’s the first thing I install whenever I’m on a new computer.
I run this exact same setup, it’s pretty much a prereq on a fresh install. I wonder if we’ve all been exposed to the same blog articles
Maybe see if you can introduce them to a GitHub project or tool that you think they’ll find interesting or useful. I know there are a ton, but I’m not coming up with anything off the top of my head. But if you can give someone a reason to be in the CLI, then they may start to branch out a bit more. I started learning more about the CLI when I started seeing it as cool. Yes, I’m a nerd.
That’s a good article. From my observation, there are a few things:
- Necessity. I’m active in communities with people who don’t use the terminal until it’s an absolute necessity. Like people running unraid, docker, or whatever containerized server. Eventually they need to type commands.
- The prettiness. Yeah, I run oh-my-zsh. It’s nice having a setup pretty environment. Some people’s only experience might be opening up the powershell default display to run one command… And that is a bad experience.
- Niche commands/programs. Take ffmpeg as an example. It’s probably the most powerful media tool that exists, but has no official gui. And it’s expansive enough that no GUI really covers what it can do. There are a bunch of other things like this.
Edit: And yeah, git. I’ve never used a graphical client. Seen a handful in use and don’t like it.
You’ve never used a graphical git client?!
I’m comfortable on the command line but a decent git UI is a way better experience.
git diff
is so basic using a GUI makes it far easier to compare changes.
Same for merge conflicts. I’m not sure you can even resolve them on the CLI?
Any form of rebase: I think I used the CLI to do an interactive rebase a few times in the early days but I’d never do so without a GUI now.
Managing branches: perhaps I’m a little too ott but I keep a lot of branches preserved locally, a GUI provides a decent tree structure for them whereas I assume on the command line I’d just get a long list.
Managing stashes: unless you just want to apply latest stash (which admittedly is almost always the case) then I’d much rather check what I’m applying through a GUI first.
There are some things I still use the CLI for though:
git remote add
git remote set-url
because I’m just too lazy to figure out how to do that in a GUI. It’s usually hidden away somewhere.
git push --force
because every GUI makes it such an effort. C’mon! I know what I’m doing - it’s /probably/ not going to mess things up…
Same for merge conflicts. I’m not sure you can even resolve them on the CLI
How are they solved when using a GUI? When using cli, it simply tells auto-merging failed and you can open the conflicting files in a text editor and solve the conflicts, then add them and continue the merge.
Managing branches: perhaps I’m a little too ott but I keep a lot of branches preserved locally, a GUI provides a decent tree structure for them whereas I assume on the command line I’d just get a long list.
git log --graph --all --oneline
There’s also --pretty, but it uses a lot of screen space.
Managing stashes: unless you just want to apply latest stash (which admittedly is almost always the case) then I’d much rather check what I’m applying through a GUI first.
You can attach a message when stashing with -m
.
And you can check them out by doing git checkout stash@{1}
or similar.
I use git on the CLI exclusively. I almost never rebase, but otherwise get by with about 5-10 commands. One that will totally change your experience is git add -p
I also have my diff/mergetool configured to use kaleidoscope, but still do everything else in the CLI.
git add -p
is great to know, but IMO one shouldn’t rely on it too much, because one should strive committing early and often (which eliminates the need for that command). Also using git add -p
has the risk of accidentally not adding some code that actually belongs to the change you are trying to commit. That has happened to me sometimes in the past and only later do I see that the changes I commited are broken because I excluded some code that I thought didn’t belong to that feature.
-p –patch
Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index.
This effectively runs add --interactive, but bypasses the initial command menu and directly jumps to the patch subcommand. See “Interactive mode” for details.
The documentation is entirely meaningless? What does it do?
To be fair, I like to use VSCode for resolving merge conflicts, because it is easy to see the deviations and apply/edit as needed. Still, I use the CLI for everything else, including commiting that merge. Plus the gh cli client when I’m using github as I can create a repo or push a repo with zero effort.
It is possible to resolve conflicts through any text editor, but not an amazing experience.
I also exclusively use the git CLI. I have tried to use a graphical client and could never figure out what it was doing and what was going on. I probably picked it up so easily because when I learned git, I was already used to using a CLI version control client. At the time, I was working at a company that heavily used Perforce and had a custom wrapper around the p4
cli that injected a bunch of custom configuration.