This is my dotfile. Usable both as a standalone Git repository or work in a Docker environment as a development container.
This repo has 3 purposes:
-
This is my personal dotfile. I do try to make it as distro/OS-agnostic as possible though.
-
To force myself to learn shell programming, tmux configuration, etc.
-
To be able to run development container(s).
-
Do not overwrite existing configuration. This is a common scenario in Linux/MacOS environments:
-
Various configurations are already there when personal configuration begins. Some systems would create .bashrc in your home directory automatically.
-
Programs love to spew lines to .bashrc or .profile, so they cannot be assumed to be static.
-
-
Leave shell config for programs to abuse. These are copied to home directory rather than linked.
-
Use links for customizations that are not related to application abuse.
-
Make sure it (this config) is easy to delete. After deleting this config, you should have a default or non-existent config.
Keep in mind that removing this config won't help you uninstall packages such as vim, emacs, etc. This is the job of your package manager.
-
Make it modular. Scripts/configs for each program should be separated by folder to make maintenance easy.
-
Make it so that using setup script(s) repeatedly will skip the parts that's already been set up.
-
Make it as simple and cross-platform as possible. What does cross-platform even mean? Hard to tell these days. But I choose POSIX shell for now.
There're very few assumptions here, not in any particular order:
-
You are running a UNIX-ish system.
-
You would prefer to have more than 1 ssh setup if needed. Separation of work and life account is typically needed, amongst other reasons.
-
At least you have Busybox or similar minimal environment.
-
You have bash as your interactive shell. If you don't have bash in your system, then .profile is loaded only. If you do use bash, then:
- .bash_profile is loaded, and it will load .profile.
- .profile does what it's supposed to do, and load in .bashrc.
This is to ensure that .profile will be loaded no matter what.
Bash, Vim, Neovim, tmux, SSH, git. A "complete" CLI working environment.
This script can also helps you set up your user name and password where applicable. Good for initializing things on WSL or other root systems.
Bash for interactive shell, Vim/Neovim for text editor, tmux for screen multiplexer, ssh and git could work together or separately.
SSH setup script here is a wrapper to allow users to set up git and SSH so we can SSH into git repos easier, and nothing else.
-
dircolors. I realize they exist, I just don't care about them enough to write one.
-
Zsh or fish. I try to minimize working directly within shell CLI because nowadays I live in Vim/Neovim/Emacs whenever possible. So I don't even heavily rely on Bash at all.
-
Emacs. It deserves its own config repo.
-
IDEs/Full programming environment setup?
Try IntelliJ suite if that tickles your fancy. Or even Visual Studio.
There's 2 ways to set up this config.
-
Using this dotfile on an existing install. In other words, not a container setup.
To pull this repo to your OS:
cd $HOME git clone https://github.com/samyilin/dotfiles.git
To set up everything:
cd $HOME/dotfiles ./setup && . "$HOME"/.profile
To setup additional programs after initial setup, i.e. your initial setup did not install vim but now it does, do
cd $HOME/dotfiles ./setup YOUR_PROGRAM
Design principles above will make sure no repeated install would happen.
To get the latest from this setup, do
cd $HOME/dotfiles git pull
If you want to remove this config:
cd $HOME/dotfiles ./remove && . "$HOME"/.bash_profile
If you want to remove config for a certain program, i.e. vim, then
cd $HOME/dotfiles ./remove YOUR_PROGRAM
To remove this repo from your setup altogether, do
rm -rf $HOME/dotfiles
Additional mode: Docker/default mode. Skips over interactive mode that the user need to intervene, i.e. setting up username/password, git and ssh. This is the default on Docker setup. More about this below.
To install using non-interactive mode:
cd $HOME/dotfiles ./setup -d
-
Using this dotfile to setup a docker/podman image. This is good for developing in a container and avoid "dependency hell."
To use this method, you would need to install docker or podman on your setup. I would suggest podman.
I have 3 Dockerfile here, one Ubuntu based (more stable-ish, although I use the latest Ubuntu release), one Fedora rawhide based (cutting-edge, good for testing latest software) and one Archlinux based (bleeding-edge, good for testing development software)
Using the appropriate Dockerfile name, the below code would generate a docker image:
cd $HOME git clone https://github.com/samyilin/dotfiles cd dotfiles docker build -f Dockerfile.DISTRO -t IMAGE_NAME
Podman requires using buildah to build image, so:
cd $HOME git clone https://github.com/samyilin/dotfiles cd dotfiles buildah build -f Dockerfile.DISTRO -t IMAGE_NAME
To enter this image, use
docker run -it --rm localhost/IMAGE_NAME
On podman, use
podman run -it --rm localhost/IMAGE_NAME
Default container/docker install would not help you set up ssh and git. These belong in your host system so you don't have to reset your ssh every time you spin up a container. To mount host's ssh and git configurations, use something like
docker run -it --rm -v $HOME/.ssh:$HOME/.ssh \ -v $HOME/.gitconfig $HOME/.gitconfig \ localhost/IMAGE_NAME
You can use a similar process to mount your git repo to the container so you don't have to keep copying your repo over. Writing a basic Bash script for this is trivial and won't be covered here.
I've tested this setup in Alpine, Arch, Ubuntu and Fedora Linux containers. Also MacOS. I would try this in VMs one day.
Will try to test this on BSD VMs one day.
If you really want the greybeards' power tools, read up The Grymoire. This is a series of practical guide for Unix/Linux tools that is actually pleasant to read, unlike the POSIX standard specification (which you have to read if you found Grymoire not clear enough).