Skip to content

lodybo/dotfiles

Repository files navigation

My .dotfiles

This repo is my collection of dotfiles that I use across setups (like personal and work computers). It's based on and heavily influenced on a number of other people's work (referenced in credits).

This repository is managed by Dotbot which helps me install everything on each computer I work with. The basic setup is simple: Dotbot will (on install) copy directories and symlink dotfiles on the pc that I'm running it on. These will be my shared settings, i.e. the settings I will use everywhere (like terminal settings, aliases, and such).

Local overrides

Some configs will additionally load a local configuration file. This will then "merge" the computer-specific configuration with my shared configuration. I can have settings that I only use on my work pc without having them show up on my personal computer. This is also very handy for _super secret information_™.

The files that will look for overrides are:

  • vim (~/.vimrc_local)
  • ssh (~/.ssh/config_local)
  • git (~/.gitconfig_local)
  • zsh (~/.zshrc_local)

Topics

My dotfiles are divided in a number of topics (an idea from Zach Holman). The top-level folders are "topics" which contain configuration. It provides a cleaner overview IMO.

My approach differs from Zach's approach in that I don't load in .zsh files within each topic into my shell environment. I use Oh My Zsh's customization options that allow me to provide any shell scripts in a custom/ folder which it will load into my environment. It's also the home of my custom functions and the external plugins I want to load into Oh My Zsh. I then set Oh My Zsh' custom folder to .dotfiles/oh-my-zsh/custom so that I don't have to copy those files and can keep it up to date in my repo.

With all that said, these are the topics currently available:

  • bin: for all (cross-platform) binaries that I want to run (e.g. exa).
  • git: for my git configuration and commit templates.
  • ssh: for "global" SSH configuration that I wanna have.
  • vim: for my Vim configuration.
  • oh-my-zsh: for my custom theme and the home of the custom folder with my aliases, functions and plugins.
  • zsh: for my Zsh configuration.

npm

There is also a step that will install npm binaries globally (like rimraf which I use all the time). The list for this is in linux.conf.yaml and macos.conf.yaml.

Configurations

This repo is set up with the ability to run multiple configurations. This is so that can have a "layered" setup. I can determine which config I want to run during install and set up my environment to my wishes.

Default / Lite

The default (or "lite") version sets up my aliases, functions, git config/templates, vim config and ssh config. It doesn't change the terminal (keeping it bash), doesn't set up Zsh or Oh My Zsh and adds a few binaries to the path but doesn't alias them. This set up is exceptionally handy on servers!

Linux / full

The linux (or "full") set up builds on the default one. All the settings mentioned above are happening, but this config expands by moving the linux binaries of bat and exa into the PATH, adding their aliases, installing and configuring Zsh and Oh My Zsh, adding Zsh-related functions and installing/configuring nvm.

macOS / full

The macOS (also "full") set up does a lot of the things the linux install does (but then obviously set up for a mac), but it also sets up the osx plugin in OMZ, sets up some Mac specific settings and installs Homebrew.

Getting up and running

In order to set all of this up you need to have a system set up running the following:

  • git
  • curl (or wget)
  • python

We'll start with the lite install

Installing dependencies

The first step is to install these dependencies before we can go any further:

# Update packages
apt update

# Install needed stuff
apt install -y git curl python

Cloning this repo

The next step is to go into the /home/ folder and clone the repository. I'd like to put it into a dotfolder.

cd ~
git clone https://github.com/lodybo/dotfiles.git .dotfiles

Installing the Lite version

The steps thus far are all we need in order to install the default / lite version of our .dotfiles. We can now cd into our folder and start the install script:

cd .dotfiles
./install

Installing the Linux version or macOS version

If we want to set up the Linux or macOS version (the "full" one), we need to install Zsh, Oh My Zsh and nvm. We can run the following commands for that:

apt update

apt install -y git curl python zsh

# Install Oh My Zsh and nvm beforehand so that we can restart the shell.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

# Source nvm and install latest Node LTS
. ~/.nvm/nvm.sh
nvm install --lts

In order to run the configuration we need to specify that to our install script. It takes an argument like linux or macos (I wouldn't add them both).

cd ~
git clone https://github.com/lodybo/dotfiles.git .dotfiles
cd .dotfiles
./install linux
# or
./install macos

macOS and ITerm2

On macOS I'm using ITerm2. Some of the configurations are loaded inside the dotfiles repo, but that also means that we need to sync it with the ITerm2 instance on the machine. I'm following the guidelines found here: https://shyr.io/blog/sync-iterm2-configs. Basically it says that we need to enable both options in the General > Preferences section.

SSH profiles

My default ITerm2 profile is based on the Nord colorscheme. However, when I use ssh (for example to connect to a production server), ITerm2 will automatically switch themes. This will alert me and tell me that I'm currently in the Danger Zone.

The switch is being done based on a list of hosts that is stored in the DOTFILES_ITERM_SSH_PROFILES variable. In order to add a host to that list, do something like this in one of the startup scripts (preferably ~/.zshrc_local):

DOTFILES_ITERM_SSH_PROFILES="$DOTFILES_ITERM_SSH_PROFILES|lodybo.nl"

I used the zsh code found here.

For a list of themes to change to, check out: https://iterm2colorschemes.com.

It's possible to go nuts with this, for example selecting a theme based on certain servers. Production servers could be red, staging servers could be purple. For more ideas, read this post: https://coderwall.com/p/t7a-tq/change-terminal-color-when-ssh-from-os-x.

Credits

Like mentioned earlier, my dotfiles are heavily influenced/based on other people's dotfiles repositories. They're marked below:

  • anishathalye: because of his work on Dotbot and his explanatory blog post which got this whole circus starting, and for some inspiration for my dotfiles.
  • holman: because dividing my dotfiles in topics seemed like a very good idea, and for some inspiration for my dotfiles.
  • caarlos0: for inspiration for my dotfiles.
  • zvory: for inspiration for my dotfiles and handling cross-platform stuff.
  • Mathias Bynens: for inspiration for my dotfiles (especially the macOS part).
  • Alex-D: for the WSL2 bridge script.
  • Shayne: for some WSL hacks (the rc.local boot script, and copying IP's).

Other people I want to credit for their contributions:

  • amix: for a very concise Vim setup. I used the basic configuration.
  • simonista: for any additional Vim configuration.

Contributing

Since this repo is essentially always present on my development machines AND in use, development can be considered "always on going".

However, there is a way to test this repo in a new linux install, with Docker.

Testing in Docker

Docker is an excellent tool to test the effects of this repo with. For my convience, a Dockerfile is included in the repo. This will set up a basic environment, based on Ubuntu, installing the necessary dependencies (including Vim, for editing), creating a user called tester, and adding the current repo as /home/tester/.dotfiles.

You can build the Dockerfile thusly:

docker build . -t dotfiles-test

You can run it thusly:

docker run --rm -it dotfiles-test

If you're lazy, like I am, you can run run-docker-test:

./run-docker-test