QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 957|回复: 11

奇怪的PS1变量问题

[复制链接]
发表于 2004-4-6 11:58:40 | 显示全部楼层 |阅读模式
我在X下面启动终端的时候,显示的总是bash-2.0.5 #,也就是说没有PS1变量,这个比较郁闷的说,非得要手动 source /etc/profile才能显示,我已经把PS1手动添加到/etc/profile.env里面了,仍然无效,有谁知道该怎么做吗?

现在的问题是本来应该已经有PS1了,进入X之后自动取消了……faint,这该怎么办?在~/.xinitrc 手动写入吗?
发表于 2004-4-6 12:13:58 | 显示全部楼层
这是个问题,呵呵,我也想知道。我也遇到了这个问题。
回复

使用道具 举报

发表于 2004-4-7 09:25:42 | 显示全部楼层
在/etc/conf.d/basic里加入source /etc/profile
回复

使用道具 举报

发表于 2004-4-7 11:38:17 | 显示全部楼层
看一下 /etc/skel/.bashrc 你就明白了。

我也就不多说了。
回复

使用道具 举报

 楼主| 发表于 2004-4-7 12:37:06 | 显示全部楼层
是不是应该把最后一行uncomment?
回复

使用道具 举报

发表于 2004-4-9 08:44:04 | 显示全部楼层
o ?!
回复

使用道具 举报

 楼主| 发表于 2004-4-9 19:44:06 | 显示全部楼层
试过了,不行。
似乎是系统在X启动的时候清除了PS1变量……
回复

使用道具 举报

发表于 2004-4-18 10:01:03 | 显示全部楼层
家目录里必须有 ~/.bash_profile
登录时才会读 .bash_profile , .bash_profile 则有对 .bashrc 的引用:

[code:1]
$> cat .bash_profile
# ~/.bash_profile: executed by bash(1) for login shells.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/login.defs
#umask 022

# the rest of this file is commented out.

# include .bashrc if it exists

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
fi

# do the same with MANPATH
#if [ -d ~/man ]; then
#    MANPATH=~/man:"${MANPATH}"
#    export MANPATH
#fi
[/code:1]

新建立一个用户时, /etc/skel 下的所有文件将被自动复制到用户家目录下(注意有 .**这样的隐藏文 件) , 其中一个就是 .bash_profile, debian 的这个文件里对 .bashrc 的引用并没有默认打开, 所以还需要自己编辑一下, 变成上的样子.

(这里对 debian 而言, 其它发行版也许会有不同之处, 请大家指出.谢谢)
回复

使用道具 举报

 楼主| 发表于 2004-4-18 18:03:22 | 显示全部楼层
我的有的,黑企鹅……
内容方面没什么问题,console下面也没问题,就是term shell里面不行,但是如果在term下面再启动一个shell,却可以了……
回复

使用道具 举报

发表于 2004-4-19 01:29:09 | 显示全部楼层
man 1 bash

       When  bash is invoked as an interactive login shell, or as
       a non-interactive shell with the --login option, it  first
       reads and executes commands from the file /etc/profile, if
       that file exists.  After reading that file, it  looks  for
       ~/.bash_profile,  ~/.bash_login,  and  ~/.profile, in that
       order, and reads and executes commands from the first  one
       that  exists  and is readable.                           

       When an interactive shell that is not  a  login  shell  is
       started,  bash reads and executes commands from ~/.bashrc,
       if that file exists.
回复

使用道具 举报

 楼主| 发表于 2004-4-19 10:29:53 | 显示全部楼层
大哥,我不是不知道这些啊,就是因为都试过了,还不行,才发帖啊。
回复

使用道具 举报

发表于 2004-4-19 10:44:46 | 显示全部楼层
echo "source /etc/profile" >> ~/.bashrc

have a try
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-10-5 12:35 , Processed in 0.051263 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表