setup.sh 1.8 KB

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