Install Z Shell (zsh) Your BEST Shell - spaceshiptrip/raspberrypi GitHub Wiki

Install ZSH

Change default shell in ubuntu

NOTE: without sudo should work. If you use sudo it will change the shell not for your working user but for root

chsh -s $(which zsh)

If that doesn't work:

  1. Open /etc/passwd:
sudo vi /etc/passwd
  1. Find the line with your username:
username:x:1634231:100:Your Name:/home/username:/bin/bash
  1. and replace bash with zsh:
username:x:1634231:100:Your Name:/home/username:/bin/zsh

Using it with auto cd:

https://blog.confirm.ch/zsh-tips-changing-directories/

setopt auto_cd

Installing the best ZSH command tools:

Before installing all of ZSH make sure you download a couple things:

  1. autojump

    • Mac using homebrew: brew install autojump
    • Debian: sudo apt install autojump
  2. Nerd Fonts

  3. Oh My ZSH:

    • cURL:
    sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    
    • wget:
      sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
      
  4. Spaceship prompt

    • Download:

      git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" --depth=1
      
    • Finish sym links:

      ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
      
    • Install VI Mode:

      git clone https://github.com/spaceship-prompt/spaceship-vi-mode.git $ZSH_CUSTOM/plugins/spaceship-vi-mode
      

      Note: For oh-my-zsh users with vi-mode plugin enabled: Add export RPS1="%{$reset_color%}" before source $ZSH/oh-my-zsh.sh in .zshrc to disable default <<< NORMAL mode indicator in right prompt.

    • Add the following to .zshrc:

      ZSH_THEME="spaceship"
      
  5. Set this in the first part of your .zshrc file:

    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    
  6. Set up the ~/.zshrc THIS IS ONLY COMPATIBLE WITH NERD FONTS INSTALLED
    The docker font below that is commented out shows up weird, but you can uncomment and try it out yourself.

    # Prompt
    ZSH_THEME="spaceship"
    SPACESHIP_PROMPT_ADD_NEWLINE="true"
    SPACESHIP_CHAR_PREFIX='\ufbdf '
    SPACESHIP_CHAR_PREFIX_COLOR='yellow'
    SPACESHIP_CHAR_SUFFIX=(" ")
    SPACESHIP_CHAR_COLOR_SUCCESS="yellow"
    SPACESHIP_CHAR_SYMBOL='~'
    SPACESHIP_PROMPT_DEFAULT_PREFIX="$USER"
    SPACESHIP_PROMPT_FIRST_PREFIX_SHOW="true"
    SPACESHIP_VENV_COLOR="magenta"
    SPACESHIP_VENV_PREFIX="("
    SPACESHIP_VENV_SUFFIX=")"
    SPACESHIP_VENV_SYMBOL='\uf985'
    SPACESHIP_USER_SHOW="true"
    # SPACESHIP_DOCKER_SYMBOL='\ue7b0'
    SPACESHIP_DOCKER_VERBOSE='false'
    SPACESHIP_BATTERY_SHOW='always'
    SPACESHIP_BATTERY_SYMBOL_DISCHARGING='\uf57d'
    SPACESHIP_BATTERY_SYMBOL_FULL='\uf583'
    SPACESHIP_BATTERY_SYMBOL_CHARGING='\uf588'
    
  7. Set up the plugins environment:

    plugins=(git zsh-autosuggestions autojump zsh-syntax-highlighting docker npm docker-compose spaceship-vi-mode)
    
    • Make sure to install the plugins autoguggestions and sytax highlighting:
    • Autosuggestions:
      git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
      
    • Syntax Highlighting:
      git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
      
  8. Enable VI mode for SPACESHIP Prompt at the end of the .zshrc file

    spaceship_vi_mode_enable
    
  9. Install dircolors solarized so you can use the dark theme and still see the files

    • Sources: https://github.com/seebi/dircolors-solarized

    • Oh-My-ZSH:

      git clone --recursive https://github.com/joel-porquet/zsh-dircolors-solarized.git $ZSH_CUSTOM/plugins/zsh-dircolors-solarized
      

      Enable plugin in ~/.zshrc:

      plugins=(zsh-dircolors-solarized)
      
  10. Install lsd

    • May not work for some systems because ruby setup is not compatible. Maybe the RPi systems?
    • https://github.com/Peltoche/lsd
    • Mac install through brew: brew install lsd

Integrating Visual Studio Code

  1. Set up the settings.json file: p
  2. Search for the app's settings.json
  3. Add the following:
    • Mac:
      {
         "window.zoomLevel": 1,
         "terminal.external.osxExec": "iTerm.app",
         "terminal.integrated.shell.osx": "/bin/zsh",
         "terminal.integrated.fontFamily": "Hack Nerd Font",
         "terminal.integrated.fontSize": 14
      }
      

Oh-My-ZSH: https://www.seeedstudio.com/blog/2020/03/06/prettify-raspberry-pi-shell-with-oh-my-zsh/


Directions from website above:

Firstly, you have to install zsh to replace bash.

sudo apt-get install zsh
Then set zsh as default shell

chsh -s /bin/zsh 
But by now, the shell terminal still looks not cool. Let’s use oh-my-zsh to prettify it. Firstly, install it from GitHub through wget

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Now restart the terminal you’ll see something different, something much cooler than the original bash shell. You can also switch to other themes according to the official zsh instructions here.

As for me, I’m using the “Agnoster” theme so I can see Git Status. And this is not enough. Let’s make the zsh shell more developer friendly with auto-suggestion and syntax highlights.

Firstly, install the plugins under zsh plugin folder.

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Then add it into your .zshrc file

vim ~/.zshrc
plugins=(git zsh-autosuggestions autojump zsh-syntax-highlighting)
Now restart the terminal and enjoy coding with shell!

Plugins for zsh

  1. https://medium.com/@caulfieldOwen/youre-missing-out-on-a-better-mac-terminal-experience-d73647abf6d7
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"

Symlink spaceship.zsh-theme to your oh-my-zsh custom themes directory:

ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"

Set ZSH_THEME="spaceship" in your .zshrc ‘s “theme” section.

Install the themes:

read the above website and follow the here link listen in thenactual website

use Powerline: https://github.com/spaceshiptrip/powerline


LSD for terminals

works only with nerdfonts https://github.com/Peltoche/lsd/releases

termux setup

https://github.com/Peltoche/lsd/issues/423


#o If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# Prompt
ZSH_THEME="spaceship"
SPACESHIP_PROMPT_ADD_NEWLINE="true"
SPACESHIP_CHAR_PREFIX='\ufbdf '
SPACESHIP_CHAR_PREFIX_COLOR='yellow'
SPACESHIP_CHAR_SUFFIX=(" ")
SPACESHIP_CHAR_COLOR_SUCCESS="yellow"
SPACESHIP_CHAR_SYMBOL='~'
SPACESHIP_PROMPT_DEFAULT_PREFIX="$USER"
SPACESHIP_PROMPT_FIRST_PREFIX_SHOW="true"
SPACESHIP_VENV_COLOR="magenta"
SPACESHIP_VENV_PREFIX="("
SPACESHIP_VENV_SUFFIX=")"
SPACESHIP_VENV_SYMBOL='\uf985'
SPACESHIP_USER_SHOW="true"
SPACESHIP_PACKAGE_SHOW="false"
SPACESHIP_DOCKER_SYMBOL='\ue7b0'
SPACESHIP_DOCKER_VERBOSE='false'
#SPACESHIP_BATTERY_SHOW='always'
SPACESHIP_BATTERY_SHOW='false'
SPACESHIP_BATTERY_SYMBOL_DISCHARGING='\uf57d'
SPACESHIP_BATTERY_SYMBOL_FULL='\uf583'
SPACESHIP_BATTERY_SYMBOL_CHARGING='\uf588'

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled  # disable automatic updates
# zstyle ':omz:update' mode auto      # update automatically without asking
# zstyle ':omz:update' mode reminder  # just remind me to update when it's time

# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git zsh-autosuggestions autojump zsh-syntax-highlighting docker npm docker-compose spaceship-vi-mode zsh-dircolors-solarized)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
#

spaceship_vi_mode_enable
⚠️ **GitHub.com Fallback** ⚠️