The very personal dotfiles of Levi Olson.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.6 KiB

6 years ago
6 years ago
  1. #!/bin/bash
  2. ######################################
  3. # init.sh
  4. # ---------
  5. # Symlink ~/dotfiles to $HOME
  6. ######################################
  7. dir=~/dotfiles # dotfiles directory
  8. backup=~/dotfiles_backup # old dotfiles backup directory
  9. symfiles=".aliases .bash_profile .bash_prompt .bashrc .dockerfunc .exports .functions .path .xinitrc .Xresources .Xdefaults .xmodmap"
  10. symdefaults=".extra" # not in version control
  11. ######################################
  12. # create dotfiles_old in homedir
  13. echo "Creating $backup to backup of any existing dotfiles already in ~/"
  14. mkdir -p $backup
  15. echo "...done"
  16. # change to the dotfiles directory
  17. echo "Changing to the $dir directory"
  18. cd $dir
  19. echo "...done"
  20. # move any existing dotfiles in homedir to dotfiles_old directory, then create symlinks
  21. for file in $symfiles; do
  22. echo "Moving any existing dotfiles from ~/ to $backup"
  23. mv ~/$file $backup/
  24. echo "Creating symlink to $file in home directory."
  25. ln -s $dir/$file ~/$file
  26. done
  27. echo "...done"
  28. # create any template/default files not in version control
  29. for file in $symdefaults; do
  30. echo "Creating empty file $file in home directory."
  31. touch $dir/$file
  32. echo "#!/bin/bash\n\n##############################\n# $file\n# ---------------\n##############################\n\n" > $dir/$file
  33. done
  34. echo "...done"
  35. # https://doc-08-0g-docs.googleusercontent.com/docs/securesc/3m7t6hq95j05qojlngekkd8c5obrjfk4/5c0eggqhge779o6kn2oe4dqsgprd16jm/1519423200000/08124755567902560828/08124755567902560828/1oZzZ8UdoqmR6KsZLdmyxjYUUTpLVxMip?e=download&nonce=vqoqalqs6bnai&user=08124