smosa/adam
/code-and-technology
/my-favorite-machine-configs-and-scripts
/


Like anyone who sits in front of a computer all day, I have some opinionated ways on how I use mine. What follows is a collection of scripts and customizations I've developed that have stood the test of time.

Self-emptying desktop

Every 5 minutes, all files on my desktop are deleted except for the five most recent. This allows me to have screenshots automatically saved to the desktop and piled up to my hearts content. The Desktop becomes a quick working space and I never put any file there that I would need for longer than an hour or so.

In a folder that syncs across all my machines, I created several scripts

5_minute_tasks.sh
hourly_tasks.sh
daily_tasks.sh
weekly_tasks.sh

And each computer has these same files in its home folder. So inside 5_minute_tasks.sh it will run 5_minute_tasks.sh in the machine's home folder if it exists. This allows me to scope some tasks to just that machine or all machines.

Then, I set up a cronjob on each machine to run each script accordingly while logging the output to a shared log folder for troubleshooting.

# 5 minutely
*/5 * * * * cd $HOME/Sync/Adam/crontab_scripts && ./5_minute_tasks.sh > $HOME/Sync/Adam/crontab_scripts/log/arch-5m-`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1

# Daily
0 8,16 * * * cd $HOME/Sync/Adam/crontab_scripts && ./daily_tasks.sh > $HOME/Sync/Adam/crontab_scripts/log/arch-daily-`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1

# Hourly
0 * * * * cd $HOME/Sync/Adam/crontab_scripts && ./hourly_tasks.sh > $HOME/Sync/Adam/crontab_scripts/log/arch-hourly-`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1

# Weekly
0 9 * * WED cd $HOME/Sync/Adam/crontab_scripts && ./weekly_tasks.sh > $HOME/Sync/Adam/crontab_scripts/log/arch-weekly-`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1

Terminal aliases

If I do something repetitively in the terminal, I make an alias for it. If it's one I can benefit from on machines running different (but POSIX) operating systems, I'll add it to the zsh aliases file that is automatically synced and installed (using the above tasks).

Here are some examples

# Easily change directories
alias cdde='cd $HOME/Desktop'
alias cddo='cd $HOME/Downloads'

# Installing packages on Arch
alias pi='sudo pacman -S --noconfirm'
alias pr='sudo pacman -Rc --noconfirm'

# If I want to edit this file
alias za='vim ~/.zsh/aliases && source ~/.zshrc'

Distraction Free Writing by Disabling the GUI

As I write this, I am on my very customized install of Arch Linux. It's my favorite place to write because I can kill the GUI with a single command and drop into the shell. Not a terminal emulator, but the true shell of the operating system. I have no notifications, no stealing my window focus in the absence of windows, no trackpad or mouse.

I run a command that automatically runs a few commands to tmux me into an IDE-like setup with writing as the largest pane. This loads up vim with NERDTree at the top, a simple shell in the bottom left corner, and lazy git in the bottom right.

I focus just on the text, enjoy longer battery life, and can easily detach and reattach from my terminal if I want to pop into the GUI again (for example, I need to copy and paste something).

Because I use sway as my window manager without any other desktop environment, it takes about 2-3 seconds to switch back into a GUI and a little faster to exit from it. I have a two-letter zsh alias to go in both directions.

Always Migratable

Whenever I change something on my computer, I ask myself "What if I just chucked this off a bridge right now?" I'd have to buy a new computer. How much work would it be to get everything back?

My answer to this used to be having a solid backup and restore strategy but this ended up not being enough. When I got a new tablet, having a backup from my computer didn't help much. I found it much easier to be smarter about some simple configuration and employment of cloud storage.

For cloud storage, I use off the shelf consumer solutions because they make it easy to not have to think about it. For my personal operating system, I take the opposite approach on my Linux machine. Both are on opposite ends of ease vs control and customization but they are similar in how easy they make it to migrate.

For the cloud storage, I know I can go to any of my machines and easily get them set up. For my operating system, I am keen to keep my customizations cross-platform compatible where possible and the parts of the OS that I really need to back up are easy to find, because I dictate these changes at a low level.