setup.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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"; ln -sf "$1" "$2"
  21. }
  22. # Run vim-plug's install process.
  23. # Vim starts with just a registry of plugins and the `nocompatible` flag.
  24. install_vim_plugins() {
  25. vim -u ~/dotfiles/vim/plugins.vim -N +PlugClean! +PlugUpdate! +qall!
  26. }
  27. # }}}
  28. # Prepare folders
  29. backup_dir=~/.dotfilesbackup/$(date)
  30. mkdir -p "$backup_dir" ~/.ssh
  31. echo "Prepared folders."
  32. # Make known_hosts file if none
  33. touch ~/.ssh/known_hosts
  34. echo "Touched known hosts."
  35. # Git config
  36. git config --global color.ui true
  37. git config --global core.editor vim
  38. git config --global core.excludesfile ~/dotfiles/git/globalignore
  39. git config --global diff.mnemonicPrefix true
  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/zshenv ~/.zshenv
  47. linkup ~/dotfiles/zsh/zshrc ~/.zshrc
  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. # Vim (and NeoVim)
  66. linkup ~/dotfiles/vim/vimrc ~/.vimrc
  67. linkup ~/dotfiles/vim/vimrc ~/.nvimrc
  68. linkup ~/dotfiles/vim ~/.vim
  69. linkup ~/dotfiles/vim ~/.nvim
  70. install_vim_plugins
  71. echo "Vim linked."
  72. echo "Setup complete!"