setup.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 -sf "$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. git config --global diff.mnemonicPrefix true
  41. echo "Git config done."
  42. # Initialise and clone any submodules
  43. git submodule sync
  44. git submodule update --init
  45. echo "Submodules done."
  46. # Zsh
  47. linkup ~/dotfiles/zsh/zshrc ~/.zshrc
  48. linkup ~/dotfiles/zsh/zshenv ~/.zshenv
  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. linkup ~/dotfiles/bin/ack ~/bin/ack
  66. echo "Ack linked."
  67. # Powerline
  68. mkdir -p ~/.config
  69. linkup ~/dotfiles/powerline/config ~/.config/powerline
  70. echo "Powerline linked."
  71. # Vim (and NeoVim)
  72. linkup ~/dotfiles/vim/vimrc ~/.vimrc
  73. linkup ~/dotfiles/vim/vimrc ~/.nvimrc
  74. linkup ~/dotfiles/vim ~/.vim
  75. linkup ~/dotfiles/vim ~/.nvim
  76. install_vim_plugins
  77. echo "Vim linked."
  78. echo "Setup complete!"