Post

Terminal Setting

Terminal Setting

Customizing MacOS Terminal

1. Transforming Terminal with Oh My Zsh

What is Oh My Zsh?

Oh My Zsh is an open-source framework that makes your terminal both vibrant and powerful. By using the Zsh shell instead of Bash, you can significantly improve your terminalโ€™s productivity.

Installation Method

Run the following command in your terminal:

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

Theme Configuration

One of Oh My Zshโ€™s biggest advantages is its variety of themes. You can change themes by modifying the .zshrc file:

1
2
3
4
5
# Open ~/.zshrc file
vim ~/.zshrc

# Modify the ZSH_THEME line
ZSH_THEME="agnoster"  # One of the popular themes

2. Terminal Color Customization

Installing iTerm2

Instead of the default terminal app, using iTerm2 provides more customization options.

  1. Download from iTerm2 official website
  2. Install via Homebrew: brew install --cask iterm2
  3. Install Fira code font: brew install font-fira-code
  4. Find desired color preset: Visit [https://iterm2colorschemes.com/] and save the desired color scheme using Save Link As. Color Save
  5. Launch iTerm2 and enter settings. Go to the Color tab and select the saved Dracula+ theme. Color Setting
  6. In the Text tab, set Fira Code font. Text Setting
  7. In the Session tab, check Status bar enabled and drag and drop desired settings in Configure Status Bar. Position is in Appearance. Session Setting Status bar Setting Status bar bottom Setting
  8. In the Window tab, you can change the window title. Window title customize

3. Useful Plugins

  1. zsh-autosuggestions: Autocomplete based on previous commands
  2. zsh-syntax-highlighting: Command syntax highlighting

Plugin Installation Example

1
2
3
4
5
6
# Install plugins via Homebrew
brew install zsh-autosuggestions zsh-syntax-highlighting

# Add the following lines to ~/.zshrc
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

~/.zshrc File Configuration

1
2
3
4
5
6
7
# Replace the device name with your desired name
prompt_context() {
  emojis=("๐ŸฆŠ" "๐Ÿฑ" "๐Ÿถ" "๐Ÿผ" "๐Ÿฏ" "๐Ÿฆ")
  nickname="Hacker"
  RAND_EMOJI_N=$(( $RANDOM % ${#emojis[@]} + 1))
  prompt_segment black default "${nickname} ${emojis[$RAND_EMOJI_N]} "
}

4. Productivity Enhancement Tips

Shortcuts

  • Ctrl + A: Move cursor to line start
  • Ctrl + E: Move cursor to line end
  • Ctrl + R: Search command history
  1. fzf: Fuzzy file finder
  2. bat: A better alternative to the cat command
  3. tldr: Command usage summary tool

๋งฅOS ํ„ฐ๋ฏธ๋„ ๊พธ๋ฏธ๊ธฐ

1. Oh My Zsh๋กœ ํ„ฐ๋ฏธ๋„ ๋ณ€์‹ ํ•˜๊ธฐ

Oh My Zsh๋ž€?

Oh My Zsh๋Š” ํ„ฐ๋ฏธ๋„์„ ํ™”๋ คํ•˜๊ณ  ๊ฐ•๋ ฅํ•˜๊ฒŒ ๋งŒ๋“ค์–ด์ฃผ๋Š” ์˜คํ”ˆ์†Œ์Šค ํ”„๋ ˆ์ž„์›Œํฌ์ž…๋‹ˆ๋‹ค. Bash ๋Œ€์‹  Zsh ์…ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ„ฐ๋ฏธ๋„์˜ ์ƒ์‚ฐ์„ฑ์„ ํฌ๊ฒŒ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์„ค์น˜ ๋ฐฉ๋ฒ•

ํ„ฐ๋ฏธ๋„์—์„œ ๋‹ค์Œ ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”:

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

ํ…Œ๋งˆ ์„ค์ •

Oh My Zsh์˜ ๊ฐ€์žฅ ํฐ ์žฅ์  ์ค‘ ํ•˜๋‚˜๋Š” ๋‹ค์–‘ํ•œ ํ…Œ๋งˆ์ž…๋‹ˆ๋‹ค. .zshrc ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜์—ฌ ํ…Œ๋งˆ๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

1
2
3
4
5
# ~/.zshrc ํŒŒ์ผ ์—ด๊ธฐ
vim ~/.zshrc

# ZSH_THEME ๋ผ์ธ์„ ์ˆ˜์ •
ZSH_THEME="agnoster"  # ์ธ๊ธฐ ์žˆ๋Š” ํ…Œ๋งˆ ์ค‘ ํ•˜๋‚˜

2. ํ„ฐ๋ฏธ๋„ ์ƒ‰์ƒ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•

iTerm2 ์„ค์น˜

๊ธฐ๋ณธ ํ„ฐ๋ฏธ๋„ ์•ฑ ๋Œ€์‹  iTerm2๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋” ๋งŽ์€ ์ปค์Šคํ„ฐ๋งˆ์ด์ง• ์˜ต์…˜์„ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  1. iTerm2 ๊ณต์‹ ์›น์‚ฌ์ดํŠธ์—์„œ ๋‹ค์šด๋กœ๋“œ
  2. Homebrew๋กœ ์„ค์น˜: brew install --cask iterm2
  3. Fira code ํฐํŠธ ์„ค์น˜: brew install font-fira-code
  4. ์›ํ•˜๋Š” ์ปฌ๋Ÿฌ ํ”„๋ฆฌ์…‹ ์ฐพ๊ธฐ: https://iterm2colorschemes.com/ ์›ํ•˜๋Š” ์ปฌ๋Ÿฌ๋ฅผ Save Link As๋กœ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. Color Save
  5. iTerm2๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ์„ค์ •์ฐฝ์— ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค. ์ดํ›„ Color ํƒญ์—์„œ ์ €์žฅํ•œ Dracula+๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค. Color Setting
  6. Text ํƒญ์—์„œ๋Š” Fira Code๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. Text Setting
  7. Session ํƒญ์—์„œ Status bar enabled๋ฅผ ์ฒดํฌํ•˜๊ณ  Configure Status Bar์—์„œ ์›ํ•˜๋Š” ์…‹ํŒ…๋“ค์„ ๋“œ๋ž˜๊ทธ ์•ค ๋“œ๋žํ•ฉ๋‹ˆ๋‹ค. ์œ„์น˜๋Š” Appearance Session Setting Status bar Setting Status bar bottom Setting
  8. Window ํƒญ์—์„œ window title์„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Window title customize

3. ์œ ์šฉํ•œ ํ”Œ๋Ÿฌ๊ทธ์ธ

Zsh ํ”Œ๋Ÿฌ๊ทธ์ธ ์ถ”์ฒœ

  1. zsh-autosuggestions: ๊ณผ๊ฑฐ ๋ช…๋ น์–ด ๊ธฐ๋ฐ˜ ์ž๋™ ์™„์„ฑ
  2. zsh-syntax-highlighting: ๋ช…๋ น์–ด ๋ฌธ๋ฒ• ํ•˜์ด๋ผ์ดํŠธ

ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ค์น˜ ์˜ˆ์‹œ

1
2
3
4
5
6
# Homebrew๋กœ ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ค์น˜
brew install zsh-autosuggestions zsh-syntax-highlighting

# ~/.zshrc์— ๋‹ค์Œ ๋ผ์ธ ์ถ”๊ฐ€
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

~/.zshrc ํŒŒ์ผ ์„ค์ •

1
2
3
4
5
6
7
# ์•ž์˜ ๋””๋ฐ”์ด์Šค ์ด๋ฆ„ ๋Œ€์‹ ์— ์›ํ•˜๋Š” ์ด๋ฆ„์œผ๋กœ ์ง€์ •ํ•˜๊ธฐ.
prompt_context() {
  emojis=("๐ŸฆŠ" "๐Ÿฑ" "๐Ÿถ" "๐Ÿผ" "๐Ÿฏ" "๐Ÿฆ")
  nickname="Hacker"
  RAND_EMOJI_N=$(( $RANDOM % ${#emojis[@]} + 1))
  prompt_segment black default "${nickname} ${emojis[$RAND_EMOJI_N]} "
}

4. ์ƒ์‚ฐ์„ฑ ํ–ฅ์ƒ ํŒ

๋‹จ์ถ•ํ‚ค

  • Ctrl + A: ๋ผ์ธ ์‹œ์ž‘์œผ๋กœ ์ปค์„œ ์ด๋™
  • Ctrl + E: ๋ผ์ธ ๋์œผ๋กœ ์ปค์„œ ์ด๋™
  • Ctrl + R: ๋ช…๋ น์–ด ํžˆ์Šคํ† ๋ฆฌ ๊ฒ€์ƒ‰

์œ ์šฉํ•œ ๋„๊ตฌ ์ถ”์ฒœ

  1. fzf: ํผ์ง€ ํŒŒ์ผ ๊ฒ€์ƒ‰๊ธฐ
  2. bat: cat ๋ช…๋ น์–ด์˜ ๋” ๋‚˜์€ ๋Œ€์•ˆ
  3. tldr: ๋ช…๋ น์–ด ์‚ฌ์šฉ๋ฒ• ์š”์•ฝ ๋„๊ตฌ
This post is licensed under CC BY 4.0 by the author.