Dotfiles
This post is a summary of a talk I was asked to give in front of my fellow PhD students.
It basically was a tutorial on shell scripting and dotfile integration.
I gave a live demo in which I demonstrated how I install my dotfile repository on a new machine.
Dotfiles set defaults for many different programs, and make personalization of these programs easy to back up.
Inspirations
- linux background
- I like to browse for r/unixporn/ ;)
- a tinkerer by nature
- bending and breaking software is fun (awk-raycaster)
- food for your OCD monster
- everybody likes pretty things
Shells
Before talking about dotfiles, system configurations and customizations,
we need to have a quick look at the basics, i.e. how we interact with the OS.
Here some important keywords:
- terminal, tty, console, and shell often used as synonyms
- terminal is the text input and output environment, for UNIX equivalent with a tty or a collection of ttys
- tty (short for teletypewriter) is a particular kind of device file which implements a number of additional commands (ioctls) beyond read and write (often directly connected to hardware devices via the kernel)
- console, sometimes a primary terminal directly connecting to the machine, appears to the OS as a kernel-implemented tty
- Command-line interpreters (cli), or sometimes also synonymously labelled shells are consoles where users can issue commands
- in the early days, the only means of interaction with the machine
- interpreted language, most also support scripting
- many different kinds of shells:
- sh (Thompson or Bourne)
- csh (C-like)
- ksh (David Korn)
- bash (Bourne-again)
- zsh (Zhong Shao’s username)
- fish (friendly-interactive)
- rsh/rbash (restricted)
- tclsh (tcl/tk commands)
- wish (tcl/tk gui version)
- different shell types:
- interactive shell (accepts commands interactively)
- non-interactive shell (usually spawned by shell scripts)
- login shell (login via SSH or terminal, usually interactive)
- non-login interactive shells read
.bashrc
files, but not your .login
and .profile
Dotfiles
- What?
- Files that start with a dot
.
, the most prominent example being .bashrc
- collection of files containing settings for various programs
- usually hidden in normal
ls
-ings, try typing ls -ad ~/.*
in terminal
- Why?
- why not?
- no, seriously… it will improve your workflow drastically (if set up to your specifications)
- Where?
- personal customizations in
~/.
, i.e. $HOME/.
- various basic configurations in
/etc/.
, e.g. /etc/bashrc
(careful if you plan to change those!)
- How?
- simply put them in your home directory
- almost all programs use dotfiles: git
.gitconfig
, ls .dircolors
, curl .curlrc
, emacs .emacs.d/init.el
, vim .vimrc
, python .pythonrc.py
, matplotlib .matplotlib/matplotlibrc
, etc.
My dotfiles
There are many resources offering dotfile configurations, setup and maintainance frameworks:
You can find my ever-growing dotfile collection here: github.com/phdenzel/dotfiles.
.USERINFO
.bashrc
.bash_profile
.aliases
.prompt
.path
.exports
.functions
.dircolors_macos
.dircolors_linux
.gitconfig
.gitignore
.pulls
.macOS
.inputrc
.screenrc
.wgetrc
.curlrc
.gdbinit
.hgignore
.editorconfig
.hushlogin
bootstrap.sh
|-- bin
|-- etc
|-- utils
|-- .emacs.d
|-- server
|-- .config/neofetch
|-- installers
|-- custom
And this is how it looks…
Setting up a new machine
I work with lots of machines (currently about 6-7), some of them virtual.
The more machines you have to set up, the more you wish you had writen something to automate this process…
- Install OS (and set up an internet connection)
- Install git (usually already installed, but old
git clone https://github.com/git/git
)
- Clone dotfile repository from GitHub
git clone https://github.com/phdenzel/dotfiles
- Run install scripts depending on OS, e.g.
brew.sh
or apt.sh
- Bootstrap dotfiles
source bootstrap.sh
- Install additional tools (via install scripts), e.g.
emacs_installer.sh
or python
- If the machine is permanent, install
Dropbox
and symlink all directories to $HOME