setup.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. # Download vim-plug, a vim plugin manager.
  27. #
  28. # Also place vim-plug where it can be auto-loaded.
  29. download_vim_plug() {
  30. folder=~/.vim/plugged/vim-plug
  31. if [ ! -e $folder ]; then
  32. echo "Vim Plugin Manager cloning"
  33. git clone https://github.com/junegunn/vim-plug.git $folder --depth 1
  34. else
  35. echo "Vim Plugin Manager updating"
  36. cd $folder && git pull
  37. fi
  38. mkdir -p ~/.vim/autoload
  39. linkup "$folder/plug.vim" ~/.vim/autoload/plug.vim
  40. }
  41. # Run vim-plug's install process.
  42. #
  43. # Vim is loaded with only the registry of plugins and the `nocompatible` flag.
  44. install_vim_plugins() {
  45. vim -u ~/dotfiles/vim/plugins.vim -N +PlugInstall +PlugClean +qall
  46. }
  47. # }}}
  48. # Make known_hosts file if none
  49. mkdir -p ~/.ssh
  50. touch ~/.ssh/known_hosts
  51. echo "We touched all the known hosts."
  52. # Git config
  53. git config --global color.ui true
  54. git config --global core.editor "vim"
  55. echo "Git config done."
  56. # Initialise and clone any submodules
  57. git submodule sync
  58. git submodule update --init
  59. echo "Submodules done."
  60. # Zsh
  61. linkup ~/dotfiles/zsh/zshrc ~/.zshrc
  62. linkup ~/dotfiles/zsh/zshenv ~/.zshenv
  63. echo "Zsh linked."
  64. # Vimperator
  65. linkup ~/dotfiles/vimperator ~/.vimperator
  66. linkup ~/dotfiles/vimperator/vimperatorrc ~/.vimperatorrc
  67. echo "Vimperator linked."
  68. # Screen
  69. linkup ~/dotfiles/screen/screenrc ~/.screenrc
  70. echo "Screen linked."
  71. # Tmux
  72. linkup ~/dotfiles/tmux/tmux.conf ~/.tmux.conf
  73. echo "Tmux linked."
  74. # Irssi
  75. linkup ~/dotfiles/irssi ~/.irssi
  76. echo "Irssi linked."
  77. # Ack
  78. linkup ~/dotfiles/ack/ackrc ~/.ackrc
  79. echo "Ack linked."
  80. # Powerline
  81. mkdir -p ~/.config
  82. linkup ~/dotfiles/powerline/config ~/.config/powerline
  83. echo "Powerline linked."
  84. # Vim (and NeoVim)
  85. linkup ~/dotfiles/vim/vimrc ~/.vimrc
  86. linkup ~/dotfiles/vim/vimrc ~/.nvimrc
  87. mkdir -p ~/.vim-tmp
  88. linkup ~/.vim-tmp ~/.vim
  89. linkup ~/.vim-tmp ~/.nvim
  90. download_vim_plug
  91. install_vim_plugins
  92. echo "Vim linked."
  93. echo "Setup complete!"