상세 컨텐츠

본문 제목

우분투 oh-my-zsh 설치 및 agnoster 설정(multi line, syntax-highlighting, autosuggestion)

TOOLS/TIPS

by koharin 2020. 8. 28. 01:43

본문

728x90
반응형

1. oh-my-zsh 설치

apt install zsh
curl -Lo install.sh https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh

 

2. agnoster 테마 적용

vi ~/.zshrc

ZSH_THEME="agnoster"

기본 테마 설정을 agnoster로 바꾼다.

 

 

3. 쉘에 사용자 이름만 남게 하기

$ vi ~/.zshrc

prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
  fi
}

위와 같이 바뀐다.

 

 

4. 폰트 설정 - powerline

mkdir agnoster_theme
cd agnoster_theme
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
cd ..
rm -rf fonts

폰트 깨짐 해결

 

반응형

5. zsh-syntax-highlighting 설정

brew 패키지 설치

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

$ echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >>~/.bash_profile
$ eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
$ cd ~/.oh-my-zsh/plugins
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

// add line in ~/.zshrc
$ vi ~/.zshrc
$ echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

$ vi ~/.zshrc
plugins=(git zsh-syntax-highlighting)

//apply change 
$ source ~/.zshrc

 

 

6. multiline (prompt newline & cursor)

$ vi ~/.oh-my-zsh/themes/agnoster.zsh-theme

prompt_newline() {
  if [[ -n $CURRENT_BG ]]; then
    echo -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR
%(?.%F{$CURRENT_BG}.%F{red})❯%f"

  else
    echo -n "%{%k%}"
  fi

  echo -n "%{%f%}"
  CURRENT_BG=''
}

## Main prompt
build_prompt() {
  RETVAL=$?
  prompt_status
  prompt_virtualenv
  prompt_aws
  prompt_context
  prompt_dir
  prompt_git
  prompt_bzr
  prompt_hg
  prompt_newline
  prompt_end
}

 

 

7. zsh-autosuggestions

$ cd ~/.oh-my-zsh/plugins
$ git clone https://github.com/zsh-users/zsh-autosuggestions.git
$ echo "source ${(q-)PWD}/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc 

$ vi ~/.zshrc
plugins=(git zsh-syntax-highlighting zsh-autosuggestions)

$ source ~/.zshrc

적용 후:


 

728x90
반응형

관련글 더보기