The whole point of computers is to make things easier.

When you're learning all about how complicated they are, there can be a tendency to revel in that complexity. If you're not careful, you could end up being a Windows network technician or something - if you're smart, you'll try to make your tools get out of your way, at the very least and better still, they could actually help you to do things quicker and better, instead of forcing you to fill your head with the arcane details of how everything works.

Setting up bash aliases and scripts to get things done is a good example of this.

Here are some things that I have found useful to change on my MacBook, to make life easier at the command line.

When I list things, I basically always want the long listing, so I alias one to the other - beautiful.

I use Tiddlywiki to run Node servers that serve my notebooks. Some of these are public by default, like the one that I use to build this website, but some of them are for my private notes. I back those ones up by having them read and write from my iCloud directory (I also have Time-machine making local copies of them, but if you can have off-site backup for zero cost or ongoing effort, you really should.

The only small problem with doing that is that the iCloud folder is located at a long and difficult to remember path

PATH

Instead of remembering that every time, I can alias it to something I will remember, like say "icloud".

ALIAS

Bash Scripts

When I run Tiddlywiki, I specify the port that I want it to serve on which means I can start several at once by specifying different ports.

This means I could alias the tiddlywiki command like this

alias tw="tiddlywiki --server"

and invoke it like this

tw 8080

The wrinkle here is that I often want to make these servers available to my local network (instead of just localhost), which I can do, but I have to pass the right parameter, which means I now have to type

tiddlywiki --server 8080 $:/core/save/all text/plain text/html "" "" 0.0.0.0

As you can see, because I need to set the seventh parameter, I also need to provide the other parameters, meaning I would have to remember them all every time.

In practice, of course, I find myself hunting through my history for the command and changing the port number. I can't just alias this command, because the port number isn't at the end.

Instead I can write a short program, with a variable and run it from the command line.

Writing the script is pretty easy, as long as you know how to reference command line arguments as variables, and you know the magic words to put at the top of the file to identify it as a bash script.

If you want to be able to run it from anywhere, you should put it somewhere on your path, strip off the ".sh" extension and make sure you have permission to run it.