A collection of console terminals in serveral operation systems.
👉 Note: Bash (Unix Shell)
👉 Note: WSL 2 on Windows
- Install Zsh, check the previous section.
👉 Using iTerms2. Download its settings.
1# CLI tools for Xcode
2xcode-select -r
3xcode-select —-install
4
5# install hombrew
6/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/master/install.sh>)"
Add to
.zshrc
or .bashrc
1# Project-based Zsh history isolation
2autoload -Uz add-zsh-hook
3function set_project_history() {
4 local gitdir
5 gitdir=$(git rev-parse --show-toplevel 2>/dev/null)
6 if [[ -n "$gitdir" ]]; then
7 local history_dir="$gitdir/.vscode"
8 local history_dir="$gitdir/.cursor"
9 local history_file="$history_dir/.zsh_history"
10 mkdir -p "$history_dir"
11 export HISTFILE="$history_file"
12 [[ -f "$history_file" ]] || touch "$history_file"
13 fc -R "$history_file"
14 else
15 export HISTFILE=~/.zsh_history
16 fi
17}
18
19add-zsh-hook chpwd set_project_history
20set_project_history
21
22autoload -Uz add-zsh-hook
23add-zsh-hook zshexit 'fc -W'
24#---------------------------
👉 Read more WSL 2 on Windows
1# check is installed
2zsh --version
1# install (linux)
2sudo apt install zsh
3
4# install (macos - integrated)
1# make zsh default bash
2chsh -s $(which zsh) # log out & log in
1# check
2echo $SHELL # /bin/zsh or similar
1# install oh-my-zsh
2sh -c "$(curl -fsSL <https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh>)"
After installing plugins, put them in
~/.zshrc
1plugins=(git docker docker-compose zsh-syntax-highlighting dnf npm)
2# for me
3# plugins=(git docker docker-compose npm ruby python emoji)
This is my choice. Source code. More settings can be found here. You need to install oh-my-zsh first!
1git clone <https://github.com/denysdovhan/spaceship-prompt.git> "$ZSH_CUSTOM/themes/spaceship-prompt"
1ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
Set
ZSH_THEME="spaceship"
in your .zshrc
.Install font Source Code Pro:
Powerline font,
1sudo apt-get install fonts-powerline
In terminal, choose the corresponding installed fonts.
Add alias to
~/.zshrc
(search "alias" to find the place to put).The following tip will display the execution time of a command. This can be useful, especially when you execute the same command multiple times and need to know when the last command was executed.
1# Push below in .zshrc
2preexec () {
3 local TIME=`date +"[%H:%M:%S] "`
4 local zero='%([BSUbfksu]|([FK]|){*})'
5 local PROMPTLEN=${#${(S%%)PROMPT//$~zero/}}
6 echo "\033[1A\033[$(($(echo -n $1 | wc -m)+$PROMPTLEN))C $fg[blue]${TIME}$reset_color"
7}
- fzf -- search in terminal. (Use:
fzf
)