setup.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. # vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{{,}}} foldlevel=0 foldmethod=marker spell:
  3. set -euo pipefail
  4. IFS=$'\n\t'
  5. # Support Functions {{{
  6. # Backup a given file.
  7. backup() {
  8. [[ -e "$1" ]] && mv "$1" "$backup_dir" || true
  9. }
  10. # Create links after backing up.
  11. linkup() {
  12. backup "$2"; ln -sf "$1" "$2"
  13. }
  14. # }}}
  15. # Prepare folders
  16. backup_dir=~/.dotfilesbackup/$(date)
  17. mkdir -p "$backup_dir" ~/.ssh
  18. echo "Prepared folders."
  19. # Make known_hosts file if none
  20. touch ~/.ssh/known_hosts
  21. echo "Touched known hosts."
  22. # Git config
  23. git config --global color.ui true
  24. git config --global core.editor vim
  25. git config --global core.excludesfile ~/dotfiles/git/globalignore
  26. git config --global diff.mnemonicPrefix true
  27. echo "Git config done."
  28. # Initialise and clone any submodules
  29. (cd ~/dotfiles && git submodule sync && git submodule update --init)
  30. echo "Submodules done."
  31. # Zsh
  32. linkup ~/dotfiles/zsh/zshenv ~/.zshenv
  33. linkup ~/dotfiles/zsh/zshrc ~/.zshrc
  34. echo "Zsh linked."
  35. # Vimperator
  36. linkup ~/dotfiles/vimperator ~/.vimperator
  37. linkup ~/dotfiles/vimperator/vimperatorrc ~/.vimperatorrc
  38. echo "Vimperator linked."
  39. # Screen
  40. linkup ~/dotfiles/screen/screenrc ~/.screenrc
  41. echo "Screen linked."
  42. # Tmux
  43. linkup ~/dotfiles/tmux/tmux.conf ~/.tmux.conf
  44. echo "Tmux linked."
  45. # Irssi
  46. linkup ~/dotfiles/irssi ~/.irssi
  47. echo "Irssi linked."
  48. # Ack
  49. linkup ~/dotfiles/ack/ackrc ~/.ackrc
  50. echo "Ack linked."
  51. # Vim (and NeoVim)
  52. linkup ~/dotfiles/vim/vimrc ~/.vimrc
  53. linkup ~/dotfiles/vim/vimrc ~/.nvimrc
  54. linkup ~/dotfiles/vim ~/.vim
  55. linkup ~/dotfiles/vim ~/.nvim
  56. echo "Vim linked."
  57. # vim-plug install process. Starts with plugin list and `nocompatible` flag.
  58. vim -u ~/dotfiles/vim/plugins.vim -N +PlugClean! +PlugUpdate! +quitall!
  59. echo "Vim plugins done."
  60. echo "Setup complete!"