简体   繁体   English

无法读取的zsh shell和退格键不适用于Docker上的zsh shell

[英]unreadable zsh shell and backspace not work on zsh shell on Docker

I used the FROM rails:onbuild image 我使用了FROM rails:onbuild图像

  • You can see the wrong/unreadable encoding here 您可以在此处看到错误/不可读的编码

  • When I type backspace after test , it didn't work, it appended spaces on the shell 当我在test之后键入backspace时,它不起作用,它在外壳上附加了空格

Here's the environment variables , 这是环境变量,

any ideas for the bug ? 对这个错误有什么想法吗?

RUBY_MAJOR=2.2
RUBY_VERSION=2.2.2
RUBY_DOWNLOAD_SHA256=5ffc0f317e429e6b29d4a98ac521c3ce65481bfd22a8cf845fa02a7b113d9b44
GEM_HOME=/usr/local/bundle
BUNDLE_APP_CONFIG=/usr/local/bundle
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=en_US.UTF-8
HOME=/root
LOGNAME=root
SHLVL=1
PWD=/associate-app
OLDPWD=/associate-app
ZSH=/root/.oh-my-zsh
PAGER=less
LESS=-R
LSCOLORS=Gxfxcxdxbxegedabagacad
_=/usr/bin/env

DOCEKRFILE (here's my docker file) DOCEKRFILE(这是我的docker文件)

FROM rails:onbuild
RUN apt-get update && apt-get -y upgrade
RUN apt-get -y -qq --force-yes install \
        build-essential \
        tree \
        locales \
        ruby-dev \
        vim \
        vim-scripts \
        git \
        git-flow\
        curl \
        zsh \
        sudo



# Install Zsh
RUN git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh \
      && cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc \
      && chsh -s /bin/zsh

RUN sed -i -E "s/^plugins=\((.*)\)$/plugins=(\1 git git-flow ruby tmux)/" ~/.zshrc


# Make ssh dir
RUN mkdir /root/.ssh/
# Copy over private key, and set permissions
ADD id_rsa /root/.ssh/id_rsa
# Create known_hosts
RUN touch /root/.ssh/known_hosts
# Add bitbuckets key
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts


RUN echo "alias ls='ls --color=auto'" >> /etc/zsh/zshrc && \
    echo "alias ll='ls -halF'" >> /etc/zsh/zshrc && \
    echo "alias ls='ls --color=auto'" >> /etc/profile && \
    echo "alias ll='ls -halF'" >> /etc/zsh/zshrc

# copy GEMFILE
WORKDIR /tmp
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install

RUN mkdir /associate-app
WORKDIR /associate-app
ADD . /associate-app

RUN locale-gen en_US.UTF-8  
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8  
CMD echo 'LC_ALL=en_US.UTF-8' >> ~/.zshrc && \
    echo 'LANG=C.UTF-8' >> ~/.zshrc && \
    echo 'LC_CTYPE=en_US.UTF-8' >> ~/.zshrc && \
CMD ["zsh"]

stty -a 风格

speed 38400 baud; rows 40; columns 164; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke    

Your local settings are inconsistent 您的本地设置不一致

LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=en_US.UTF-8

That is, LANGUAGE is not using UTF-8, while the other settings are doing this. 也就是说, LANGUAGE未使用UTF-8,而其他设置正在执行此操作。

That may be part of the problem. 那可能是问题的一部分。

Also, some terminals implement the iutf8 setting for stty . 此外,一些终端实现iutf8为设置stty That tells the terminal driver how to adjust the cursor position for multibyte (UTF-8) characters. 这就告诉终端驱动程序如何调整多字节(UTF-8)字符的光标位置。 You might check to see if stty -a shows -iutf8 (feature disabled), and enable it if it is not, eg, 您可能会检查stty -a显示-iutf8 (功能已禁用),如果未显示-iutf8启用它,例如,

stty -a
stty iutf8

When the feature is available, the terminal driver knows that it should take into account whether the text uses UTF-8 (and may have multiple bytes per column). 当该功能可用时,终端驱动程序知道应该考虑文本是否使用UTF-8(并且每列可能有多个字节)。 If it does not, it will count each byte as a column, and when erasing the "last" character, may do something like this: 如果没有,它将把每个字节计为一列,并且在擦除“最后一个”字符时,可能会执行以下操作:

backspace space space

producing the effect which is shown above. 产生上面显示的效果。

Finally, it would be nice to know the actual terminal in use. 最后,很高兴知道实际使用的终端 For instance, rxvt does not support UTF-8; 例如,rxvt不支持UTF-8。 xterm can be configured with/without UTF-8. xterm可以配置为带有/不带有UTF-8。 The value for TERM is largely irrelevant, since your shell is likely ignoring it in favor of built-in behavior. TERM的值在很大程度上无关紧要,因为您的外壳可能会忽略它,而采用内置行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM