登录时accurev是否读取任何文件?

发布于 2024-08-12 14:13:54 字数 379 浏览 2 评论 0原文

在linux中,我需要一旦登录accurev,PS1就会更改为以下内容:

假设我的工作空间放置在路径~/myfiles/accurev/ws/myworkspace

<username>@<machineName> : ACCUREV > 

,因此,当我例如cd到<代码>~/myfiles/accurev/ws/myworkspace/myproject1/org/daz/ , PS1 是:

<username>@<machineName> : ACCUREV/myproject1/org/daz > 

In linux, I need once I login to accurev, the PS1 changes to the following:

suppose my workspace placed in the path ~/myfiles/accurev/ws/myworkspace

<username>@<machineName> : ACCUREV > 

so, when I for example cd to ~/myfiles/accurev/ws/myworkspace/myproject1/org/daz/ ,
the PS1 be :

<username>@<machineName> : ACCUREV/myproject1/org/daz > 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜唯美灬不弃 2024-08-19 14:13:54

您可以使用 Accurev info 中的数据来实现此目的。但在每次提示加载时执行此操作可能会很烦人,因为该命令需要几秒钟才能完成。您可以通过检查您的 PWD 是否已更改并仅在更改目录时运行它来调节这一点。

例如,这里有一种方法来获取 PWD 相对于 Accurev Info 的“Top”的路径:

pwd | cut -b`accurev info 2>/dev/null | grep Top | awk '{print $2}' | wc -c | awk '{print $1}'`- 2>/dev/null

您可以将其放入 PS1,但每个提示都会额外花费 1-2 秒。如果您只想在目录更改时执行此操作,则可以使用 PROMPT_COMMAND 来完成该工作,但前提是 PWD != OLDPWD

所以。可行吗?是的。值得吗?很难说。

哦,至于你的颜色。查看https://github.com/matschaffer/profile,特别是https://github.com/matschaffer/profile/blob/master/environment.conf 用于 PS1 定义在底部。这应该会给你一些想法。

You can use the data in accurev info to pull this off. But doing it on every prompt load might get annoying since the command takes a few seconds to complete. You could maybe temper that by checking if your PWD has changed and only run it when changing directories.

For example, here's a way to get the path of your PWD relative to accurev info's 'Top':

pwd | cut -b`accurev info 2>/dev/null | grep Top | awk '{print $2}' | wc -c | awk '{print $1}'`- 2>/dev/null

You could drop this into PS1, but then every prompt will take 1-2 extra seconds. If you wanted to do it only on directory changes you could probably use PROMPT_COMMAND to do the work but only if PWD != OLDPWD.

So. Doable? yes. Worth it? hard to say.

Oh, and as for your colors. Check out https://github.com/matschaffer/profile, specifically https://github.com/matschaffer/profile/blob/master/environment.conf for the PS1 definition at the bottom. That should give you some ideas.

猫弦 2024-08-19 14:13:54

您应该使用以下命令输入工作区:

accurev start -w myworkspace

然后在 .bashrc 中添加以下内容:

if [ "${ACCUREV_TOPDIR}" != "" ] 
then
  PS1='[\u@\h `pwd | sed -e "s#${ACCUREV_TOPDIR}#ACCUREV#"`]\$ '
else
  PS1='[\u@\h \W]\$ '
fi
export PS1

我个人更喜欢看到工作区,例如:

PS1='[\u@\h `pwd | sed -e "s#${ACCUREV_TOPDIR}#WS(${ACCUREV_WSPACE})#"`]\$ '

You should enter your workspaces with the following command:

accurev start -w myworkspace

Then in your .bashrc add the following:

if [ "${ACCUREV_TOPDIR}" != "" ] 
then
  PS1='[\u@\h `pwd | sed -e "s#${ACCUREV_TOPDIR}#ACCUREV#"`]\$ '
else
  PS1='[\u@\h \W]\$ '
fi
export PS1

I personally prefer to see the workspace as well like:

PS1='[\u@\h `pwd | sed -e "s#${ACCUREV_TOPDIR}#WS(${ACCUREV_WSPACE})#"`]\$ '
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文