kar*_*gen 28 ssh session themes command-line
是否可以根据我通过 SSH 连接到的服务器自动更改终端的颜色?
例如,当我启动终端时,它在我的配置文件下定义了标准颜色。然后我 ssh 到 ssh.example.com 并且颜色变为黑色和绿色。然后我退出会话,颜色返回到标准颜色主题。
我知道您可以手动执行此操作。但我正在寻找一种自动化的方式。
Rad*_*anu 24
是的,你可以通过改变PS1在价值.bashrc上的每个主机文件,其中要连接带ssh。
请参阅此答案以查看如何根据您喜欢 bash 更改PS1值的方式进行服装化。

在我的机器上(radu@Radu)我有.bashrc:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\]\u@\h\[\033[00m\]:\[\033[01;34m\] \w\[\033[01;37m\] > '
Run Code Online (Sandbox Code Playgroud)
在托管机器(radu@ubuntu)上,我有:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35;40m\]\u@ubuntu\[\033[00;40m\]:\[\033[01;34;40m\] \w\[\033[01;32;40m\] > '
Run Code Online (Sandbox Code Playgroud)