Modern web development seems to regularly forget that simple is a good thing. Logging in to ctrl-c.club is almost meditative.
Perhaps we need a yearly 'remove something from your dev stack' day. Because I would be willing to bet everyone's
package.json has a dev dependency they could remove with an NPM script running a bash command, or a few-line function in their task runner.
It's not that you need to reinvent every wheel, it's more that it's worth remembering that package management isn't free. Your time is a cost. A third party package could suddenly demand your time on its own schedule - leftpad being the obvious extreme example.
Anyway, this is just a half a thought, captured while I mooch around the CLI.
a little trick
Bash often pops up a little useful trick. This week I needed to quickly draft an article between 500-1000 words. I'd written it in a text file as I basically just opened a new tab in Sublime and started writing.
Checking the word count was easy:
wc -w draft.txt
It's a reasonably accurate count, too. Handles hyphenated and contracted words and so on; but it doesn't ignore things like wiki markup (eg. I had lists with
* markers and they were counted as words). Still good enough for what I needed though, since I just needed to land in a word count range.
The thing about bash (and unix generally) is you are exceedingly unlikely to be the first person who needed to do a simple task. A quick google search will usually give you the answer. You don't have to remember that
-w to just return the word count, you really just need to remember there's a word count command and know how to check its usage (
So much of bash configuration and behaviour is about context - where are you, where is the process running.
I was really confused why my vim settings weren't applying while editing something in
/etc/. Took me a while to realise duh my settings will only load if I start vim somewhere it can see the
.vimrc. Start vim from
~ and use
:edit /etc/foo... lo and behold, my settings applied.
Simple......once you know the answer.
the vibe of the thing
I've been pondering why I'm having so much fun messing around with bash. This essay certainly feeds into the general feeling: The Elements Of Style: UNIX As Literature (unrelated topic but still curiously current, by the same author: Howl.com - Salon.com).
When the web became a Thing™ in my home town, the first move was the local library became an ISP. The internet did not arrive as tech, it arrived as information. I went to university and studied Journalism and Philosophy; and procrastinated from study by hand-coding web pages. My first paid web-ish job was building and education kit for school kids to learn their local history.
The internet is words. We dress it up with images and compress words to emoji and use video to move words around, but the internet is fundamentally about communication.
Somewhere in all of that, bash (or *nix if you prefer) has persisted. It's still words. You type words, machines do things for you, other humans see words.
It's the vibe of the thing.
If you use bash for a while you will inevitably have to run something as
sudo. Or more likely, re-run something as
As a beginner, at first you'll laboriously retype the command with
sudo prepended. Then you learn about bash history; so you hit
↑ and just insert
There's an even quicker way though:
sudo !!, which basically means run the previous command as sudo.
$ makemeasandwich ERR! Please try running this command again as root/Administrator. $ sudo !! (makes sandwich)
Because re-running things as sudo is annoying, I indulge my profane sense of humour and alias this to
$ makemeasandwich ERR! Please try running this command again as root/Administrator. $ ffs (makes sandwich)
If you're new to bash/cli, I recommend you take a few minutes to customise your tools. While that may seem superficial, I've noticed it makes a huge difference to how comfortable you'll feel using the system; and in turn, how likely you are to stick with them long enough to learn them. The defaults tend to feel unfriendly - OSX's black and white default theme is very hard on the eyes, for example.
So what are some good things to change? IMHO:
- Your terminal's default font and colours. I like to set text to Consolas, bump up the font size and use classic green-on-black. There are no right answers here other than to point out you should pick something you can comfortably look at for long periods.
- Learn how to customise your
aliasfor commands you run frequently, in your
~/.bash_profile. A really common hack is to set up
alias ll="ls -l"or override
lswith your usual settings (you can always run the un-aliased ls with
- If you use vim, set up your
syntax onand add a good highlighting scheme (eg. I'm currently using Monokai).
These steps alone will go a long way towards making the prompt feel like it's yours. Personalisation like a good set of aliases makes things more efficient; while the right colours and typeface make things easier to read. Above all, it'll help make the command line feel like somewhere you want to be working; and that's important.
hello, cruel world
Just a little file written in
ssh and set in predictably bash-y green and black. Oh yes we're in the matrix here ;)
There's something enjoyably minimal about using these tools. They speak to both the old and new - old tools, still used in a new world. A reminder of a different era where the web was text and emoji were nothing but a glint in an emoticons eye. Yet the bash prompt quietly lives on, powering the production of the latest and greatest web sites and apps.
For all of the advances we make, everything old is new again.