bash:〜/ .bash_profile:没有这样的文件或目录

时间:2014-10-09 22:46:10

标签: bash

我一直收到这个错误:

bash: ~/.bash_profile: No such file or directory

这是我的bash_profile:

alias ngrok=/Users/mmahalwy/Desktop/Code/ngrok

export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced

alias ls='ls -GFh'

function prompt {
  local BLACK="\[\033[0;30m\]"
  local BLACKBOLD="\[\033[1;30m\]"
  local RED="\[\033[0;31m\]"
  local REDBOLD="\[\033[1;31m\]"
  local GREEN="\[\033[0;32m\]"
  local GREENBOLD="\[\033[1;32m\]"
  local YELLOW="\[\033[0;33m\]"
  local YELLOWBOLD="\[\033[1;33m\]"
  local BLUE="\[\033[0;34m\]"
  local BLUEBOLD="\[\033[1;34m\]"
  local PURPLE="\[\033[0;35m\]"
  local PURPLEBOLD="\[\033[1;35m\]"
  local CYAN="\[\033[0;36m\]"
  local CYANBOLD="\[\033[1;36m\]"
  local WHITE="\[\033[0;37m\]"
  local WHITEBOLD="\[\033[1;37m\]"
  local RESETCOLOR="\[\e[00m\]"

  export PS1="\n$RED\u $PURPLE@ $GREEN\w $BLUE[\#] → $RESETCOLOR"
  export PS2="| → $RESETCOLOR"
}

# prompt

export PATH=/usr/local/bin:$PATH

source ~/.git-completion.bash

if [ -f `brew --prefix`/etc/bash_completion ]; then
    . `brew --prefix`/etc/bash_completion
fi


source ~/.profile
source /Users/mmahalwy/.iterm2_shell_integration.bash

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

更新

问题是我在vim中错误地复制过的"~/.bash_profile" 38L, 1070C。谢谢您的帮助!

3 个答案:

答案 0 :(得分:8)

Bash有~/.profile而不是~/.bash_profile

~/.profile的内容:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# 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/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

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

答案 1 :(得分:2)

更新

问题是一个尾随的“〜/ .bash_profile”38L,1070C,我从vim那里错误地复制了。谢谢你的帮助!

答案 2 :(得分:0)

在我的情况下,我收到以下错误。

-bash: /Users/mac241/.rvm/scripts/rvm: No such file or directory
-bash: /Users/mac241/.rvm/scripts/rvm: No such file or directory

经过几次检查后,我知道创建.bash_profile文件的时间,下面已经预先写好了两个命令。

source /Users/mac241/.rvm/scripts/rvm
source /Users/mac241/.rvm/scripts/rvm  

基于错误,我知道这是问题,在我删除后,它开始工作。希望您编写并定义那些只需要在shell启动时自动运行的命令。