找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 11215|回复: 9
收起左侧

Putty SSH连接树莓派,终端文字没有颜色了

[复制链接]
发表于 2013-2-12 22:20:07 | 显示全部楼层 |阅读模式
出现一个奇怪的问题,先前Putty SSH 小Pi的时候各种文字显示都正常,能够区分颜色。今天重启了下,再登录进去发现文字全变成白色的了……

Putty的设置没有变过,这是什么情况啊?有人遇到过类似情况吗?



搜狗截图_2013-02-12_22-17-37.png
回复

使用道具 举报

发表于 2013-2-13 11:16:17 | 显示全部楼层
修改
  1. ~/.bashrc
复制代码
文件,加入下面的内容,或去掉这些内容前面的“#”号。
  1. export LS_OPTIONS='--color=auto'
  2. eval "`dircolors`"
  3. alias ls='ls $LS_OPTIONS'
  4. alias ll='ls $LS_OPTIONS -l'
  5. alias l='ls $LS_OPTIONS -lA'
复制代码
然后注销,再登录。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-2-13 16:03:22 | 显示全部楼层
本帖最后由 carlrex 于 2013-2-13 16:08 编辑
geekr 发表于 2013-2-13 11:16
修改文件,加入下面的内容,或去掉这些内容前面的“#”号。然后注销,再登录。

谢谢~我照你说的改了下,没有效果,有可能在装Ruby时改了什么东西,我把整个我的整个.bashrc放上来,能帮我看看吗?再次感谢!

补充一下:在Xwindows下的终端显示是正常的。
  1. # ~/.bashrc: executed by bash(1) for non-login shells.
  2. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
  3. # for examples

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

  6. # don't put duplicate lines or lines starting with space in the history.
  7. # See bash(1) for more options
  8. HISTCONTROL=ignoreboth

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

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

  14. # check the window size after each command and, if necessary,

  15. # update the values of LINES and COLUMNS.
  16. shopt -s checkwinsize

  17. # If set, the pattern "**" used in a pathname expansion context will
  18. # match all files and zero or more directories and subdirectories.
  19. #shopt -s globstar

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

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

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

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

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

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

  50. # If this is an xterm set the title to user@host:dir
  51. case "$TERM" in
  52. xterm*|rxvt*)
  53.     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  54.     ;;
  55. *)
  56.     ;;
  57. esac
  58. # enable color support of ls and also add handy aliases
  59. if [ -x /usr/bin/dircolors ]; then
  60.     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dirc$
  61.     alias ls='ls --color=auto'
  62.     #alias dir='dir --color=auto'
  63.     #alias vdir='vdir --color=auto'

  64.     alias grep='grep --color=auto'
  65.     alias fgrep='fgrep --color=auto'
  66.     alias egrep='egrep --color=auto'
  67. fi

  68. # some more ls aliases
  69. #alias ll='ls -l'
  70. #alias la='ls -A'
  71. #alias l='ls -CF'
  72. # Alias definitions.
  73. # You may want to put all your additions into a separate file like
  74. # ~/.bash_aliases, instead of adding them here directly.
  75. # See /usr/share/doc/bash-doc/examples in the bash-doc package.

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

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

  85. PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

  86. export LS_OPTIONS='--color=auto'
  87. eval "`dircolors`"
  88. alias ls='ls $LS_OPTIONS'
  89. alias ll='ls $LS_OPTIONS -l'
  90. alias l='ls $LS_OPTIONS -lA'
复制代码
回复 支持 反对

使用道具 举报

发表于 2013-2-13 19:02:28 | 显示全部楼层
本帖最后由 geekr 于 2013-2-13 19:04 编辑

你已经设置了颜色了啦,82行之前的都是啊!不用加入我给你的那些代码了。是不是Putty没设置啊?!
QQ截图20130213190418.jpg
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-2-13 22:28:12 | 显示全部楼层
geekr 发表于 2013-2-13 19:02
你已经设置了颜色了啦,82行之前的都是啊!不用加入我给你的那些代码了。是不是Putty没设置啊?!

putty设置的没有问题啊,和图上一样……之前是一切正常。昨天按论坛帖子安装SiriProxy,装了Ruby,装完重启后就这样了……这个不知和Ruby有关吗?
回复 支持 反对

使用道具 举报

发表于 2013-2-15 23:28:54 | 显示全部楼层
打env看环境变量
我的是
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01r=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42w=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-2-16 13:11:01 | 显示全部楼层
jocover 发表于 2013-2-15 23:28
打env看环境变量
我的是
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33; ...

我打env看到的环境变量和上面的完全不一样诶……

是PATH=,Term=,SHELL=等东西,请问具体命令是?
回复 支持 反对

使用道具 举报

发表于 2013-2-16 19:18:19 | 显示全部楼层
carlrex 发表于 2013-2-16 13:11
我打env看到的环境变量和上面的完全不一样诶……

是PATH=,Term=,SHELL=等东西,请问具体命令是?
  1. LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd    =40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=0    1;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.    tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz    =01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.d    eb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31    :*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=0    1;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.x    bm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;    35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mk    v=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;3    5:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=0    1;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd    =01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*    .ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00    ;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga    =00;36:*.spx=00;36:*.xspf=00;36:"
  2. export LS_COLORS
复制代码
上面代码添加/etc/profile里去


回复 支持 反对

使用道具 举报

发表于 2013-2-27 17:58:20 | 显示全部楼层
carlrex 发表于 2013-2-13 22:28
putty设置的没有问题啊,和图上一样……之前是一切正常。昨天按论坛帖子安装SiriProxy,装了Ruby,装完重 ...

如果不行,就试试备份你现在的~/.bashrc文件,再建立一个新的~/.bashrc文件,把下面的内容放进去:
  1. alias ls='ls --color=auto'
  2. alias dir='dis --color=auto'
  3. alias vdis='vdir --color=auto'
  4. alias grep='grep --color=auto'
  5. alias fgrep='fgrep --color=auto'
  6. alias egrep='egrep --color=auto'
复制代码
再source一下看行不行:
  1. source ~/.bashrc
复制代码
回复 支持 反对

使用道具 举报

发表于 2014-2-26 16:46:01 | 显示全部楼层
今天碰到一样问题,瞎折腾下好了,不一定能解决你的问题,仅供参考:
看下你/home/pi下面是不是有.bash_profile文件, 如果有打开之,在开头敲入source ~/.bashrc 保存退出
我手动加了.bash_profile文件,发现启动时候不调用.bashrc所有颜色控制代码就不生效了

希望对你有帮助
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则