#!/bin/bash # Renk tanımları RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' CYAN='\033[0;36m' BOLD='\033[1m' NC='\033[0m' # No Color # Varsayılan ayar dosyaları dizini config_directory=$(pwd) # Ayar dosyaları betik ile aynı dizinde değilse kullanıcıdan ayar dizinini iste if [ ! -d "$config_directory/emacs.d" ] || [ ! -d "$config_directory/nano" ] || [ ! -f "$config_directory/nanorc" ] || [ ! -f "$config_directory/bash_aliases" ]; then echo -e "${YELLOW}Ayar dosyalarının bulunduğu dizin (örn. ~/Documents/mydotfiles/): ${CYAN}${BOLD}$config_directory${NC}" read -p "" config_directory fi # Ayar dosyaları ve hedef konumları tanımla declare -A config_files=( ["$config_directory/emacs.d"]="$HOME/.emacs.d" ["$config_directory/nano"]="$HOME/.nano" ["$config_directory/nanorc"]="$HOME/.nanorc" ["$config_directory/bash_aliases"]="$HOME/.bash_aliases" ) # Genel ayar yükleme fonksiyonu setup_configuration() { local source_path=$1 local target_path=$2 local source_config_name=$(basename "$source_path") if [ -e "$target_path" ]; then echo -e "${YELLOW}${BOLD}$target_path${NC} zaten var." echo -e "Mevcut ayarları koruyarak ekle ${CYAN}(e)${NC}, üzerine yaz ${RED}(y)${NC}, olduğu gibi bırak ${GREEN}(b)${NC}:" read -p "" user_choice case $user_choice in [Ee]* ) if [ -d "$source_path" ]; then cp -r "$source_path"/* "$target_path" echo -e "${BOLD}$source_config_name${NC} içeriği ${GREEN}${BOLD}${target_path}${NC} içine eklendi." else cat "$source_path" >> "$target_path" echo -e "${BOLD}$source_config_name${NC} içeriği ${GREEN}${BOLD}${target_path}${NC} dosyasına eklendi." fi # .bash_aliases'i .bashrc'ye ekle if [[ "$target_path" == "$HOME/.bash_aliases" ]]; then bashrc_path="$HOME/.bashrc" if ! grep -q "source $target_path" "$bashrc_path"; then echo "source $target_path" >> "$bashrc_path" echo -e "${BOLD}$(basename "$target_path")${NC} dosyası ${GREEN}${BOLD}$(basename "$bashrc_path")${NC} dosyasına eklendi." else echo -e "${YELLOW}${BOLD}$(basename "$target_path")${NC} zaten ${BOLD}$(basename "$bashrc_path")${NC} dosyasında kaynak olarak gösteriliyor." fi fi ;; [Yy]* ) backup_path="${target_path}_backup_$(date +%Y%m%d_%H%M%S)" mv "$target_path" "$backup_path" echo -e "${YELLOW}${BOLD}$target_path${NC} yedeklendi: ${BOLD}$backup_path${NC}" cp -r "$source_path" "$target_path" echo -e "${BOLD}$source_config_name${NC} içeriği ${GREEN}${BOLD}${target_path}${NC} dosyasına yazıldı." # .bash_aliases'i .bashrc'ye ekle if [[ "$target_path" == "$HOME/.bash_aliases" ]]; then bashrc_path="$HOME/.bashrc" if ! grep -q "source $target_path" "$bashrc_path"; then echo "source $target_path" >> "$bashrc_path" echo -e "${BOLD}$(basename "$target_path")${NC} dosyası ${GREEN}${BOLD}$(basename "$bashrc_path")${NC} dosyasına eklendi." else echo -e "${YELLOW}${BOLD}$(basename "$target_path")${NC} zaten ${BOLD}$(basename "$bashrc_path")${NC} dosyasında kaynak olarak gösteriliyor." fi fi ;; [Bb]* ) echo -e "${YELLOW}${BOLD}$target_path${NC} olduğu gibi bırakıldı." ;; * ) echo -e "${RED}Geçersiz seçim. İşlem atlandı.${NC}" ;; esac else cp -r "$source_path" "$target_path" echo -e "${BOLD}$source_config_name${NC} içeriği ${GREEN}${BOLD}${target_path}${NC} olarak yüklendi." # .bash_aliases'i .bashrc'ye ekle if [[ "$target_path" == "$HOME/.bash_aliases" ]]; then bashrc_path="$HOME/.bashrc" if ! grep -q "source $target_path" "$bashrc_path"; then echo "source $target_path" >> "$bashrc_path" echo -e "${BOLD}$(basename "$target_path")${NC} dosyası ${GREEN}${BOLD}$(basename "$bashrc_path")${NC} dosyasına eklendi." else echo -e "${YELLOW}${BOLD}$(basename "$target_path")${NC} zaten ${BOLD}$(basename "$bashrc_path")${NC} dosyasında kaynak olarak gösteriliyor." fi fi fi } # Tüm ayarları yükle for source_path in "${!config_files[@]}"; do setup_configuration "$source_path" "${config_files[$source_path]}" done echo -e "${GREEN}Tüm ayarlar tamamlandı!${NC}"