setup.sh 2.0 KB

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