Add Linux/SSH/colorscheme.sh
This commit is contained in:
45
Linux/SSH/colorscheme.sh
Normal file
45
Linux/SSH/colorscheme.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
BASHRC_CONTENT="\n# Farbiges ls und grep\nalias ls='ls --color=auto'\nalias grep='grep --color=auto'\nalias egrep='egrep --color=auto'\nalias fgrep='fgrep --color=auto'\neval \"\$(dircolors -b ~/.dircolors)\"\nif [ \"\$EUID\" -eq 0 ]; then\n PS1='\\[\\e[1;31m\\]\\u\\[\\e[0;33m\\]@\\[\\e[1;35m\\]\\h \\\[\\e[1;33m\\]\\w\\[\\e[0m\\] # '
|
||||
else\n PS1='\\[\\e[1;32m\\]\\u\\[\\e[0;33m\\]@\\[\\e[1;35m\\]\\h \\\[\\e[1;34m\\]\\w\\[\\e[0m\\] \\\$ '
|
||||
fi\n"
|
||||
|
||||
# Sicherstellen, dass die Datei ~/.dircolors erstellt wird
|
||||
dircolors -p > ~/.dircolors
|
||||
|
||||
# Funktion, um die .bashrc Datei zu aktualisieren
|
||||
update_bashrc() {
|
||||
local user_home=$1
|
||||
local bashrc_file="$user_home/.bashrc"
|
||||
|
||||
# Sicherstellen, dass die Datei existiert
|
||||
touch "$bashrc_file"
|
||||
|
||||
# Prüfen, ob der Inhalt bereits existiert, wenn nicht, hinzufügen
|
||||
if ! grep -q "Farbiges ls und grep" "$bashrc_file"; then
|
||||
echo -e "$BASHRC_CONTENT" >> "$bashrc_file"
|
||||
echo "$bashrc_file wurde aktualisiert."
|
||||
else
|
||||
echo "$bashrc_file ist bereits aktuell."
|
||||
fi
|
||||
|
||||
# .dircolors in das Benutzerverzeichnis kopieren (außer für root)
|
||||
if [ "$user_home" != "/root" ]; then
|
||||
cp ~/.dircolors "$user_home/.dircolors"
|
||||
chown $(basename $user_home):$(basename $user_home) "$user_home/.dircolors"
|
||||
fi
|
||||
}
|
||||
|
||||
# Aktualisiere die .bashrc Datei für root
|
||||
update_bashrc /root
|
||||
|
||||
# Aktualisiere die .bashrc Datei für alle Benutzer im /home Verzeichnis
|
||||
for dir in /home/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
update_bashrc "$dir"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Skriptausführung abgeschlossen."
|
||||
```
|
||||
Reference in New Issue
Block a user