/terminal-setup

Terminal setup for macOS, Linux, WSL, and Windows

Primary LanguageShellMIT LicenseMIT

Terminal Setup

Terminal setup for zsh in macOS, Ubuntu/Debian, and Windows.

Terminal Demo

Key Features

Auto Installation (Recommended)

  1. To customize your own configs, you can fork this project before running the below installation script

  2. Run the below to setup the terminal automatically:

    sudo curl -fsSL https://raw.githubusercontent.com/saltchang/terminal-setup/HEAD/install.sh | sh -

    It will setup the terminal by the below steps:

    1. Install homebrew, coreutils, python and pipx for macOS
    2. Install fonts: Meslo & Fira Code
    3. Install and setup zsh
    4. Clone this project into $HOME/projects/personal/terminal-setup
    5. Create a soft link from $HOME/.zshrc to the one in this project
    6. Create a soft link from $HOME/.p10k.zsh to the one in this project
    7. Create a soft link from $HOME/.local/terminal-setup/bin to the one in this project
    8. Optionally install pnpm
    9. Optionally install and setup terminal (iTerm2 or Alacritty)
  3. After the installation, restart your terminal or run source $HOME/.zshrc, you should see the new face of the shell

Manual Installation

For Windows, see Windows Section

Setup Your Terminal

Install & Config iTerm (macOS)

  1. Install iTerm2

    brew install --cask iterm2
  2. Download this iTerm Profile

  3. Open your iTerm > Settings > Profiles > Other Actions > Import JSON Profiles > Choose the downloaded profile

  4. After you setup: Other Actions > Set as Default

  5. Restart iTerm

Install Alacritty (macOS, Linux)

  1. Install Alacritty

  2. You can setup the config by copying the Alacritty Config to your ~/.config/alacritty/alacritty.toml or run the install script:

    ./setup-alacritty.sh

    It will create a symbolic link to the config from your ~/.config/alacritty/alacritty.toml

Customize Your Configs

To customize your own configs, you can fork this project before the below steps.

Setup for macOS

Install Homebrew

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

Install coreutils

GNU-coreutils is required for some commands in macOS.

brew install coreutils

Install Python & Pipx

brew install python
brew install pipx

Install Nerd Fonts

Please install at least one of the below fonts for your terminal, Menlo is recommended.

See all Nerd Fonts.

FiraCode

Fira Code is recommended for your editor such as VS Code.

macOS
brew tap homebrew/cask-fonts
brew install --cask font-fira-code
Ubuntu/Debian
sudo apt install fonts-firacode

Clone This Project

It's recommended to put the project under $HOME/projects/personal:

mkdir -p $HOME/projects/personal
cd $HOME/projects/personal

Then clone this project (if you forked it, replace the URL with your own):

  • use SSH

    git clone git@github.com:saltchang/terminal-setup.git
  • use HTTPS

    git clone https://github.com/saltchang/terminal-setup.git

Install zsh

macOS

Since Catalina, macOS will use zsh as the default shell, so you should have zsh built-in in your system

Ubuntu/Debian

sudo apt update && sudo apt -y install zsh

Then restart your terminal

Setup the Shell

To setup the shell, just run the script:

cd terminal-setup

./setup.sh

It will create a soft link from ~/.zshrc to the one in this project, check dotfiles/.zshrc.

Now restart your terminal or run source ~/.zshrc, you should see the new face of the shell.

Customize Your Shell

Run the below command to open your .zshrc:

edit-rc

Or use the shortcut to go to the terminal-setup repo:

go-rc-repo

Then you can start to customize your shell.

Color for powerlevel10k

If you would like to customize the color scheme of powerlevel10k, please see This chart.

Custom Functions and Aliases

This setup includes several custom functions and aliases to improve your productivity. Here's a list of what's available:

Custom Functions

  • cl: Change to a directory and list its contents
  • home: Change to the home directory and display a welcome message
  • gow: Go to the work projects directory
  • gop: Go to the personal projects directory
  • gol: Go to the libraries directory
  • odg: Interactive menu to select and go to different IXT projects
  • select_menu: Interactive menu to select an option from a list
  • update_git: Check for and update Git to the latest version
  • update_terminal_setup: Update the terminal setup itself
  • load-node-version: Automatically use the correct Node.js version based on .tool-versions or .nvmrc files

Custom Aliases

  • edit: Open files in the default editor (set to VSCode)
  • edit-rc: Edit the .zshrc file
  • go-rc-repo: Go to the terminal setup repository
  • edit-ssh: Edit the SSH config file
  • source-rc: Source (reload) the .zshrc file
  • paths: Display all directories in PATH, one per line
  • weather: Show weather information using wttr.in

Git Aliases

  • gclb: Clean local branches (except main and develop)
  • gclmb: Clean merged branches
  • gfap: Fetch all and pull
  • gfapr: Fetch all and pull with rebase
  • gpuoc: Push and set upstream to origin for the current branch

System-specific Aliases

macOS:

  • unu: Update and upgrade Homebrew packages

Linux:

  • unu: Update and upgrade apt packages
  • ffind: Fuzzy find files
  • monitor: Monitor system resources using gotop
  • mand: Analyze disk usage with ncdu (excluding /mnt)

Docker Aliases

  • docker-all: List all Docker containers with details
  • docker-ls: List running Docker containers with details

Other Aliases

  • c: Clear the terminal
  • python: Alias for python3
  • pip: Alias for pip3

Troubleshooting

Font Issues

If you're seeing boxes or question marks instead of special characters in your prompt:

  1. Make sure you've installed the recommended fonts (Meslo or FiraCode).
  2. Ensure your terminal is set to use one of these fonts.
  3. If using iTerm2, go to Settings > Profiles > Text and select the appropriate font.

Node.js Version Switching Issues

If automatic Node.js version switching isn't working:

  1. Make sure asdf is properly installed and configured.
  2. Check if you have a .tool-versions or .nvmrc file in your project directory.
  3. Try running asdf reshim nodejs after installing a new Node.js version.

For any other issues, please open an issue on the GitHub repository.

Windows

Config Windows Terminal

  1. Open your Windows Terminal > Settings > Open JSON file
  2. Copy json configs from this config file
  3. Paste the config to the Windows Terminal config json you just opened
  4. Restart Windows Terminal

Setup PowerShell

See PowerShell Setup

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.