Dotfiles | Install scripts
PostedI have had my dotfiles on Github for a while now, but have been really messing with them lately. They contain a few really clever bits that I thought were worth going over. This will be a series, where I go over various sections of my dotfiles, with a highlight on anything that I find to be exceptionally useful, something I haven't seen very often, or anything I created myself and find myself quite proud of. Here are some of my favorite things from my install scripts.
I often reinstall my OS or set up new devices. I have put instructions to get up and running very quickly in my readme. This is mostly for my personal use, to refresh my memory or allow me to copy/paste the commands, but is probably useful to others as well. In a nutshell, after a fresh install, I put in my SSH keys from a keydrive I keep on my literal keychain. I then clone my dotfile repo, and with a single make
command I will be in a comfortable environment.
A quick introduction to make and makefiles, and a confession: I am not super familiar with make files. They are used to trigger a sequence of commands. They are normally used when building software from source. The makefile will link different libraries and call the build in different ways depending on the machine environment it it being built in. I am not doing anything that complicated; I'm just installing software and moving config files depending in different ways. I may later look into how I can modify this to detect automatically if the system is based on Debian or Arch, but this works just fine for now.
arch: archinstall dirs all link yay
deb: debinstall dirs neovim all link
This is the single command to install all my setup on a new system. It simply calls other commands in a certain order. Those commands vary depending on if I'm on a system that uses pacman such as Arch, or apt such as Debian or a Chromebook's Linux layer. I will still have to do some basic setup like choosing a wallpaper and installing language servers in Neovim, but I can still hit the ground running within 15 minutes or so of completing a fresh install.
archinstall:
sudo pacman -S --needed -< ./pkgs.arch
debinstall:
# Install packages
# for i in $$(cat pkgs); do sudo apt-get install $i; done
xargs sudo apt-get install < pkgs.deb
# Install starship
curl -sS https://starship.rs/install.sh | sh
I have two concurrent lists of packages to install, for both Arch and Debian. These are simply files with one pachage name per line. This will install all packages in the applicable file. The Debian version also installs the Starship prompt, which I really enjoy in my command line. I don't install a lot as I prefer a simple tiling window manager (currently migrating from awesome to i3) and most of my time is either in Chromium or a terminal (currently kitty).
dirs:
mkdir -p ~/Desktop ~/Documents ~/Downloads ~/Google ~/Music ~/Pictures ~/Projects ~/Public ~/Templates ~/Videos ~/.config/rclone
cat rclone.txt > ~/.config/rclone/rclone.conf
rclone config reconnect drive:
Some distros (base Arch, for example) don't automatically create the standard home directory structure. This allows recreating easily, as well as setting up rclone to allow for accessing my Google Drive seamlessly with the rest of my file system. A future post will both cover why I choose to use rclone to access my drive, as well as the clever bit in setting it up.
neovim:
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz
sudo rm -rf /opt/nvim-linux64
sudo tar -C /opt -xzf nvim-linux64.tar.gz
rm nvim-linux64.tar.gz
The version of NeoVim in the Debian repo is woefully out of date, and this is one of my most-used applications so I like to have access to the latest features. This will install it in a single line from Neovim's download site. I can rerun the line to upgrade as well.
all:
stow --verbose --target=$$HOME --restow */
delete:
stow --verbose --target=$$HOME --delete */
Calling make
with no arguments is the same as make all
, which updates all my dotfiles. They are processed with GNU Stow. There are several resources on how to use stow and git to manage dotfiles, but the one I originally found (and cannot find anymore) suggested using make to actually run stow, which was the beginnings of this file.
link:
echo 'source ~/.bash/source' >> ~/.bashrc
echo 'source ~/.bash/profile' >> ~/.profile
echo 'source ~/.bash/logout' >> ~/.bash_logout
My bash scripts are not in the preconfigured files (.bashrc, .profile, .bash_logout). Instead, they are in the .bash directory and this will pull them in from the existing dotfiles, if any exist. The advantage of this approach is that any distro-specific config done by the distro will not be touched or carried from one system into another. This makes distro-hopping less painful. This is a separate section as it should only be called once per machine, else the files will all be run twice. The way these files are set up will be the topic of my next post.
yay:
sudo pacman -S --needed git base-devel && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si
yay -Y --gendb
yay -Syu --devel
yay -Y --devel --save
cd ..
rm -rf yay
Yay is a wonderful frontend to pacman, that also opens up simple access to the AUR, but takes a few steps to install and set up. With this, that is reduced to a simple make yay
.
This makefile is quite short compared to the typical makefile, which is normally used to kick off compilation of an entire application that may be used on all types of hardware. However, it is able to reduce the time for setting up a new computer to just a few minutes and commands. If you choose to use it on your own system, you will need to make changes to suit your own needs, of course, but I have used this at least a dozen times and would say that I have saved a combined total of 24 hours, at least. Not bad for something that has been pieced together as my needs have changed and has less time invested in it that this article about it.
I hope you have picked up some thing useful from this article. The next article in this series will be coming soon, and is about how I have my bash config set up.