main2.sh 573 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. declare -A bashrc_files
  3. bashrc_files=( ["home"]=".bashrc-home" ["work"]=".bashrc-work" )
  4. switch_bashrc() {
  5. local choice=$1
  6. if [[ -n "${bashrc_files[$choice]}" ]]; then
  7. cp "${HOME}/${bashrc_files[$choice]}" "${HOME}/.bashrc"
  8. echo "Переключено на ${bashrc_files[$choice]}."
  9. else
  10. echo "Неверный выбор. Пожалуйста, выберите 'home' или 'work'."
  11. fi
  12. }
  13. if [[ $# -ne 1 ]]; then
  14. echo "Использование: $0 {home|work}"
  15. exit 1
  16. fi
  17. switch_bashrc "$1"