Dotfiles - How to Configure your Shell (intro)
Tags: tutorial, dotfiles, productivity, linux
Published: 2020-09-06 10:53:48

> Sharing my shell dotfiles for developers using macOS, Linux, ZSH or Bash

My aim is make my configs easy to understand and manage - using functions to make the shell config lighter, if statements to turn on features when needed. I use aliases at the shell and git level to make it easy to reach for long or frequently-used commands.

If want to just see config files, skip ahead to [Part 2](https://dev.to/michaelcurrin/dotfiles-shell-config-5dnf).


## What you'll discover in this post series

Click links to skip to that part of the series.

- What is a dotfile?
- My [shell config](https://dev.to/michaelcurrin/dotfiles-shell-config-5dnf) setup
- My [shell aliases](https://dev.to/michaelcurrin/dotfiles-shell-aliases-2ehe)
- My [git config file](https://dev.to/michaelcurrin/dotfiles-git-config-348o) (mostly git aliases)
- My global [git ignore](https://dev.to/michaelcurrin/dotfiles-global-git-ignore-38ef) file
- How to write a [shared config](https://dev.to/michaelcurrin/dotfiles-shared-config-for-zsh-and-bash-4ff9) that gets loaded by both `.zshrc` and `.bashrc`


## Background

Let me give you an idea of what development I do on a daily basis. You'll see the configs fit into these areas.

- Linux and macOS
- [Bash](https://github.com/MichaelCurrin/learn-to-code/tree/master/en/topics/shell/Bash) and [ZSH](https://github.com/MichaelCurrin/learn-to-code/tree/master/en/topics/shell/ZSH)
- [Git](https://github.com/MichaelCurrin/learn-to-code/tree/master/en/topics/version_control/Git) for version control
- Scripting using [Python](https://github.com/MichaelCurrin/learn-to-code/tree/master/en/topics/scripting_languages/Python), [JavaScript](https://github.com/MichaelCurrin/learn-to-code/tree/master/en/topics/scripting_languages/JavaScript), NPM and NVM
- A bit of scripting using Deno, [Go](https://github.com/MichaelCurrin/learn-to-code/tree/master/en/topics/scripting_languages/Go) and [Ruby](https://github.com/MichaelCurrin/learn-to-code/tree/master/en/topics/scripting_languages/Ruby)


## What is a dotfile?

A **dotfile** is a file or directory which has a name that starts with a "full-stop" or "dot".

On "Unix-like systems", such as Linux and macOS, a dotfile is **hidden** by default when viewing files in a folder browser and the shell. This makes it harder to see and edit but keeps them out of the way unless you are actually looking for them.

For example running `ls` shows `Documents`, `Downloads` etc. but `ls -a` will show all hidden files like `.aliases` and `.bashrc` and directories like `.config/` and `.ssh/`.

Config files are typically stored are dotfiles in the user home directory. Such as `~/.bashrc`. 

You can open it for editing from the command-line using something like this:

```sh
$ edit ~/.bashrc
$ nano ~/.bashrc
$ vim ~/.bashrc
$ code ~/.bashrc # VS Code
$ subl ~/.bashrc # Sublime
```


## My global dotfiles

The next few posts in this series cover content for files in user directory. 

I provide links to files in my [MichaelCurrin/dotfiles](https://github.com/MichaelCurrin/dotfiles) repo, which I created specifically for sharing in this blog post. 

I also highlight and explain some of the content directly in the posts.


## Dotfiles by other people

For further reading, see this [dotfiles](https://dev.to/helderburato/write-your-own-dotfiles-2l65) post by `@helderburato`. It includes dotfiles by a few people.

I have heard of `yadm` as a dotfile manager from comments on my post. I haven't used it before but its site has a couple of dotfile repos linked there.

- https://yadm.io/docs/examples

Side note - the way I manage my dotfiles is actually through a private repo cloned locally. I have symlink in my home directory pointing to `.bashrc` and others in the repo, so get the benefit of my repo code being used live and I get to regularly push and pull changes on GH to keep work and personal laptops in sync. I find it works well.

## Next

Onto the configs! Go to [Part 2](https://dev.to/michaelcurrin/dotfiles-shell-config-5dnf) for my shell configs.