EC2(Amazon Linux 2)에 zsh를 넣어 테마를 설정할 때의 단계

팁



EC2(Amazon Linux 2)에 zsh를 넣을 때를 위한 메모입니다.
「프로덕션 환경이야!」라고 하는 정보등을 누구라도 알기 쉽게 하기 위해서 zsh의 테마도 설정합니다.
편리하게 하기 위한 설정도 실시합니다.

전제


  • 사용 중인 EC2 인스턴스에 Git이 설치되어 있어야 합니다.
  • 모든 작업은 ssh 연결된 EC2 내에서 수행됩니다.

  • 절차



    흐름


  • zsh 설치
  • zsh 테마 및 설정 변경
  • 로그인시 쉘을 bash → zsh로 변경

  • zsh 설치



    존재하는 쉘 목록을 표시하고 zsh가 없는지 확인하십시오.
    $ cat /etc/shells
    
    # 結果
    /bin/sh
    /bin/bash
    /usr/bin/sh
    /usr/bin/bash
    /bin/tcsh
    /bin/csh
    

    zsh를 설치합니다.
    $ sudo yum install zsh
    

    zsh 테마 변경



    설치한 zsh를 사용한다.
    $ zsh
    

    다음이 나오므로 (0)을 선택한다.
    This is the Z Shell configuration function for new users,
    zsh-newuser-install.
    You are seeing this message because you have no zsh startup files
    (the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
    ~).  This function can help you with a few settings that should
    make your use of the shell easier.
    
    You can:
    
    (q)  Quit and do nothing.  The function will be run again next time.
    
    (0)  Exit, creating the file ~/.zshrc containing just a comment.
         That will prevent this function being run again.
    
    (1)  Continue to the main menu.
    
    --- Type one of the keys in parentheses --- 
    

    홈 디렉토리에 .zshrc가 만들어졌지만 필요 없기 때문에 삭제한다.
    $ rm ~/.zshrc
    

    Prezto를 넣으십시오. zsh를 사용하고 있는 상태에서, 다음의 커멘드를 친다.
    $ git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
    
    $ setopt EXTENDED_GLOB
    for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
      ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
    done
    

    zsh를 다시 시작합니다.
    $ exit
    $ zsh
    


    zsh 테마가 바뀌고 있음을 알 수 있습니다. 이 이미지의 테마는 sorin입니다.prompt -p에서 테마 목록을 참조하고 좋은 테마의 이름을 기억하십시오.

    [참고] 여기서 prompt -p가 나타나지 않으면 설치된 zsh가 오래되었을 수 있습니다.
    prezto issue에는 이런가 있습니다.
    여기에 prompt가 나오지 않아도 큰 문제는 없지만, 신경이 쓰이는 분은 새로운 zsh를 다시 설치하는 것이 좋습니다. 쉘을 바꿀 때는 백업용 세션을 남겨두는 등, 로그인할 수 없게 되지 않도록 신중하게 작업을 합시다.
    $ prompt -p
    


    이번에는, fade 의 red로 한다. 어쩐지 프로덕션 환경 같음이 나와 누구에게나 알기 쉬운 생각이 들었기 때문에.
    홈 디렉토리에 어느새 할 수 있는 .zpreztorc 를 편집한다.
    vi ~/.zpreztorc
    

    테마를 sorin에서 fade red로 변경합니다.

    .zpreztorc
    # before
    # zstyle ':prezto:module:prompt' theme 'sorin'
    
    # after
    zstyle ':prezto:module:prompt' theme 'fade' 'red'
    
    

    보완 및 구문 강조 표시를 활성화합니다.

    .zpreztorc
    zstyle ':prezto:load' pmodule \
      'environment' \
      'terminal' \
      'editor' \
      'history' \
      'directory' \
      'spectrum' \
      'utility' \
      'completion' \
      'syntax-highlighting' \  # 追加
      'autosuggestions' \  # 追加
      'prompt'
    

    저장하고 닫습니다.
    zsh를 다시 시작하면 설정이 활성화되었습니다.
    $ exit
    $ zsh
    

    로그인 시 쉘 변경



    이것으로 zsh의 준비가 완료되었으므로, 로그인시의 쉘을 bash에서 zsh로 변경한다.
    그러나 Amazon Linux 2는 기본적으로 chsh를 사용할 수 없으므로 먼저 설치해야 합니다.
    sudo yum install util-linux-user
    

    chsh를 사용할 수 있게 되었으므로, 쉘을 바꾼다.
    # zshのパスを確認する
    $ cat /etc/shells
    
    $ sudo chsh ec2-user
    
    # フルパスを入力する
    /bin/zsh
    

    참고



    Amazon AWS EC2에서 zsh를 사용해 봅시다.
    너의 터미널은 어색하다.
    【EC2】Amazon Linux2에서 chsh 명령을 사용할 수 있도록 한다

    좋은 웹페이지 즐겨찾기