This is mostly a blog post for me to look back and understand how I’ve setup and configured my dotfiles and other applications that I use.
This is how my shell currently looks like. If you spend considerable amount of time in the shell, it usually is worth to make it look nice.
OS=Linux SHELL=zsh TERM=xterm-256color
ZSH and Prezto Reference
Before we get into the setup, let’s try to understand the various shell related dotfiles that are in use.
Breakdown of zsh dotfiles
There are five basic starup files which get sourced whenever a new shell is instantiated (excluding prezto config). These are all located in $HOME
, i.e ~/
.
.zshenv
- This file gets sourced in all shells. Environment variables which are updated frequently should be set here. ($PATH
,$EDITOR
,$PAGER
).zprofile
- Similar to.zlogin
and run in loginshells
. NOT meant to be used together with.zlogin
.zshrc
- This file gets sourced in all interactive shells ([[ -o interactive ]]
is true). It should contain commands for interactive usage. Aliases, functions, options, key bindings, command completion, prompt, coloring are defined and configured here.Prezto dotfiles
.zpreztorc
- Gets sourced after.zshrc
. This file configures Prezto..zshrc
sources.zprezto/init.zsh
..zprezto/init.zsh
sources.zpreztorc
.
.zlogin
- This file gets sourced in all login shells ([[ -o login ]]
is true). It should not modify the shell environment at all. Rather, it should be used to run external commands (fortune, msgs, etc)..zlogout
- Gets sourced when login shells exit. Used to clear and reset the terminal.
Prezto’s execution order
According to zsh documentation,
You may wonder why there are both
.zprofile
and.zlogin
, when they are both for login shells: the answer is the obvious one, that one is run before, one after.zshrc
. This is historical; Bourne-type shells run/etc/profile
, and csh-type shells run~/.login
, and zsh tries to cover the bases with its own startup files.
~/.zshenv
~/.zprofile
- Prezto source this file for non-login and level 1 shells. ([[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) ]]
)~/.zshrc
~/.zpreztorc
~/.zlogin
- Only for login shells~/.zlogout
- Only for login shells
How I manage my dotfiles?
Simple, using git. I have git repository, ~/.dotfiles
.
All necessary files should be symlinked to $HOME
.
In the near future, the files will be renamed to GNU Stow will be used to auto symlink necessary files.filename.symlink
, and a new init.sh
script will be created which will recursively symlink the files
When ~/.zshrc
file is sourced, the script in it sources all my *.zsh
configuration in the ~/.dofiles/
recursively.
My filesystem
I tweaked XDG base directory specification to suit my needs.
$HOME/.config
is now$HOME/.dotfiles
$HOME/.local/bin
is now$HOME/.dotfiles/local/bin
$HOME/.local/share
is now$HOME/.dotfiles/local/share
Why? Because symlinking is a tedious process and it’s way more easier to add $HOME/.dotfiles/local/bin
to $PATH
Prompt
I use Spaceship prompt. I’ve configured the shell prompt symbol to be random. This sparks joy in me. Have a look at zsh/prompt.zsh
for prompt configuration
Vim
I prefer to use vim wherever I can. Currently I use vim in
- chrome using vimium extension,
- ideavim in Idea products (Clion mostly)
- vscodevim in vscode
~/.vimrc is symlinked, and vim plugins are installed through vim-plug in ~/.vim/plugged
Vscode
I can’t remember shorcuts for different applications over the long term. So I prefer to learn one type of shortcuts and use it everywhere. So I learnt IntelliJ’s shortcuts and use the same shortcuts via extension in vscode.
Grub Screen
I customized my grub bootloader to have this background image. Yes, I’m a Messi fan.