setup.sh 1.6 KB

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