基本问题:当我在终端中打开新选项卡时,bash 失败并显示以下错误输出:
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `exec -la (null) (null) -1'
[Process completed]
在首选项中,我设置了使用相同设置/目录打开的新选项卡。
我一直在学习自定义 bash 提示符区域,实际上是试图解决这个问题,但无济于事。在我意识到我应该由用户执行此操作之前,我搞乱了/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
最后,我的 ~/.bash_profile 如下所示:
source /etc/bashrc
export PATH=~/Code:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin.
export CLASSPATH=~/Programs/:~/Programs/bailey.jar:~/Programs/labs/:.
export PYTHONPATH=~/dm/:~/Code/Git/.:.
如果有人能给我任何建议,那就太好了。
最佳答案
我也遇到了这个问题,并发现我不小心更改了终端首选项的“启动”选项卡中的设置。设置为“外壳打开方式:命令(完整路径):。”
我将其改回“外壳打开方式:默认登录外壳”,这解决了问题。
关于bash - Terminal.app 中的新选项卡无法在同一目录中打开/bash 失败(Mountain Lion),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17181044/