터미널 색상이 작동하지 않습니다


30

OSX에서 SSH를 통해 Ubuntu 10.04.2 LTS 서버에 액세스하고 있습니다. 최근에 색상이 작동을 멈췄습니다. RVM을 설치 / 문제 해결하는 동안 발생한 것으로 생각되지만 긍정적이지 않습니다.

.bashrc에서 나는 uncommeneted force_color_prompt=yes했고, 내가 실행할 때 env | grep TERM나는 얻는다 TERM=xterm-color. 그러나 여전히 색상이 없습니다.

어떤 아이디어? 감사!

출력은 다음과 같습니다 cat .bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi


# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac


# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
   alias dir='dir --color=auto'
   alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm"

안녕! 의 결과를 cat ~/.bashrc질문에 추가하십시오!
antivirtel

답변:


29

/ etc / skel에 샘플 기본 .bashrc 파일이 있습니다. 현재 .bashrc를 백업 mv .bashrc .bashrc.bak한 다음 cp /etc/skel/.bashrc .bashrc해당 샘플을 홈 디렉토리로 다시 복사 할 수 있습니다. 그런 force_color_prompt=yes다음 새 파일에서 주석 을 해제 하고 파일 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"의 끝 (마지막 줄)에 다시 추가 하여 RVM이 계속 작동하도록합니다.

그런 . .bashrc다음 프롬프트에서 실행 하여 bash 프로파일을 다시로드하십시오. 색상 프롬프트가 다시 표시되고 type rvm | head -1텍스트를 반환 해야하는 명령으로 RVM을 테스트하십시오 .rvm is a function

그래도 문제가 해결되지 않으면 Mac OS X에서 표준 터미널 앱을 사용 중인지, Mac의 터미널에서 어떤 프로필을 사용 중인지 알려주십시오.


나를 위해, Xubuntu 13.04
Green

9

Snow Leopard 에서 Lion 으로 업그레이드 한 후에 색상이 작동을 멈췄을 것입니다 .

Lion에서 어떤 이유로 든 기본적으로 터미널은 " xterm-color " 대신 " xterm-256color " 로 선언되며 이는 우분투가 이해하는 것입니다.

이전 조치에 의해 언급 한 바와 같이 옵션 중 하나는, 당신을 위해, 주석 force_color_prompt=yes~/.bashrc

다른 옵션은 Terminal.app에서 터미널을 xterm-color로 다시 선언하는 것입니다. 이를 수행하는 방법은 다음과 같습니다.

  1. Terminal.app 시작
  2. 메뉴 터미널-> 환경 설정으로 이동하십시오 (또는 Cmd + 사용)
  3. Settings탭으로 이동하여 기본으로 설정된 테마를 찾으십시오.
  4. Advanced탭으로 이동
  5. 옆에있는 드롭 다운을 찾아 xterm-color로Declare terminal as: 설정하십시오.

여기 내 설정이 있습니다

업데이트 : Mountain Lion 이 드롭 다운 메뉴에서 xterm-color 옵션을 완전히 제거한 것 같습니다 . 업그레이드를 수행하는 경우 이전 구성을 유지하는 것이 좋지만 새로 설치하는 경우 터미널의 구성 파일을 수동으로 편집해야하며 plist 편집기 ( 필요한 XCode에 포함) 가 필요합니다. App Store를 통해 설치). xterm-color 옵션 을 추가 하려면 다음과 같이 터미널 파일의 위치가 ~ / Library / Preferences / com.apple.Terminal.plist 에 있습니다 .

  1. 현재 실행중인 경우 Terminal.app를 종료하십시오.
  2. App Store에서 XCode 설치 (이 단계를 이미 설치 한 경우 생략)
  3. $ open ~/Library/Preferences/com.apple.Terminal.plist
  4. plist를 탐색하여 Root > Window Settings
  5. 기본 테마의 이름 (내 경우에는 Pro)을 찾아 확장하고 TerminalType키를 찾으십시오 .
  6. 이제 TerminalType키를 수동으로 xterm-color 로 변경하십시오.
  7. 파일을 저장하고 터미널을 시작하십시오.

1
nano ~/.bashrc

입력 Ctrl+ W및 검색 할 force_color첫 번째 결과는을 강조한다, f다만 한 후, #문자.

를 눌러 Backspace지금 Ctrl+ X다음 YYes다음 Enter.

source ~/.bashrc

또는

. ~/.bashrc

이제 터미널에 색상이 표시됩니다.

나는 이것이 당신을 위해 작동하기를 바랍니다.


0

.bash_login홈 디렉토리에 파일이없는 경우 파일 을 크레이트하여 넣을 수 .bashrc있습니다.

터미널을 닫았다가 다시 열면 문제가 해결됩니다!


0

macOS 터미널이 TERM을 이전 xterm-color로보고하도록 강제하지 않고 Linux에서 .bashrc를 변경하여 xterm-256color를 컬러 클라이언트로 인식 할 수 있습니다. 이것은 최신 버전의 우분투에서 기본값으로 보입니다. 이렇게하려면 다음 줄을 변경하십시오.

xterm-color) color_prompt=yes;;

에:

xterm-color|*-256color) color_prompt=yes;;

그런 다음 실행 source .bashrc하면 터미널이 컬러로 표시됩니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.