setup.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. # Location: $HOME/dots
  3. # User Scope: user
  4. # Run as: ./setup.sh <arg>
  5. # Script to setup terminal environment
  6. if [ $# -ne 1 ]; then
  7. echo "::[Dots Setup Script]::"
  8. echo "Usage: setup.sh <prompt to use: seafly|parrot|powerline>"
  9. exit 1
  10. fi
  11. host=$(hostname)
  12. hostname="${host^^}"
  13. repo_directory="/opt/qconfig"
  14. user_prompt="$1"
  15. # Set Permissions
  16. chmod 660 $(find ./ -type f)
  17. chmod 660 $(find "$HOME/.bashrc" -type f)
  18. chmod 770 $(find "$HOME/dots" -type d)
  19. function add_string_to_file() {
  20. # Checks if a string is in a file
  21. # adds it if it isn't in that file
  22. local file="$1"
  23. local string="$2"
  24. if ! grep -q "$string" "$file"; then
  25. echo "$string" >> "$file"
  26. fi
  27. }
  28. # Bashrc
  29. add_string_to_file "$HOME/.bashrc" "source $HOME/dots/default_aliases"
  30. add_string_to_file "$HOME/.bashrc" "source $HOME/dots/$user_prompt-prompt"
  31. add_string_to_file "$HOME/.bashrc" "bash $HOME/dots/life.sh 1993-07-21 control"
  32. # NVIM
  33. mkdir -p "$HOME/.config/nvim/"
  34. cp "./nvim" "$HOME/.config/nvim/init.vim"
  35. # TMUX
  36. cp "./tmux.conf" "$HOME/.tmux.conf"
  37. # PATH VARS
  38. if [ -f "$HOME/.dots/user_paths" ]; then
  39. chmod 660 "$HOME/.dots/user_paths"
  40. add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_paths"
  41. fi
  42. if [ -f "$HOME/.dots/user_aliases" ]; then
  43. chmod 660 "$HOME/.dots/user_aliases"
  44. add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_aliases"
  45. fi
  46. if [ -f "$repo_directory/user_paths" ]; then
  47. chmod 660 "$repo_directory/user_paths"
  48. add_string_to_file "$HOME/.bashrc" "source $repo_directory/user_paths"
  49. fi
  50. if [ -f "$repo_directory/user_aliases" ]; then
  51. chmod 660 "$repo_directory/user_aliases"
  52. add_string_to_file "$HOME/.bashrc" "source $repo_directory/user_aliases"
  53. fi
  54. # Source
  55. source "$HOME/.bashrc"