jwb*_*ley 1 debian bash bashrc
我正在尝试将系统所有用户的提示值($PS1 变量)更改为相同的值。
我将以下内容存储在文件 /etc/ps1 中:
PS1='`
if [ $? -eq 0 ];
then echo -n "\[\033[00;35m\]\u\[\033[01;32m\]@\[\033[00;35m\]\h\[\033[00;32m\](\[\033[01;35m\]\W\[\033[01;32m\])\[\033[00;32m\]\$";
else echo -n "\[\033[00;35m\]\u\[\033[01;31m\]@\[\033[00;35m\]\h\[\033[01;31m\](\[\033[35m\]\W\[\033[31m\])\[\033[00;31m\]\$";
fi`\[\033[0m\]'
Run Code Online (Sandbox Code Playgroud)
在我的单用户帐户下,我可以将source /etc/ps1
它添加到我的 ~/.profile 文件中(有趣的是,当我将它添加到 ~/.bashrc 时它不起作用)。如果我将其添加到 /etc/profile 或 /etc/bashrc.basrch 以使所有用户都发生这种情况,则不会发生任何事情。我正在拔头发试图让它发挥作用。这是在 Debian 7.1.0 (Linux 3.2.46) 上。
将修改后的 PS1 设置添加到/etc/profile.d/custom_ps1.sh
. 下面的文件/etc/profile.d
自动来源于/etc/profile
:
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
Run Code Online (Sandbox Code Playgroud)
每当生成登录外壳时都会调用它。从bash
联机帮助页:
当 bash 作为交互式登录 shell 或作为具有
--login
选项的非交互式 shell 调用时,它首先从文件中读取并执行命令/etc/profile
(如果该文件存在)。读取该文件后,它会按该顺序查找~/.bash_profile
、~/.bash_login
、 和~/.profile
,并从第一个存在且可读的命令中读取和执行命令。--noprofile
当 shell 启动时可以使用该选项来禁止这种行为。
归档时间: |
|
查看次数: |
3311 次 |
最近记录: |