bash 我怎样才能摆脱在每个新终端会话上运行的东西?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9555868/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get rid of something running on every new terminal session?
提问by Inc1982
I am using Lion. I have an error that outputs on every new terminal session:
我正在使用狮子。我有一个错误,在每个新的终端会话上输出:
-bash: __rvm_add_to_path: command not found
It's an almost brand new user account.. RVM is installed on the other account on the machine.. ~/.bashrc & ~/.bash_profile are both blank.. the out put of env is:
这是一个几乎全新的用户帐户.. RVM 安装在机器上的另一个帐户上.. ~/.bashrc & ~/.bash_profile 都是空白.. env 的输出是:
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/ry/8zsyknmx7dj4_2zzvn1n71500000gn/T/
Apple_PubSub_Socket_Render=/tmp/launch-jsfKPw/Render
TERM_PROGRAM_VERSION=303
TERM_SESSION_ID=3EBC0F1A-9867-41E5-8873-75E84B9F712F
USER=incorvia
COMMAND_MODE=unix2003
SSH_AUTH_SOCK=/tmp/launch-ZQqgPj/Listeners
Apple_Ubiquity_Message=/tmp/launch-u3d1lp/Apple_Ubiquity_Message
__CF_USER_TEXT_ENCODING=0x1F5:0:0
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin
PWD=/bin
LANG=en_US.UTF-8
HOME=/Users/incorvia
SHLVL=1
LOGNAME=incorvia
DISPLAY=/tmp/launch-0B0I8s/org.x:0
_=/usr/bin/env
I see nothing related to RVM here.. where else can I look?
我在这里看不到任何与 RVM 相关的内容……我还能在哪里看?
=====
======
/etc/bashrc
/etc/bashrc
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
# Tell the terminal about the working directory at each prompt.
if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then
update_terminal_cwd() {
# Identify the directory using a "file:" scheme URL,
# including the host name to disambiguate local vs.
# remote connections. Percent-escape spaces.
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND"
fi
=========
==========
Fixed...
固定的...
In the bottom of my /etc/profile it was sourcing /etc/profile.d/rvm.sh
在我的 /etc/profile 底部,它正在采购 /etc/profile.d/rvm.sh
Don't know how that got there...
不知道那是怎么来的...
回答by simont
Bash loads a series of files during startup. A good overview of the bash startup process can be found here.
Bash 在启动期间加载一系列文件。可以在此处找到有关 bash 启动过程的良好概述。
Generally, the global settings, /etc/profile, /etc/bashrc, and the associated personalized settings, ~/.profileand ~/.bashrcare loaded, although that is slightly distribution-dependant (and on Mac OS X, for example, by default /etc/profiledoesn't exist).
一般情况下,全局设置,/etc/profile,/etc/bashrc,和相关的个性化设置,~/.profile并~/.bashrc加载,虽然稍微分布相关的(和Mac OS X上,例如,在默认情况下/etc/profile不存在)。
From the RVM Installation page:
从RVM 安装页面:
Multi-User:
The rvm function will be automatically configured for every user on the system if you install as root. This is accomplished by loading /etc/profile.d/rvm.sh on login. Most Linux distributions default to parsing /etc/profile which contains the logic to load all files residing in the /etc/profile.d/ directory. Once you have added the users you want to be able to use RVM to the rvm group, those users MUST log out and back in to gain rvm group membership because group memberships are only evaluated by the operating system at initial login time.
多用户:
如果您以 root 身份安装,rvm 功能将自动为系统上的每个用户配置。这是通过在登录时加载 /etc/profile.d/rvm.sh 来完成的。大多数 Linux 发行版默认解析 /etc/profile,其中包含加载位于 /etc/profile.d/ 目录中的所有文件的逻辑。一旦您将希望能够使用 RVM 的用户添加到 rvm 组,这些用户必须注销并重新登录以获得 rvm 组成员身份,因为组成员身份仅在初始登录时由操作系统评估。
I'd guess that the other use has installed in Multi-Usermode;
/etc/profileprobably loads /etc/profile.d/rvm.sh.
我猜其他用途已经安装在Multi-User模式中;
/etc/profile可能加载/etc/profile.d/rvm.sh。
To stop it being loaded, you could remove the source RVMline from /etc/profile- this will stop it being loaded for all users, though.
要停止加载它,您可以删除该source RVM行/etc/profile- 这将停止为所有用户加载它,但是。
回答by Nick Henry
For the account that had a working profile, I had the following .rvmrc:
对于具有工作配置文件的帐户,我有以下 .rvmrc:
root@sc-27617:~# cat .rvmrc
export rvm_prefix="/usr/local/lib/sc"
export rvm_path="/usr/local/lib/sc/rvm"
To get the error to go away for my other accounts, I simply copied this file to the other accounts and fixed the permissions (chown johndoe:johndoe /home/johndoe/.rvmrc)...
为了让我的其他帐户的错误消失,我只是将此文件复制到其他帐户并修复了权限(chown johndoe:johndoe /home/johndoe/.rvmrc)...
回答by zhihong
In Ubuntu 12.04, by default, the /etc/profile.d/rvm.sh will not be loaded when starting a new terminal. So every time, when starting a new termail, cmd as follows must be used to start rvm:
在 Ubuntu 12.04 中,默认情况下,启动新终端时不会加载 /etc/profile.d/rvm.sh。所以每次启动一个新的终端时,必须使用如下cmd启动rvm:
source /etc/profile.d/rvm.sh
And there are two ways to fix it:
有两种方法可以修复它:
open a new terminal-> right click and select Profiles->Profile Preferences->Title and Command->select "Run command as a login shell".
open a new terminal->run cmd as follows then the /etc/profile.d/rvm.sh will be auto loaded in a new terminal:
echo '[[ -s "/etc/profile.d/rvm.sh" ]] && . "/etc/profile.d/rvm.sh" # Load RVM function' >> ~/.bashrc
打开一个新终端-> 右键单击并选择配置文件-> 配置文件首选项-> 标题和命令-> 选择“将命令作为登录shell 运行”。
打开一个新的终端->按如下方式运行 cmd 然后 /etc/profile.d/rvm.sh 将自动加载到新终端中:
echo '[[ -s "/etc/profile.d/rvm.sh" ]] && 。"/etc/profile.d/rvm.sh" # 加载 RVM 函数' >> ~/.bashrc
As some explanation hereto say the 1st solution is not a nice one but the 2nd is suggested.
作为这里的一些解释,第一个解决方案不是一个好的解决方案,但建议使用第二个解决方案。
So in other way round, if you do not want the terminal to run something in a new terminal, you need to check whether the auto load is coursed by the two ways:
因此,反过来,如果您不希望终端在新终端中运行某些内容,则需要检查自动加载是否通过两种方式进行:
check whether the "Run command as a login shell" is selected and unselect it.
open the ~/.bashrc file ,find the lines related loading the function and delete it.
检查是否选择了“作为登录外壳运行命令”并取消选择它。
打开 ~/.bashrc 文件,找到与加载函数相关的行并删除它。
回答by Salem Thompson
I had the same file (/etc/profile.d/rvm.sh) from a previous rvm installation. Deleting that file worked for me as well.
我在之前的 rvm 安装中有相同的文件 (/etc/profile.d/rvm.sh)。删除该文件也对我有用。
For the sake of being thorough, logging out of the shell seems to be required.
为了彻底起见,似乎需要注销 shell。
回答by siefca
In your /etc/profilechange the line:
在您的/etc/profile更改行中:
source /etc/profile.d/rvm.sh
source /etc/profile.d/rvm.sh
into:
进入:
if [ "${SHELL}" != "/bin/sh" ]; then
source /etc/profile.d/rvm.sh
fi
Why?
为什么?
In Mac OS X the default shell of superuser (root) is a POSIX shell, not a pure Bash. Adding such condition will disable rvmfor (possibly) emerygency shell /bin/sh, used by system administrator. That is good. If you would like to install something using root's account, you can always type bashand then rvm …in a command line.
在 Mac OS X 中,超级用户 ( root)的默认 shell是 POSIX shell,而不是纯 Bash。添加此类条件将禁用rvm(可能)/bin/sh系统管理员使用的紧急外壳。那很好。如果您想使用root的帐户安装某些东西,您可以随时在命令行中输入bash和rvm …。
回答by Tim Ogilvy
Debian 6.1 scans the /etc/profile.d/ file for all .sh files and includes them, so there's no listing for rvm in any of the profiles or .bashrc files anywhere. Deleting rvm.sh from /etc/profile.d/ solves this.
Debian 6.1 会扫描 /etc/profile.d/ 文件中的所有 .sh 文件并将其包含在内,因此在任何配置文件或任何 .bashrc 文件中都没有列出 rvm。从 /etc/profile.d/ 中删除 rvm.sh 可以解决这个问题。
回答by Hadi Farnoud
if you have ZSH or OH-MY-ZSH, then you need to remove source /etc/profile.d/rvm.shfrom /etc/zprofile
如果您有 ZSH 或 OH-MY-ZSH,那么您需要从/etc/zprofile 中删除源/etc/profile.d/rvm.sh

