I'm pretty lazy, but lazy in a productive way. I don't like doing the same thing over and over, so I spend a little extra time and effort once so that I can be lazy in the future. This works well most of the time, but if I use someone else's machine I feel like a toddler again. Or if I get a new computer…
Recently my work kindly sent me out a new MacBook Pro. The old one started to levitate because its fan was running so hard. I like my new machine, and thought that I had set up all my tricks within the first few hours, but my muscles have a longer memory than I do apparently. I keep doing things that just don't work on this new machine…
Here are 5 things that I absolutely must do to any new development machine.
Zsh is great. I don't use it to its full extent, but I mainly leverage its autocomplete and reverse search features. Have a look at their website for more information and how to install.
There are some great themes available with zsh, but I created my own back in the day to get my prompt they way I like it and I've stuck with it. It sits on two lines, so you always have your cursor start at the same place regardless of how many directories deep you are, or the size of your window. It gives some git information such as the branch name, and has some symbols that appear depending on the status (uncommitted change, committed but not pushed, upstream ahead of downstream etc). It also gives the time and directory as you can see in the image above.
They weren't accepting new themes at the time, but if you like mine, you can find it on my Github. If you don't like mine, and don't like any of the themes that come standard, I'd recommend creating one yourself. I can't remember the details of how to create it, but I remember I had a blast. Have a look at existing ones and you should be able to figure out how to do whatever you want.
An alias file means that you can create your own command for whatever you want. I just use it to reduce the number of times my precious fingers have to hit keys, but you can use it however you want. I had an old colleague who used it to bypass spelling mistakes — his alias file was full of “gut pull”, “git pish” etc.
If you're using zsh you can find/create your alias file at ~/.oh-my-zsh/custom/alias.zsh
Link lot of my aliases are specific to projects that I work on, so I'll not share them here, but to create an alias it's as simple as this:
alias cdp='cd ~/projects'
I do have a handy method to create aliases on the fly which you can put into your alias.zsh file as well:
function al () {
local aliasName=$1
shift
echo "alias $aliasName='$*'" >> ~/.oh-my-zsh/custom/alias.zsh
source ~/.zshrc
}
This is useful if you find yourself in the middle of something but fed up of typing the same nonsense over and over. Use it like this:
al [aliasName] [command]
eg: al createFile touch NewFile
will create this line in alias.zsh:
alias createFile='touch NewFile'
In practically every app on Mac I can use the same keyboard shortcuts to edit my text. Not so in iTerm I'm afraid. If you want to jump back whole words at a time, or to the start of the line, you might want to add these key bindings. To add new bindings in iTerm follow these steps:
For the “action” noted in each of these, the dropdown option is italicised and the value is in bold.
Keyboard shortcut: option + left arrow
Action: Send Escape Sequence b
Keyboard shortcut: option + right arrow
Action: Send Escape Sequence f
Keyboard shortcut: cmd + left arrow
Action: Send Hex Code 001
Keyboard shortcut: cmd + right arrow
Action: Send Hex Code 005
Keyboard shortcut: option + backspace
Action: Send Hex Code 017
Keyboard shortcut: option + delete
Action: Send Text ed
Keyboard shortcut: cmd + delete
Action: Send Hex Code 0B
I could probably reduce the number of keys I hit to a ridiculously low number by using code snippets, but I really only use one or two with frequency.
To create a snippet go to Code>Preferences>User Snippets and choose to create a new one. We're going to call this one javascript.json because that's what I write most days. Here are my three most used snippets:
"Print to console": {
"prefix": "console.log",
"body": [
"console.log('$1', $1)",
"$2"
],
"description": "Log output to console"
},
"describe": {
"prefix": "describe",
"body": [
"describe('$1', () => {",
"$2",
"})"
],
"description": "describe block"
},
"it": {
"prefix": "it should",
"body": [
"it('should $1', () => {",
"$2",
"})"
],
"description": "it block"
}
The first snippet allows you to console log the output of a variable next to the string of the variable name, ie console.log(“variableName”, variableName);
The next two snippets help with TDD. You can enter describe and it block without having to faff around with brackets and functions. The first editable option will be the name of the block, and pressing tab will put you into the body.
I'd love to know exactly how much time these snippets have saved me over the years, but I'm sure it's into days now.
Self taught software developer with 11 years experience excelling at JavaScript/Typescript, React, Node and AWS.
I love learning and teaching and have mentored several junior developers over my career. I find teaching is one of the best ways to solidify your own learning, so in the past few years I've been maintaining a technical blog where I write about some things that I've been learning.
I'm passionate about building a teams culture and processes to make it efficient and satisfying to work in. In many roles I have improved the quality and reliability of the code base by introducing or improving the continuous integration pipeline to include quality gates.