ターミナルの色が機能しない


30

OSXからSSH経由でUbuntu 10.04.2 LTSサーバーにアクセスしています。最近、色が機能しなくなりました。RVMのインストール/トラブルシューティング中に起こったと思いますが、ポジティブではありません。

では.bashrcのI 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

あなたとあなたの現在の.bashrcのバックアップを作ることができる-サンプルでは/ etc / skelの位置デフォルト.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
グリーン

9

色は、あなたがにアップグレードおそらく後、作業を停止しているライオンからSnow Leopardは

ライオンでは、何らかの理由で、デフォルトで端末が「と宣言されているのxterm-256色の代わりに」の「xtermの色 Ubuntuが理解するものです」。

前回の応答で述べたように選択肢の一つは、あなたのためです、コメントを解除force_color_prompt=yes~/.bashrc

もう1つのオプションは、Terminal.appで端末をxterm-colorとして再宣言することです。その方法は次のとおりです。

  1. Terminal.appを起動します
  2. [ターミナル]メニューの[設定]に移動します(またはCmd +を使用します)。
  3. Settingsタブに移動し、デフォルトとして設定されているテーマを見つけます
  4. Advancedタブに移動します
  5. 横のドロップダウンを見つけて、xterm-colorDeclare terminal as:設定します

ここに私の設定があります

更新Mountain Lionxterm-colorオプションをドロップダウンメニューから完全に削除したようです。アップグレードを行う場合、おそらく古い構成を保持しますが、新規インストールを行う場合は、ターミナルの構成ファイルを手動で編集する必要があります。そのためには、plistエディター(XCodeに必要なものが含まれます) App Store経由でインストールされます)。ターミナルのファイルの場所は〜/ Library / Preferences / com.apple.Terminal.plistにあり、xterm-colorオプションを追加するには次のようにします。

  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、その後YのためにYes、そしてEnter

source ~/.bashrc

または

. ~/.bashrc

ターミナルに色が表示されます。

これがお役に立てば幸いです。


0

代替手段の.bash_login1つは、ホームディレクトリにファイルが存在しない場合はファイルを作成し、中に入れること.bashrcです。

ターミナルを閉じて再度開きます。問題を解決する必要があります。


0

macOSターミナルにTERMを古いxterm-colorとして強制的に報告させるのではなく、Linux上の.bashrcを変更して、xterm-256colorをカラークライアントとして認識させることができます。これは、Ubuntuの新しいバージョンのデフォルトのようです。これを行うには、次の行を変更します。

xterm-color) color_prompt=yes;;

に:

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

次に実行するsource .bashrcと、ターミナルがカラーで表示されます。

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.