setup better env for developer

Table of Contents

Setting up a convenient environment on macOS for developers involves configuring the terminal, installing essential tools, and customizing workflows for efficiency. Here’s a comprehensive guide:

1. Update macOS and Install Xcode Command Line Tools

Ensure your macOS is up-to-date:

sudo softwareupdate --install --all

Install Xcode Command Line Tools (required for compilers like gcc and tools like git):

xcode-select --install

2. Install a Package Manager: Homebrew

Homebrew simplifies installing development tools and software:

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

Update Homebrew and verify installation:

brew update && brew doctor

3. Install Essential Development Tools

Use Homebrew to install essential tools:

brew install git zsh fzf fd bat lsd htop tmux wget curl tree

Recommended tools:
• fzf: Fuzzy finder for searching commands/files.
• bat: A cat alternative with syntax highlighting.
• lsd: A modern ls replacement with icons and colors.
• tmux: Terminal multiplexer for session management.

4. Configure the Terminal

Install iTerm2

Download and install iTerm2 for a better terminal experience: iTerm2

Customize iTerm2:
• Use the Preferences panel to set fonts, colors, and keyboard shortcuts.
• Install a Powerline font for better visual prompts:

brew install --cask font-hack-nerd-font

Set the font in iTerm2: Preferences > Profiles > Text > Change Font.

5. Configure the Shell

macOS uses Zsh as the default shell. Customize it for efficiency.

Install Oh My Zsh

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

Add Plugins

Enable useful plugins in ~/.zshrc by editing the plugins section:

plugins=(git z zsh-autosuggestions zsh-syntax-highlighting fzf)

Install additional plugins:
• zsh-autosuggestions: Suggests commands as you type.

brew install zsh-autosuggestions
•   zsh-syntax-highlighting: Highlights syntax for easier debugging.
brew install zsh-syntax-highlighting

Set a Custom Theme

Use Powerlevel10k for a highly customizable Zsh prompt:

brew install romkatv/powerlevel10k/powerlevel10k
echo 'source /opt/homebrew/opt/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc

Configure it with:

p10k configure

6. Install Development Environments

Programming Languages

Install commonly used languages:
• Python:

brew install python
pip3 install --upgrade pip

•   Node.js:

brew install node

•   Java:

brew install openjdk

Virtual Environments
• For Python:

pip3 install virtualenv

•   For Node.js:

npm install -g n

Version Managers
• For Python (pyenv):

brew install pyenv

•   For Node.js (nvm):

brew install nvm
mkdir ~/.nvm
echo 'export NVM_DIR="$HOME/.nvm"' >>~/.zshrc
echo '[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh"' >>~/.zshrc

7. Set Up Git

Configure Git globally:

git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
git config --global core.editor "code --wait"

Generate SSH keys for GitHub:

ssh-keygen -t ed25519 -C "youremail@example.com"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub

Add the key to your GitHub account.

8. Install a Code Editor

•   Visual Studio Code:

brew install --cask visual-studio-code

Add the code command:

ln -s "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code

9. Install Docker

Install Docker for containerized development:

brew install --cask docker

10. Enhance Navigation and Productivity

•   Aliases:

Add useful aliases to ~/.zshrc:

alias ll='ls -lah'
alias gs='git status'
alias gc='git commit -m'
alias ..='cd ..'
alias ...='cd ../..'

•   Custom Functions:

mkcd() {
mkdir -p "$1" && cd "$1"
}

11. Keep the Environment Updated

Regularly update tools:

brew update && brew upgrade

With these configurations, your macOS environment will be optimized for productivity, development, and convenience.

Comments |0|

Legend *) Required fields are marked
**) You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Category: 似水流年