Terminal + ZSH

Anh-Thi Dinh
A collection of console terminals in serveral operation systems.
πŸ‘‰Β Note: Bash (Unix Shell)

Useful shortcuts with texts in the terminal

Only for macOS (Windows/Linux isn’t checked yet)
1Ctrl+A # go to the beginning of line
2Ctrl+E # go to the end of line
3Option+Left # back one word
4Option+Right # forward one word
5Ctrl+U # remove the entire line containing the cursor
6Ctrl+K # delete from cursor to end of line
7Crtl+W # delete a word backward (left of cursor)
8Alt+D # delete a word forward (right of cursor)

Terminals

Windows

Install cmder (drop-down by Ctr + \) and I use this personal setting files.
πŸ‘‰ Note: WSL 2 on Windows

Linux

  • Install Zsh, check the previous section.

MacOS

πŸ‘‰ Using iTerms2. Download its settings.

Remember the last command lines for each project

Zsh

(MacOS) Install Homebrew first.
πŸ‘‰ Read more WSL 2 on Windows

Install Zsh + oh-my-zsh

On MacOS, Zsh is already installed and default.
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
Install oh-my-zsh.

Plugins

Install below plugins (using oh-my-zsh way) first:
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)

spaceship-prompt theme

Install using oh-my-zsh way: check here:
Set ZSH_THEME="spaceship" in your .zshrc.

Fonts

Install font Source Code Pro:
  1. Install wget and fontconfig first using brew
    1. 1brew install wget
      2brew install fontconfig
  1. Follow instruction here (step 1-4). If some folders don't exist, create them!
  1. Install Source Code Pro for Powerline and then
    1. 1fc-cache -f -v
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).

Display execution time below to command

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}

Other plugins

  1. fzf -- search in terminal. (Use: fzf)
Β