setup.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. main_user=$(id -un 1000)
  15. user_prompt="$1"
  16. # Set Permissions
  17. chmod 660 $(find ./ -type f)
  18. chmod 660 $(find "$HOME/.bashrc" -type f)
  19. chmod 770 $(find "$HOME/dots" -type d)
  20. function add_string_to_file() {
  21. # Checks if a string is in a file
  22. # adds it if it isn't in that file
  23. local file="$1"
  24. local string="$2"
  25. if ! grep -q "$string" "$file"; then
  26. echo "$string" >> "$file"
  27. fi
  28. }
  29. # Bashrc
  30. add_string_to_file "$HOME/.bashrc" "source $HOME/dots/default_aliases"
  31. add_string_to_file "$HOME/.bashrc" "source $HOME/dots/$user_prompt-prompt"
  32. add_string_to_file "$HOME/.bashrc" "bash $HOME/dots/life.sh 1993-07-21 control"
  33. # NVIM
  34. mkdir -p "$HOME/.config/nvim/"
  35. cp "./nvim" "$HOME/.config/nvim/init.vim"
  36. # TMUX
  37. cp "./tmux.conf" "$HOME/.tmux.conf"
  38. # PATH VARS
  39. if [ -f "$HOME/.dots/user_paths" ]; then
  40. chmod 660 "$HOME/.dots/user_paths"
  41. add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_paths"
  42. fi
  43. if [ -f "$HOME/.dots/user_aliases" ]; then
  44. chmod 660 "$HOME/.dots/user_aliases"
  45. add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_aliases"
  46. fi
  47. if [ -f "$repo_directory/user_paths" ]; then
  48. chmod 660 "$repo_directory/user_paths"
  49. add_string_to_file "$HOME/.bashrc" "source $repo_directory/user_paths"
  50. fi
  51. if [ -f "$repo_directory/user_aliases" ]; then
  52. chmod 660 "$repo_directory/user_aliases"
  53. add_string_to_file "$HOME/.bashrc" "source $repo_directory/user_aliases"
  54. fi
  55. # Set System Aliases
  56. sudo add_string_to_file "/etc/bash.bashrc" "source /home/$main_user/dots/system_aliases"
  57. # Source
  58. source "$HOME/.bashrc"