Try   HackMD

【學習筆記】zsh setting change your terminal theme

Ubuntu Setting

  1. Install zsh, and git package

    $sudo apt-get install zsh
    $sudo apt-get install git

  2. Check your current client support shell

    $cat /etc/shells

    Note: It will list down all the shell it support

  3. Check default shell
    $echo $SHELLS or $echo $0
    default is /bin/bash

  4. Install oh-my-zsh
    You can use either wget or curl to download. Default wget is installed, so I will used it instead of curl.

    via curl

    shc"(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

    or

    via wget

    shc"(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

  5. Change your default shell to zsh
    $chsh -s /bin/zsh

  6. Download your theme

  7. cd to home directory and copy the download theme to zsh folder

$cd $sudo mv Downloads/bullet-train.zsh-theme .oh-my-zsh/themes/
  1. edit .zshrc to change your theme

    #change ZSH_THEME to bullet-train
    nano ZSH_THEME = “bullet-train”

  2. restart your terminal or logout

  3. install poweline else font will be strange, especially logo

    $sudo apt-get install powerline
    $sudo apt-get install fonts-powerline

Script automatic ZSH write file

#!/bin/bash #creating zsh terminal echo "installing zsh" apt-get install zsh -y echo "installing git" apt-get install git -y echo "check support shell :" cat /etc/shells echo "check current shell:" echo $SHELL echo "install oh-my-zsh" #curl: #sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" #wget sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" echo "change shell to zsh" chsh -s /bin/zsh #setting theme cd #sudo mv Downloads/bullet-train.zsh-theme .oh-my-zsh/themes/ sudo cp -av bullet-train.zsh-theme .oh-my-zsh/themes/ sed -i -e 's/ZSH_THEME="robbyrussell"/#ZSH_THEME="robbyrussell"\nZSH_THEME="bullet-train"/g' .zshrc #echo 'read -p "please enter your option' #echo '1. setup pxe setting dhcp tftp ' #echo '========================' #read -p "Your Options: " option

Mac Setting

  1. 安裝 Homebrew
    Homebrew 是 Mac OSX 上的的套件管理工具,是方便安裝管理 OSX 裡需要用到但預設沒安裝的套件。

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

  2. install iterm2

    brew install cask iterm2

    • 背景: command + i or iterms>preferences 選colors 或是下面plugin
      iterm color plugin download
      color 選import plugin 上面下載 。選schemes裡面的
    • spit terminal:
      split vertical: ⌘ + D
      horizontal: ⌘ + ⇧+D
      switch terminal: ⌘ + Option+ right left
      max/min terminal:⌘+ shift+ ⏎
    • Word Jumps:
      perference> keys>natural text editing
      add word ex: one two three
      switch word: options right or left move word
    • delete word: delete + backspace
    • command history hint: ⌘ ;
  3. 安裝 ZSH

  • check what shell are are using:

    echo $SHELL

  • install zsh

    brew install zsh

  • set default iterm2 shell to zsh

    csh -s /bin/zsh #method1
    sudo sh -c "echo $(which zsh) >> /etc/shells" #method2
    chsh -s $(which zsh) #method3
    restart itern after setting it

  1. 安裝 oh-my-zsh (iterm plugin)
#via curl sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" # or # via wget sh -c "$(wget -O-https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • Method 2

    git clone git://github.com/robbyrussell/oh-my-zsh.git
    cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
    source ~/.zshrc

  1. download zsh theme
  • makesure you are in home directory cd ~
  • All theme theme description
  • agnoster theme link
    • For Mac users, I highly recommend iTerm 2 + Solarized Dark
  • Powerlevel9k theme
  • Powerlevel10k theme
    • download and install
      ​​​​git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
    • after set theme .zshrc it will ask you question, press

      n
      n
      y
      which style you want?
      1unicode or 2ascii? 1
      show time
      flat or blurred at end?
      same line as heading?
      compact or space
      instant prompt mode? 1
      apply?

  1. open and edit .zshrc to change theme
  • edit .zshrc

    ZSH_THEME="agnoster"
    ZSH_THEME="random" #randome theme
    ZSH_THEME="powerlevel9k/powerlevel9k"
    ZSH_THEME="powerlevel10k/powerlevel10k"

  1. update change

    source ~/.zshrc

  2. install Powerline fonts else not looking rigt
  • Method 1
  • Method 2 : clone github and install
    • got to powerline github and clone
    • install using the script:

      cd fonts
      ./install.sh

  • set iterns perference and change fonts
    perferences>Profile> change font> and select the font you install just now "source code pro for powerline"

其他ohmyzsh外掛或建議 more plugin

  • edit .zshrc for plugin same as theme

    plugins= (osx #type tab will new terminal tab
    websearch
    vscode #vscode
    )

  • Auto Suggestions Plugin

    • download

    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

    • add plugin to ~/.zshrc:

    plugins=(
    git zsh-autosuggestions
    )

    • source ~.zshrc
  • Syntax Highlighting

    • download and install

    brew install zsh-syntax-highlighting

    • open and edit ~/.zshrc:
    • Skip to the end of ~/.zshrc and add below:

    source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

    • source ~.zshrc
    • press cd will list all directory
  • Change the username@hostname

    • edit .zshrc
    • add below bottom of ZSH_THEME or any place

      DEFAULT_USER = `whoami`

  • alias

    • vscode plugin
      • add code in plugin

      plugins= (vscode)

      • open vscode

      >shell #install code command in PATH

      • use code . will open vscode
  • terminal with vscode
    - go to setting or CMD +
    - go to edit setting json

    • for Source Code Pro + Font Awesome: "terminal.integrated.fontFamily": "'SourceCodePro+Powerline+Awesome Regular'". The single quotes are important! Restart VS Code after the config change.
    • for Source Code Pro: "terminal.integrated.fontFamily": "Source Code Pro for Powerline"
    • for Meslo: "terminal.integrated.fontFamily": "Meslo LG M for Powerline"
    • for other fonts you'll need to check the font name in Font Book. You can right click on them on select "Show in Finder" to get the exact name.
  • neofetch (fancy )

  • fzf (history command)

    • fzf github
    • Homebrew to install:

      brew install fzf
      #To install useful key bindings and fuzzy completion:
      $(brew prefix)/opt/fzf/install

    • github install

      git clone depth 1 https://github.com/junegunn/fzf.git ~/.fzf
      ~/.fzf/install
      ask you question: press y

    • key
      • fuzzy find command history: ctrl + R
      • fuzzy find current direcoty: ctrl + T
        • rm with tab
        • ls with tab
        • .css$ : start with css file
      • cd ** or ssh **

reference:

tags: Linux Mac Zsh terminal Tool