Answer the question
In order to leave comments, you need to log in
Different console background for different servers?
Good day, Habr!
I think each of those who use the built-in ssh console client from under Linux at least once got confused and executed a command on the server that should have been on the local machine or vice versa, or even confused the server. In general, you understand what I mean;)
Any ideas how to recolor the background of the console so that it is acceptable for server A it was black, server B is gray, etc.
Answer the question
In order to leave comments, you need to log in
Make different prompts on different servers, then this setting will be independent of the terminal emulator used. For example, [19:13:13; [email protected]; dir]$
you can highlight [email protected] in different colors.
In my opinion, it is enough to enter the server name in PS1:
\[\033[1;33;41m\h>\]\[\033[1;32;40m \D{%d.%m, %H:%M}\] \[\033[1;33;40m\w\]\[\033[1;32;40m\]\[\033[0;37;40m\n
#!/bin/sh
# Создан 17-го Июль 2009 года в 10:43
#
echo "
********* СВОЙСТВА **********
Название стиля | Код
------------------------|----
Сбросить все свойства | 0
Повышенная яркость | 1
Пониженная яркость | 2
Подчеркнутый | 4
Нормальная яркость | 5
Инвертированный | 7
Скрытый | 8
********** ЦВЕТА ***********
Название цвета |Текст |Фон
----------------|-------|---
Черный | 30 | 40
Красный | 31 | 41
Зеленый | 32 | 42
Желтый | 33 | 43
Синий | 34 | 44
Маджента | 35 | 45
Циановый | 36 | 46
Белый | 37 | 47
----------------------------
Цвета задаются в формате [свойство;цвет_текста;цвет_фона] (можно указывать только один пар.),
например: \033[37;40m - белый текст на черном фоне
"
HEADER="\t\t"
for B in `seq 40 47`
do
HEADER=`echo -e "$HEADER Фон $B\t\c"`
done
for A in 1 2 4 5 7 8
do
echo -e "\033[0m\n\n Свойство $A:\n$HEADER\c"
for B in `seq 30 37`
do
echo -e "\n Текст $B\t\c"
for C in `seq 40 47`
do
echo -e "\033[$A;$B;$C""m Буквы\t\c"
done
echo -e "\033[0m\c"
done
done
echo -e "\033[0m\n\n"
5 servers in tabs and get the dream of an epileptic. :)
I use "[lapatopa frol:~]$" coloring for the welcome font color, usually green + machine name highlighted in red/yellow (in this case, lapatopa is my local laptop, so I have it green). On production servers, I have the server name highlighted in red :)
I don't have many servers. I work out by setting up Profiles in the Gnome Terminal.
The command for each profile is ssh [email protected]
On the Colors tab, you can customize the look you want.
Maybe it will help:
$ setterm -foreground green -background black -store
besides displaying the server name in the prompt, I also highlight different tabs for different machines: 3-local, 4-production-server
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question