setup.sh 1.7 KB

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