setup.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. # Backup a given file.
  15. backup() {
  16. [ -e "$1" ] && mv "$1" "$backup_dir"
  17. }
  18. # Create links after backing up.
  19. linkup() {
  20. backup "$2"
  21. ln -sf "$1" "$2"
  22. }
  23. # Run vim-plug's install process.
  24. # Vim starts with just a registry of plugins and the `nocompatible` flag.
  25. install_vim_plugins() {
  26. vim -u ~/dotfiles/vim/plugins.vim -N +PlugUpdate! +PlugClean! +qall!
  27. }
  28. # }}}
  29. # Prepare folders
  30. backup_dir=~/.dotfilesbackup/$(date)
  31. mkdir -p "$backup_dir" ~/bin ~/.config ~/.ssh
  32. echo "Prepared folders."
  33. # Make known_hosts file if none
  34. touch ~/.ssh/known_hosts
  35. echo "Touched 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. linkup ~/dotfiles/powerline/config ~/.config/powerline
  69. echo "Powerline linked."
  70. # Vim (and NeoVim)
  71. linkup ~/dotfiles/vim/vimrc ~/.vimrc
  72. linkup ~/dotfiles/vim/vimrc ~/.nvimrc
  73. linkup ~/dotfiles/vim ~/.vim
  74. linkup ~/dotfiles/vim ~/.nvim
  75. install_vim_plugins
  76. echo "Vim linked."
  77. echo "Setup complete!"