当我将它移动到一个新的环境时,我的bashrc停止了工作?

时间:2015-07-30 11:22:02

标签: windows git macos bash shell

我刚将所有文件从Windows移动到OS X(现在在Macbook Air上)。我在windows上使用了bash shell,我以为我会在我的mac上使用相同的bash shell(或类似的)。 Windows上的那个来自我的git安装。 OS X已经内置了一个,称为终端。

.bash_profile只有一行source /root/config/bashrc.sh

bashrc.sh看起来像这样:

warp() {
  cd /c/root/ ; 
}

launch() { 
  git add -A . ;
  git commit -m $1 ;
  git push heroku master ;
  echo $1 ;
}

#defaults
export VISUAL=sublime_text
export EDITOR="$VISUAL"

#aliases
alias i="ipconfig"
alias s="sublime_text &"
alias l="ls -a -l"

#commands
warp
#grunt watch &
#sublime_text &
clear

#output
echo ""
echo "************************************************"
echo " - .bashrc loaded and sourced to bashrc.sh"
echo " -  added functions warp() and launch()"
echo " -  added alias (i)pconfig (s)ublime (l)s -a -l"
echo "************************************************"
echo ""

这就是"炸毁"当我运行它。终端给出了以下错误。以前它没有错误。

'bash: /root/config/bashrc.sh: line 1: syntax error near unexpected token `{
'bash: /root/config/bashrc.sh: line 1: `warp() {

1 个答案:

答案 0 :(得分:1)

  

问题是与/root/config/bashrc.sh

的.bashrc配置的间接采购相关的权限      

正常的解决方案就是直接将配置写入〜/ .bashrc文件

<强>〜/ .bashrc中

warp() {
  cd /c/root/ ; 
}

launch() { 
  git add -A . ;
  git commit -m $1 ;
  git push heroku master ;
  echo $1 ;
}

#defaults
export VISUAL=sublime_text
export EDITOR="$VISUAL"

#aliases
alias i="ipconfig"
alias s="sublime_text &"
alias l="ls -a -l"

#commands
warp
#grunt watch &
#sublime_text &
clear

#output
echo ""
echo "************************************************"
echo " - .bashrc loaded and sourced to bashrc.sh"
echo " -  added functions warp() and launch()"
echo " -  added alias (i)pconfig (s)ublime (l)s -a -l"
echo "************************************************"
echo ""

替代解决方案[不推荐]

如果在〜/ .bashrc

中使用以下内容
source /root/config/bashrc.sh;

然后您必须授予用户对以下文件的读取和执行权限

/root
/root/config
/root/config/bashrc.sh

在/ root上给+ rx通常不是一个好主意。

或者您可以将配置放在某个地方,例如/etc/user.bashrc.sh,您已经可以作为用户访问/ etc ..