side quest
Legacy systems at work required me to learn Powershell and maintain windows builds for a couple of years. It wasn't terrible but it certainly wasn't good. I'm not under illusions that bash is somehow the greatest technology ever created, but the way dotnet ecosystem stalwarts go on you'd think Powershell was.
My thoughts? Not really. It's just bash but more verbose and with extremely irritating error handling.
If you have to use it, it's fine. If you have a choice, stick to linux servers and bash scripts.
If I was starting from scratch tomorrow though, I might use Node or Python for scripts - particularly if I had to support multiple platforms for development. The hit on runtime installation isn't that high any more, even on windows boxen (where you can use WSL, Docker or pair Chocolatey up with Powershell).
But still... getting properly into bash keeps paying dividends. Truly the gaffa tape skill of CI/CD.
2020.08.20
still thinking
Nothing since 2016... where does the time go? Funny how ideas rattle around though. Doing a talk this coming week about using simple tools; and included things I wrote in the last post. The industry is still addicted to complexity and we still need to reset that kind of thinking.
2018.09.23
simplicity
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.
2016.12.17
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 wc
needs -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 (wc --help
).
2016.06.19
intricacies
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.
2016.05.28
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.
2016.05.22
the ffs
alias
If you use bash for a while you will inevitably have to run something as sudo
. Or more likely, re-run something as sudo
.
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 sudo
.
There's an even quicker way though: sudo !!
, which basically means run the previous command as sudo.
Hence:
$ 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 ffs
.
$ makemeasandwich ERR! Please try running this command again as root/Administrator. $ ffs (makes sandwich)
2016.05.20
bash customisation
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
$PS1
and usealias
for commands you run frequently, in your~/.bash_profile
. A really common hack is to set upalias ll="ls -l"
or overridels
with your usual settings (you can always run the un-aliased ls with\ls
). - If you use vim, set up your
.vimrc
, setsyntax on
and 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.
2016.05.18
hello, cruel world
Just a little file written in vim
via 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.
2016.05.17