Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using bash to automate dotfiles

I want to create my own automated dotfiles folder. (I'll be using git to use version control on my dotfiles, but that's irrelevant for the question)

What i simply want is to symbolically link all the files and folders in ~/dotfiles to my home folder. Being not good at all with bash I can't do this. Please help me with this.

I would also appreciate the following features if possible.

  • Folders are only shallowly linked
  • My files could be in the dotfiles folder without the actual dot in the file-name (like ~/dotfiles/vimrc rather than ~/dotfiles/.vimrc)
  • It should be able to ignore some files, like my .git file which are stored in the same folder

Of course if you already know a service providing this, that is at least as good as providing some do-myself commands. Note how I specifically want it to be bash or something that most likely exists on all unix machines (so i guess commands using g++ are fine).

like image 469
Tarrasch Avatar asked Mar 08 '11 20:03

Tarrasch


1 Answers

Give this a try:

ln -s ~/dotfiles/* ~

There shouldn't be any need for a loop. Of course, you can use find if you need something recursive.

Edit:

To make the destination files hidden:

for f in ~/dotfiles/*
do
    ln -s "$f" "$HOME/.${f##*/}"
done
like image 58
Dennis Williamson Avatar answered Sep 27 '22 22:09

Dennis Williamson