As dev, it's not uncommon to use different machines or to renew laptops and devices. You don't want to spend too much time in repetitive operations, such as setting git, defining custom aliases, etc.
To speed up install, you can store these configurations in a git repository (often called dotfiles
by convention).
In such repository, you will likely add .bashrc
, .zshrc
, .gitconfig
, .gitignore_global
, etc. It's way more convenient for new install and maintenance.
In addition, you may include a small script to copy each file at the root of the $HOME
folder, so you won't have to do it manually:
#!/usr/bin/env zsh
# Credit: Julien maury
target="$PWD/files"
echo "Copying files..."
cd $target
for entry in $(ls .??*)
do
cp $entry $HOME
echo "$entry copied!"
done
echo "Done!"
cd -
The script goes at the root of the repository and all dotfiles in a subfolder called files
:
āāā files
ā āāā .bashrc
ā āāā .zshrc
ā āāā .gitconfig_global
ā āāā .gitconfig
āāā install.zsh
To use the repo, you may run git clone DOTFILES_REPO_URL && cd DOTFILES_REPO && zsh install.zsh
.
This approach works best if you keep the same operating system, so you might encounter some issues when switching between Windows, Linux, and Mac, but those incompatibilities tend to be less and less frequent.