Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unreadable zsh shell and backspace not work on zsh shell on Docker

I used the FROM rails:onbuild image

  • You can see the wrong/unreadable encoding here

  • When I type backspace after test, it didn't work, it appended spaces on the shell

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)

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    
like image 370
newBike Avatar asked May 19 '15 08:05

newBike


People also ask

Is zsh a Bourne shell?

ZSH, also called the Z shell, is an extended version of the Bourne Shell (sh), with plenty of new features, and support for plugins and themes. Since it's based on the same shell as Bash, ZSH has many of the same features, and switching over is a breeze.

What is zsh shell?

Zsh is a shell designed for interactive use, although it is also a powerful scripting language. Many of the useful features of bash, ksh, and tcsh were incorporated into zsh; many original features were added. The introductory document details some of the unique features of zsh.

Is zsh slower than bash?

We can start by profiling raw zsh - it's even faster than raw bash. The first step is to figure out exactly what's taking so long - there are a variety of tools to measure performance, but the most useful will be zsh 's native debug tools.


1 Answers

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.

That may be part of the problem.

Also, some terminals implement the iutf8 setting for stty. That tells the terminal driver how to adjust the cursor position for multibyte (UTF-8) characters. You might check to see if stty -a shows -iutf8 (feature disabled), and enable it if it is not, e.g.,

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). 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; xterm can be configured with/without UTF-8. The value for TERM is largely irrelevant, since your shell is likely ignoring it in favor of built-in behavior.

like image 82
Thomas Dickey Avatar answered Nov 01 '22 05:11

Thomas Dickey