setup.sh 2.0 KB

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