[Guide] How I git my dotfiles - GNU/Linux

Users browsing this thread: 1 Guest(s)
z3bra
Grey Hair Nixers
That's a great tutorial!

If I can help, here is a script from my ~/etc/ It will list all the files in its directory, dump them in a file on /tmp/, ask you to edit the file, and create a symlink for each file.

~/etc/copy.sh :
Code:
#!/bin/sh

TMPFILE=/tmp/dotfiles.list

OK="[$(tput setaf 3)OK$(tput sgr0)]"
NOPE="[$(tput setaf 1)FAIL$(tput sgr0)]"

cat <<EOF > $TMPFILE
##
## Here is an auto-generated file for linking
## config file to your $home directory
##
## The $0 script will read filenames from that
## file in order to create ONLY the links you
## want.
##
## The following list lists every. single. file
## or directory. Just remove the line that you
## don't want to be linked.
## Then, save that file, and watch the magic happen...
##
EOF

echo "listing the whole directory"
ls $PWD >> $TMPFILE

$EDITOR $TMPFILE

echo "simulating..."
for f in $(grep -v '^#' $TMPFILE); do
  echo "$f -> ~/.$f"
done

echo "attempting to link config file to ~ ..."
read -p "Hit <Enter> to continue, <Ctrl-C> to abort..."
for f in $(grep -v '^#' $TMPFILE); do
  ln -s $PWD/$f ~/.$f
  if [ -L ~/.$f ] ; then
    echo "$OK   -> $f"
  else
    echo "$NOPE -> $f"
  fi
done

echo "removing temporary files"
rm $TMPFILE

echo "finished."

File list comment/delete de files you dont want to see)
Code:
##
## Here is an auto-generated file for linking
## config file to your  directory
##
## The ./copy.sh script will read filenames from that
## file in order to create ONLY the links you
## want.
##
## The following list lists every. single. file
## or directory. Just remove the line that you
## don't want to be linked.
## Then, save that file, and watch the magic happen...
##
bashrc
#copy.sh
cwmrc
elinks
#evilwmrc
#irssi
mutt
#ncmpcpp
#openbox
#ratpoisonrc
#rtorrent.rc
#screenrc
#tint2
tmux.conf
vim
vimrc
xbindkeysrc
xinitrc
Xresources
#zshrc
This will create a symlink for every uncommented line, by appending a '~/.' before the filename (bashrc -> ~/.bashrc).

Once you're done editing the list, it will simulate the linking, so that you can check that it does it the way you want. Presse <Enter> to proceed, <Ctrl-C> to abort. Finally, watch the linking going!

It has saved me a lot of pain seting up new machines :)
BANGARANG, MOTHERFUCKER


Messages In This Thread
[Guide] How I git my dotfiles - by crshd - 06-09-2013, 02:08 AM
RE: [Guide] How I git my dotfiles - by shtols - 06-09-2013, 05:58 PM
RE: [Guide] How I git my dotfiles - by z3bra - 06-11-2013, 04:34 AM