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.
- Download from iTerm2 official website
- Install via Homebrew:
brew install --cask iterm2
- Install Fira code font:
brew install font-fira-code
- Find desired color preset: Visit [https://iterm2colorschemes.com/] and save the desired color scheme using Save Link As.
- Launch iTerm2 and enter settings. Go to the Color tab and select the saved Dracula+ theme.
- In the Text tab, set Fira Code font.
- In the Session tab, check Status bar enabled and drag and drop desired settings in Configure Status Bar. Position is in Appearance.
- In the Window tab, you can change the window title.
3. Useful Plugins
Recommended Zsh Plugins
- zsh-autosuggestions: Autocomplete based on previous commands
- 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 startCtrl + E
: Move cursor to line endCtrl + R
: Search command history
Recommended Tools
- fzf: Fuzzy file finder
- bat: A better alternative to the cat command
- 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๋ฅผ ์ฌ์ฉํ๋ฉด ๋ ๋ง์ ์ปค์คํฐ๋ง์ด์ง ์ต์ ์ ์ป์ ์ ์์ต๋๋ค.
- iTerm2 ๊ณต์ ์น์ฌ์ดํธ์์ ๋ค์ด๋ก๋
- Homebrew๋ก ์ค์น:
brew install --cask iterm2
- Fira code ํฐํธ ์ค์น:
brew install font-fira-code
- ์ํ๋ ์ปฌ๋ฌ ํ๋ฆฌ์ ์ฐพ๊ธฐ: https://iterm2colorschemes.com/ ์ํ๋ ์ปฌ๋ฌ๋ฅผ Save Link As๋ก ์ ์ฅํฉ๋๋ค.
- iTerm2๋ฅผ ์คํํ์ฌ ์ค์ ์ฐฝ์ ๋ค์ด๊ฐ๋๋ค. ์ดํ Color ํญ์์ ์ ์ฅํ Dracula+๋ฅผ ์ ํํฉ๋๋ค.
- Text ํญ์์๋ Fira Code๋ฅผ ์ค์ ํฉ๋๋ค.
- Session ํญ์์ Status bar enabled๋ฅผ ์ฒดํฌํ๊ณ Configure Status Bar์์ ์ํ๋ ์ ํ ๋ค์ ๋๋๊ทธ ์ค ๋๋ํฉ๋๋ค. ์์น๋ Appearance
- Window ํญ์์ window title์ ๋ฐ๊ฟ ์ ์์ต๋๋ค.
3. ์ ์ฉํ ํ๋ฌ๊ทธ์ธ
Zsh ํ๋ฌ๊ทธ์ธ ์ถ์ฒ
- zsh-autosuggestions: ๊ณผ๊ฑฐ ๋ช ๋ น์ด ๊ธฐ๋ฐ ์๋ ์์ฑ
- 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
: ๋ช ๋ น์ด ํ์คํ ๋ฆฌ ๊ฒ์
์ ์ฉํ ๋๊ตฌ ์ถ์ฒ
- fzf: ํผ์ง ํ์ผ ๊ฒ์๊ธฐ
- bat: cat ๋ช ๋ น์ด์ ๋ ๋์ ๋์
- tldr: ๋ช ๋ น์ด ์ฌ์ฉ๋ฒ ์์ฝ ๋๊ตฌ