Files
dotfiles/Install.org
dx 014f7b616a ~clean up the install.org
Structure document a bit better such that the headings are in
step-by-step order.
Add optional tag to some headings so those headings can be skipped for
the most minimal install necessary
2020-07-16 20:17:32 +01:00

4.4 KiB

Install

Introduction

Each heading is a step in the install process. Run each headings source code snippets as you progress through them. Any snippets that have the tag :optional: can be avoided, and are likely extra functionality that you can use later on.

Generate user directories

This makes some useful directories that are used by the system and/or by me. I split these into two sections so at minimum you can install the system folders and generate the user folders if you wish.

System folders

mkdir ~/.local;
mkdir ~/.local/src;
mkdir ~/.local/bin;
mkdir ~/.config;

User folders   optional

Firstly the essentials for a good user experience™

mkdir ~/Downloads ~/Pictures ~/Music;

Then generate the other stuff that I use (mostly).

mkdir ~/Text;
mkdir ~/School;
mkdir ~/Code;
mkdir ~/Code/Learning;
mkdir ~/Code/Projects;

Clone templates   optional

These are templates coded by me (MIT licensed) which are basically boilerplate helpers for differing languages. They allow me to quickly start coding up projects as they remove the hassle of setting the build system and source directories up manually. They're cloned into ~/Code/Templates not only so you can hack on them as you wish but also so you can generate templates even when offline just by copying the template you want and removing/replacing the '.git' directory in it.

Firstly you need the folders for the templates to be stored in, so mkdir them.

mkdir ~/Code;
mkdir ~/Code/Templates;

Then clone the templates into the folder.

declare -a templates=("CTemplate" "CPPTemplate" "PythonTemplate"
					  "NodeTemplate" "ArduinoTemplate");
for template in ${templates[@]}; do
	git clone https://github.com/odavep/$template ~/Code/Templates/$template;
done

Managing modules

What is stow?

GNU/Stow is a utility for symlinking folders (named as 'modules') to the home directory.

How does stow work (roughly)?

Each module must be structure as if that module directory were to be mapped directly on to the home directory. For example, the vim module which has only a vimrc file would be structured "~/Dotfiles/Vim/.vimrc" so that when it is stowed, the vimrc goes directly to "~/.vimrc" This also means that if any files are already present that conflict with the module files, the stow will not work. So make sure to clean up beforehand.

Activating a module

Activating a module is as simple as just entering the dotfiles directory and entering 'stow <Module name>'. This will symlink the contents of the internal directory to the home directory.

Deleting a module

Deleting a module is a call to stow with the -d argument (i.e. 'stow -D <module name>'). This will delete the symlinks to all the files in the module, leaving the home directory clean of them.

Activate all modules   optional

Basically get all folders excluding the '.git' and '.' folder, then just stow them.

folders=`find . -maxdepth 1 -type 'd' -not -name '.git' -not -name '.'`;

# Symlink profiles
for pkg in $folders; do
	echo "Stowing " $pkg;
	stow $pkg
done

Emacs support   optional

Get all modules in Dotfiles

The main function used to retrieve all the stowable modules in the Dotfiles directory.

(defun +dotfiles-install/get-modules ()
  "Get all modules in dotfiles directory"
  (interactive)
  (cdr
   (reverse
    (split-string
     (shell-command-to-string "find ~/Dotfiles/ -maxdepth 1 -type 'd' -not -name '.git' -not -name '$USER/Dotfiles/'")
     "\n"))))
(+dotfiles-install/get-modules)

Install module

Little elisp snippet to stow a specific module in the Dotfiles folder using completing-read.

(defun +dotfiles-install/install-module ()
  (interactive)
  (async-shell-command (format "stow %s" (completing-read "Stow module: " (+dotfiles-install/get-modules) nil t)) "*stow-output*" "*stow-error*"))
(+dotfiles-install/install-module)

Delete module

Little elisp snippet to delete a stowed module in the Dotfiles folder using completing-read.

(defun +dotfiles-install/delete-module ()
  (interactive)
  (async-shell-command
   (format "stow -D %s" (completing-read "Delete module: " (+dotfiles-install/get-modules) nil t))
   "*stow-output*" "*stow-error*"))
(+dotfiles-install/delete-module)