I just wiped my Mac and reinstalled everything and as I was doing so thought about various stuff I do to stay productive on the computer1. This list is as much for my own reference as anyone else’s and to some degree is an expansion of the UsesThis interview I did in 2017.
We all know that e-mail is the worst.
I use Thunderbird for e-mail. I like it because I can use if offline (I like working where there is no wifi) and I have all my messages and attachments on the computer in front of me. I used a couple of other programs years ago (Mail.app and Sparrow) but neither were as good with large inboxes (mine now dates from about 2004). I’m sure you can do similar hacks with other e-mail clients, but these tips are Thunderbird only.
When you’re online you will get messages. These will be distracting. Step one is to make sure that Thunderbird starts up in offline mode and doesn’t look for new messages. That way if you want to just write a message you don’t look at all those new messages.
In the “Notifications” Preference Pane you can turn all this off. No sounds, no pop-ups, nothing.
There is a great plugin for Thunderbird called Send Later. When in offline mode, you can set a time/date for the message you are writing to send. This can be useful when “away” but when you don’t want to set the expectation that you will immediately respond to messages (e.g., waking up early with jetlag on vacation and getting to grips with your inbox) or to set a general “office hours” rule (e.g., “I don’t reply to e-mails outside 9-5 GMT).
I aspire to (though at the moment rarely achieve) Inbox Zero. This involves a lot of moving messages around (or deleting them. Nostalgy helps with that by letting you move messages using the keyboard only (much quicker than navigating a folder hierarchy using the mouse).
A lot of my computer time is spent developing software, here are some tips for particular programs (mainly I used
vim and R, so that’s a lot there…).
I use this script to give me a useful
git prompt on the command line, telling me which branch I’m on, whether I have uncomitted changes etc. Once you’ve put the script somewhere useful, you’ll need to add something like the following to your
# add to prompt when in a git repo source ~/.git-prompt.sh PS1='\u@\h \W$(__git_ps1 " (%s)")\$ ' export GIT_PS1_SHOWDIRTYSTATE=1
This can be especially useful when going in to do a “quick fix” and having forgotten that you’d already made uncomitted changes previously (obviously I’m very professional and this basically never happens).
As mentioned above, I sometimes leave uncommitted changes in my
git-unsaved that lets you check which folders with
git repos in them have uncommitted changes. I keep all the projects I’m working on in a folder named
~/current, so I set up the following
bash alias (having installed
git-unsaved) to check any repos in
alias tocommit='git-unsaved -p ~/current'
(Note, you need to have
npm installed first, which you can do with
homebrew for example.)
I use the
vim-rmarkdown plugin for
vim to highlight RMarkdown properly.
.bash_profile I have a few shortcuts setup for R development. I’ll walk through them…
alias R='R --quiet --no-save --no-restore --no-environ'
This just makes sure that each R session I start from the command line is clean and won’t save anything when it’s done (
--no-save --no-restore --no-environ) and that it doesn’t print the welcome message/copyright info each time (
--quiet). The former is extremely useful when running other people’s code.
alias Rrender='Rscript -e "library(rmarkdown);render(commandArgs(trailingOnly=TRUE))"'
This creates a new command
Rrender where running
Rrender thingo.Rmd will render that RMarkdown document according to the YAML in that file.
alias purl='Rscript -e "library(knitr);purl(commandArgs(trailingOnly=TRUE))"'
This will just output all the code chunks from an RMarkdown document ignoring the non-code bits.
alias roxygenhere='R -e "devtools::document()"' alias Rinstallhere='R -e "devtools::install()"' alias Rcheckhere='R -e "devtools::check()"' alias Rtesthere='R -e "devtools::test()"'
These four are useful for package development. You run them from anywhere within a package directory to document, install, check or test (respectively) the current package.
The built-in R debugged (which last time I checked was the same as the one in RStudio) completely baffles me. Since I started using R, I’ve used the
debug package, which (to me at least) seems much easier to use. Just call
mtrace() on the function you want to debug and then step through the function (by hitting enter) when it gets called. You can then interrogate the objects that are there, save them back to your workspace (using
go() to control flow through the function.
I work as a statistical ecologist, so the main things I do when I’m not writing software is writing papers and giving talks. There are some other bits and pieces that I use to make that easier.
I write my talks using
xaringan but sometimes folks ask for PDFs of the talks (rather than HTML).
decktape allows you to quick convert an HTML presentation into a PDF on the command line. Again you can install via NPM.
This stuff may or may not be productive, but since I’m writing it for myself I’ll leave it here…
I work a lot with people in the USA, I also have many friends living there. To stop myself messing up maths (which happens often) I use mclock as a second clock, set to some US timezone, from which it’s easy to work out other US timezones (Pacific is good, as subtraction is hard).
Years ago I found this useful script for setting up a new Mac. It gives you a lot of options to choose from (and seems to get updated with each new release of macOS). My adaptation of the file is available here but it might be worth reading through the longer file to see what’s possible.
If you look at my Twitter output you’ll see I don’t really stay productive at all. ↩