setup.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/sh
  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. git submodule sync
  45. git submodule update --init
  46. echo "Submodules done."
  47. # Zsh
  48. linkup ~/dotfiles/zsh/zshenv ~/.zshenv
  49. linkup ~/dotfiles/zsh/zshrc ~/.zshrc
  50. echo "Zsh linked."
  51. # Vimperator
  52. linkup ~/dotfiles/vimperator ~/.vimperator
  53. linkup ~/dotfiles/vimperator/vimperatorrc ~/.vimperatorrc
  54. echo "Vimperator linked."
  55. # Screen
  56. linkup ~/dotfiles/screen/screenrc ~/.screenrc
  57. echo "Screen linked."
  58. # Tmux
  59. linkup ~/dotfiles/tmux/tmux.conf ~/.tmux.conf
  60. echo "Tmux linked."
  61. # Irssi
  62. linkup ~/dotfiles/irssi ~/.irssi
  63. echo "Irssi linked."
  64. # Ack
  65. linkup ~/dotfiles/ack/ackrc ~/.ackrc
  66. echo "Ack linked."
  67. # Vim (and NeoVim)
  68. linkup ~/dotfiles/vim/vimrc ~/.vimrc
  69. linkup ~/dotfiles/vim/vimrc ~/.nvimrc
  70. linkup ~/dotfiles/vim ~/.vim
  71. linkup ~/dotfiles/vim ~/.nvim
  72. install_vim_plugins
  73. echo "Vim linked."
  74. echo "Setup complete!"