MacOS and Linux搭建开发和学习环境
MacOS and Linux 下搭建开发环境如:Python, Scala, Verilog, etc; 学习环境如:LaTex, WPS and other mac handy tools
Ubuntu 22.04 config notes
you have to install wine to install wechat, follow this page to install
wine-wechat.
Then follow this
guide to solve wechat resolution problem.
Typing tools: nvim, tmux and terminal
Nvim: Nvim is advanced-vim, on ubuntu you can use command
to install nvim. Important: make sure the neovim version is \(\ge\) 0.8. <- you can download Neovim source file and extract it, link thesudo apt install neovim
nvim
executable file to/usr/bin
.Tmux: tmux can allow you to manage your terminal windows quickly, you can use command
sudo apt install tmux
to install it. All tmux config is in the file~/.tmux.config
, this link is my config for tmux.Terminal: the Ubuntu default terminal is not true color and has many bug when using tmux. So we have to use a third party terminal. I am using
wezterm
to replace the default ternimal. It's a cross plateform terminal.
You can go to their github page to download it.
Besides, wezterm config is in~/.wezterm.lua
, this website is the config demo for wezterm.Important: I think
alacritty
terminal is more useful that wezterm!!! So I prefer you use alacritty instead of wezterm.
sogou input
Just go to the sogou input website, they provided
detailed installation guide. BUT sogou input works
unstable on my Ubuntu. For example, sogou can't work with
zsh
, wezterm
, etc. You have to make your
default shell to be bash
, if you make your default shell to
be zsh
, sogou input cannot type Chinese!
- WPS一开始不支持搜狗中文输入法,按照wps在Ubuntu下可以中文输入的方法进行修复,主要是:
方法一:在
/usr/bin/wps, /usr/bin/et, /usr/bin/wpp
三个文件一开始添加方法二:直接在环境变量里面配置上述两行代码,就可以在所有的应用里输入中文啦1
2
3
4# sogou input
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
method 3: create a file ~/.xprofile
and add the above 3
codes
Coding Tools
TODO: add installation guide in the future
- C++ and C
- gcc, g++
- make
- gdb
- Chisel:
- JRE
- Mill
- Verilog:
- Verilator
- Python
- Miniconda
- Jupyter
Step by step guide to setup your Macbook for coding and study
[TOC]
Acknowledgement: I used to want write a detailed guide of setting the Mac for coding and study, but I give up. The reason is: I get all the installation guide from Google, and the guide are quite detailed. I don't think it's meaningful to copy their articles here so I just do the following two things:
- give url to the articles which I read when I try to install these tools.
- give my own notes about key steps which are not written by these articles.
Thanks for reading this boring and long article, you can reach me by sending emails to timemeansalot@gmail.com.
Chrome
If you use Safari instead of Chrome, you can skip this part.
- Open your Safari web browser and type Chrome, then you can go to the
main website of chrome. Allow download from this website and you can
download
googlechrome.dmg
under your download folder. - Double click the install file, and you can finnaly install chrome on you MAC.
- if chrome can not show content right:
rm -rf ~/.config/google-chrome/Default/GPUCache
Clashx
I Don't know why I want this app, I don't know what can I do with it, I don't take any responsibility for installing this App and I will not use it
Homebrew
Mac package manager, very useful for installing apps in Mac.
Run the following code in your terminal to install
Homebrew
./bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Run the following two command to add homebrew to your PATH.
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/fujie/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Check if homebrew is ready:
brew --version
Git
- install git: `brew install git
- config git:
cd ~ && mkdir .ssh && cd .ssh
ssh-keygen -t rsa -C 'your email'
- copy the
.pub
key to your github setting - test: `ssh -T git@github.com'
Iterm2
Better terminal than the default terminal in Mac.
- Install command:
brew install --cask iterm2
- follow this
guid to config Iterm2. It will teach the following things:
- installing Oh-my-zsh
- installing powerlevel10K Theme for omz
- installing Nerd-Font
- installing zsh plugins
- config Iterm2 color theme
- optional: you can follow dracula iterm2 theme guide to install the dracula theme for Iterm2
Neovim
It's a better vim tool with a lot of config options.
Make sure you have good internet connection before you want to config nvim, the config below will clone a lot of files from Githb.
- install formatter
prettier
:npm install -g prettier
- install neovim:
brew install neovim
- config neovim
- install
stow
: this is a tool for better manager git repos - clone
.env_config
repo cd .env_config && stow nvim
- install
- install all plugins:
cd ~/.config/nvim/lua/user && nvim plugins.lua
Save the file, nvim will auto install all the plugins. - in nvim, use
TSUpdateSync
to install treesitter plugins. - telescope: this is a fuzzy finder, you have to install ripgrep to
use telescope in nvim:
1
2
3
4# macos
brew install ripgrep
# ubuntu
sudo apt-get install ripgrep - config markdown-preview: markdown-preview can let you see your
markdown file render effect in neovim, make sure you
have
node
andyarn
installed.if you have trouble running yarn install, you may have to reinstall yarn using npm:1
2
3
4
5cd ~/.local/share/nvim/site/pack/packer/start/
git clone https://github.com/iamcco/markdown-preview.nvim.git
cd markdown-preview.nvim
yarn install
yarn build1
2
3sudo apt remove cmdtest
sudo apt remove yarn
sudo npm install -g yarn - install picgo_core: picgo is a picture upload tool to easy upload
your picture to image bed. nvim is configed to support picgo, we need to
install picgo core to support picgo on sysetm, follow this guide to install
picgo_core. the config file ins under
1
2
3npm install picgo -g # install picgo-core
# set uploader
picgo set uploader~/.picgo/config.json
, my config file is showing below:1
2
3
4
5
6
7
8
9
10
11{
"picBed": {
"uploader": "smms",
"current": "smms",
"smms": {
"token": "vPkuQrDtSvj0nXrKgRTQbJqRoxP1msR2",
"backupDomain": "smms.app"
}
},
"picgoPlugins": {}
} - formatter: markdown formatter need to start null-ls LSP, and null-ls
need you to install prettier on you Mac:
brew install prettier
Tmux
It's a terminal manager will allow you to quick manage all your terminals. Follow this guid to config tmux.
- install Tmux:
brew install tmux
- install tpm:
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
- config Tmux:
cd ~/.env_config && stow tmux
`
tools
- unzip:
brew install unzip
Tools which makes Macbook more easy to ues
those tools are open source and easy to get, you can get them by Google or App Store
- drawio: Security-first diagramming for teams
- rectangle: Move and resize windows in macOS using keyboard shortcuts or snap areas
- betterdisplay:Custom Resolutions, XDR/HDR Extra Brightness, Dummy Displays, Brightness Adjustment, Picture in Picture, Display and EDID overrides + more!
- bartender: Bartender is an award-winning app for macOS that superpowers your menu bar, giving you total control over your menu bar items, what's displayed, and when, with menu bar items only showing when you need them.
- TickTick: job management tools to arrange your day, add todo lists
- Typora: Typora gives you a seamless experience as both a reader and a writer. It removes the preview window, mode switcher, syntax symbols of markdown source code, and all other unnecessary distractions. Instead, it provides a real live preview feature to help you concentrate on the content itself.
- scroll reverser: reverse the mouse direction
- xnip: screen shot app, free and useful
- Bob: very handy translation and ocr tool on mac
- 4k video downlaoder: download youtube videos and playlists
- wps: office tool, replace of microsoft office
- Caffeine: prevent your Mac from automatically going to sleep, dimming the screen or starting screen savers.
- picgo: A tool for quickly uploading pictures and getting URL links for pictures. I recommend you to avoid the beta version of picgo, because the file may be damaged.
- latex: LaTeX is not
a stand-alone typesetting program in itself, but document preparation
software that runs on top of Donald E. Knuth's TeX typesetting system.
There are 2 ways which I think is convenient to install LaTeX on Mac:
brew install mactex --cask
- go to mactex
homepage, download the
MacTex.pkg
file, double click it after downloading, the installed is done.
Coding Setup
IDE
- vscode: to enable vim plugin
i,j,k,l
continue move in vscode, type this command in your terminal:defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool true
- idea
Config Python env using Miniconda
- go to miniconda website to download the installer.
- install:
cd ~/Downloads && bash xxx.sh
- config miniconda to use domestic source, following this guide
Config for NodeJS
- install nvm: nvm is nodejs version manager, use
brew install nvm
to install it.
After installation, make sure to add nvm to your PATH variable and source.bashrc
or.zshrc
file - Optional: you may need to change nvm source to China if you
are in China and want to boot up the download speed:
1
2export NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node
export NVM_IOJS_ORG_MIRROR=http://npm.taobao.org/mirrors/iojs - install nodejs:
- search all available nodejs:
nvm ls-remote
- install nodejs:
nvm install 18
, this command will install nodejs 18 on your Mac
- search all available nodejs:
- Optional: config nodejs to use source in China, see the
current source of nodejs:
npm config get registry
type the following command in your terminal:npm config set registry https://registry.npm.taobao.org
- test nodejs by setting up hexo website
1
2
3npm install hexo -g # install hexo
hexo s -g # render the blog page locally
brew install pandoc # optional: if blog render step fail
Config for Verilog
- gtkwave: in order to install gtkwave on MacOS 14 or later
1
2brew install --HEAD randomplum/gtkwave/gtkwave
sudo cpan install Switch - iverilog:
brew install icarus-verilog
- verilator:
brew install verilator
- RISC-V
Toolchain: follow the link to install RISC-V Toolchain to mac is
very easy. The key point is that: if your are using WiFi, it may
fail, you can use your phone's hotpot instead.
1
2
3brew install riscv-tools # install Toolchain
brew test riscv-tools # test installation
which riscv64-unknown-elf-gcc # if this works fine, the Toolchain is ready on your mac - on Ubuntu, go to download
pre-build riscv-tools and extract it. Then add the
bin
folder to yourPATH
Config for Scala and Chisel
install scala on mac:
Don't install scala manually, Don't install scala manually, Don't install scala manually!!!, Skip this step, Skip this step, Skip this step
Because we will use
mill
to manage scala, we don't have to install scala by ourself!!!! DON'T install it by yourself!!!curl -fL https://github.com/VirtusLab/coursier-m1/releases/latest/download/cs-aarch64-apple-darwin.gz | gzip -d > cs && chmod +x cs && (xattr -d com.apple.quarantine cs || true) && ./cs setup
The above command is from this website and it's for Macbook with Apple silicon.
- this will install scala related stuff and sbt(scala build tool)
- however, you still have to install Java Runtime to
run scala, using
brew install openjdk
Test installation:scala -version
😭NOTES: make sure you have correctly setJAVA_HOME
to the right directory, otherwisesbt
ormill
will fail to run. In MacOS, you can use/usr/libexec/java_home
command to show the correctJAVA_HOME
path.
mill: Chisel build tool, faster than sbt, but takes more disk space, using
brew install mill
to install mill.
After installation, you can usemill version
to check if mill is correctly installed. There are many ways to install mill on mac.brew install mill
, this will install the latest version of millsh -c "curl -L https://github.com/com-lihaoyi/mill/releases/download/0.9.8/0.9.8 > /usr/local/bin/mill && chmod +x /usr/local/bin/mill"
, this will install mill version 0.9.8, it's the mill version used by XiangShan group.
follow chisel-bootcamp guide to install jupyter and scala kernel for python.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16# install jupyter
pip3 install --upgrade pip
pip3 install jupyter --ignore-installed
pip3 install jupyterlab
# jupyter backend for Scala
curl -L -o coursier https://git.io/coursier-cli && chmod +x coursier
SCALA_VERSION=2.12.10 ALMOND_VERSION=0.9.1
./coursier bootstrap -r jitpack \
-i user -I user:sh.almond:scala-kernel-api_$SCALA_VERSION:$ALMOND_VERSION \
sh.almond:scala-kernel_$SCALA_VERSION:$ALMOND_VERSION \
--sources --default=true \
-o almond
./almond --install
# after installation, You can delete coursier and almond files if you so desire.