iTerm2: 구성 파일을 소스로 가져오려고 하면 이상한 오류 메시지가 나타납니다.

iTerm2: 구성 파일을 소스로 가져오려고 하면 이상한 오류 메시지가 나타납니다.

iTerm2 3.0.15
OS X 10.11.6

최근에 새로 설치한 후 터미널을 구성하려고 했습니다. 제 문제는 그렇게 할 때 이상한 오류 메시지가 나타난다는 것입니다. 내 .bash 디렉토리로 이동합니다. 여기에는 별명, bash_profile, 내보내기, 추가 기능, 함수, inputrc, 경로 및 프롬프트라는 이름의 여러 구성 파일이 있습니다.

내가 할 때 :

source bash_profile

다음 오류 메시지가 나타납니다.

-bash: book: command not found

모든 구성 파일에서 정확히 동일한 오류 메시지가 나타납니다.

두 가지 문제가 있습니다.

  1. 내 bash_profile 파일은 내가 시도한 다른 구성 파일과 마찬가지로 소스가 아닙니다.

  2. 터미널을 구성하는 것이 기본이라고 확신하지만 오류 메시지가 실제로 무엇을 의미하는지 이해하지 못합니다. 해당 명령에 문제가 있다는 것을 알지만 book이에 대한 귀중한 정보를 얻을 수 없습니다.

내가 시도한 것:

  • 터미널 명령: man book, book --help또는 명령이 존재하지 않거나 수동 입력이 없다고 help book말했습니다 . 결과 book만 줬는데 명령보다는 명령 info book에 더 관련이 있는 것 같네요 . 그리고 내 구성 파일에도 언급이 없습니다 .infobookbook

  • Google 검색 "bash: book: 명령을 찾을 수 없음"은 물론 "명령을 찾을 수 없음"을 많이 반환하지 않지만 이에 대한 유일한 참조는 bookBash-it의 Github 저장소에 있는 게시물입니다. 찾을 수 없는 명령에 대한 대부분의 답변은 PATH 환경 변수에 관한 것이지만 다음과 같이 경로를 수동으로 입력하더라도(올바른 방법이길 바랍니다):

    export PATH=~/.rbenv/shims:/usr/local/Cellar:/usr/local/bin:/usr/local/sbin:/usr/local/bin/flake8:/usr/local/bin/git:/usr/bin:/bin:/usr/sbin:/sbin
    

    그 후 다시 시도하면 source bash_profile동일한 결과가 나타납니다 -bash: book: command not found.

  • Terminal.app에도 동일한 문제가 있습니다.

내 bash_profile 파일:

#--------------------------------------------------------------------------#

# B A S H _ P R O F I L E

#--------------------------------------------------------------------------#

# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc

# Load the shell dotfiles, and then some:
# * ~/.path can be used to extend `$PATH`.
# * ~/.extra can be used for other settings you don’t want to commit.
for file in ~/.bash/{path,prompt,exports,aliases,functions,extra,inputrc}; do
    [ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
unset file;

# Enable iTerm 2 Shell Integration
source ~/.iterm2_shell_integration.`basename $SHELL`

# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob;

# Append to the Bash history file, rather than overwriting it
shopt -s histappend;

# Autocorrect typos in path names when using `cd`
shopt -s cdspell;

# Do not autocomplete when accidentally pressing Tab on an empty line.
shopt -s no_empty_cmd_completion

# Enable tab completion for `g` by marking it as an alias for `git`
if type _git &> /dev/null && [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then
    complete -o default -o nospace -F _git g;
fi;

# Add tab completion for many Bash commands
#if which brew > /dev/null && [ -f "$(brew --prefix)/share/bash-completion/#bash_completion" ]; then
#   source "$(brew --prefix)/share/bash-completion/bash_completion";
#elif [ -f /etc/bash_completion ]; then
#    source /etc/bash_completion;
#fi;

# Thanks to @tmoitie, adds more tab completion for bash,
# also when hitting tab twice it will show a list.
#if [ -f $(brew --prefix)/etc/bash_completion ]; then
#    . $(brew --prefix)/etc/bash_completion
#fi

# R U B Y
# Ensure rbenv will be used first
# eval "$(rbenv init -)"
# test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" 

답변1

마침내 Homebrew를 통해 Bash 4.4.19를 설치하고 이를 사용하도록 iTerm 기본 설정을 편집했습니다. 이름 앞에 점을 추가하여 구성 파일의 이름을 바꾸었고 놀랍게도 작동했습니다. 즉, 구성 파일을 수동으로 소싱했을 때 iTerm이 변경 사항을 반영했습니다.

파일 이름을 직접 바꾸면 동일한 결과를 얻을 수 있는지, 아니면 새 버전의 Bash로 인한 변경으로 인해 마침내 작동했는지는 알 수 없습니다. 나는 bash를 잘 모르지만 기본 구성이 어떻게 든 엉망이되어 새 버전을 새로 설치하여 사용한다고 가정합니다.소유하다기본 구성은 작동하기에 충분했습니다.

몇 번 사용한 후 iTerm이 실행 시 .bash_profile 파일을 자동으로 로드하지 않는다는 것을 깨달았습니다. 다행히도 저는 해결책을 찾았습니다. 실행 파일을 찾을 위치를 지정할 수 있는 앱의 기본 설정에서 시작 시 실행할 명령을 추가할 수 있습니다. source ~/.bash_profile더 나은 해결책을 찾을 때까지 작업을 수행하겠습니다.

관련 정보