카테고리 없음

iTerm2 MAC 터미널 커스텀

GaGah 2023. 5. 23. 01:28

MacBook 터미널 커스텀 포스팅을 드디어 하네요!

 

한번 셋팅하면 끝!  이다보니.. 안하다가

이번에 터미널 셋팅을 해야해서 겸사겸사 포스팅도 같이 해봅니다!

 

 

셋팅 완료 후 neofetch 조회 후 결과

 

 

 

🐹 iTerm2 설치

1) iterm2 홈페이지에서 다운로드

 

2) 위에서 다운받은 iTerm2를 열고, 아래의 명령어 실행

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

 

3) zsh 설치

brew install zsh

 

 

🐹 Oh-my-zhs 설치

 

Themes

🙃 A delightful community-driven (with 2,100+ contributors) framework for managing your zsh configuration. Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, pyth...

github.com

 

위 링크를 클릭하면, 터미널의 여러 테마들이 있는데, 원하는 걸 골라서 아래 명령어 실행해주면 됩니다.

// sh -c "$(curl -fsSl 원하는테마추가)
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

 

 

 

🐹 텍스트 색상 변경하기

iterm2 색상

 

Iterm Themes - Color Schemes and Themes for Iterm2

 

iterm2colorschemes.com

 

1) 위 링크에서 확인해보고, 원하는 색상을 골라서 다운해주면 됩니다.

https://raw.githubusercontent.com/mbadolato/iTerm2-Color-Schemes/master/schemes/Tomorrow%20Night.itermcolors

 

2) 다운을 했다면, iTerm > Preferences 

 

3) iTerm > Preferences > Profiles > Colors 에서 다운 받은 iterm themes를 import 해주고 선택해주면 끝!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

🐹 Font 수정하기

iTerm > Preferences > Profiles > Text 에서 원하시는 폰트/사이즈를 맞춰서 수정!

 

🐹 /.zshrc 변경

# 편집기 열기
vi /.zshrc

# ZSH_THEME 변경
ZSH_THEME="agnoster"

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

 

 

 

 

🐹  터미널에 사용자 이름 커스터마이징

먼저 agonster.zsh-theme 를 열어주고요

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

 

JUST DO IT!

## 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
}

 

 

코드 제일 하단에 내려가서 추가

prompt_newline() {
  if [[ -n $CURRENT_BG ]]; then
    echo -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR
%{%k%F{blue}%}$SEGMENT_SEPARATOR"
  else
    echo -n "%{%k%}"
  fi

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

 

 

 

여기부터는 옵션입니닷! (사실 앞에도 옵션이긴 하죠..! ㅎㅎ)

 

🐹 Syntax Highlight 적용

# brew를 통해 설치해줍니다.
brew install zsh-syntax-highlighting

# ~/.zshrc에 들어가서 아래의 코드를 입력해줍니다.
vi ~/.zshrc

source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

예시

 

 

🐹  이름 커스터마이징

prompt_context() {
  # Custom (Random emoji)
  emojis=("👻" "🐙" "🐬" "🦄" "🐣" "🐶" "🐹" "🐳" "🍀" "🌈" "💜" "🚀" "💛" "🌸" "🏅" "🎀" "🍄" "🍇" "⭐")
  RAND_EMOJI_N=$(( $RANDOM % ${#emojis[@]} + 1))
  
  # {gaga} -> 원하시는 닉네임 작성
  prompt_segment black default "{gaga} ${emojis[$RAND_EMOJI_N]} "
}

 

 

 

🐹 상태바 추가하기

 

 

 

📗 참고 문서

https://ooeunz.tistory.com/21

LIST