zsh的安装

Oh my zsh.

![Oh My Zsh](https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png)

Install ZSH.

sudo apt install zsh

Install Oh my ZSH.

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# github proxy加速
REMOTE="https://ghfast.top/https://github.com/ohmyzsh/ohmyzsh.git" sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install plugins.

  • autosuggesions plugin

    git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

  • zsh-fast-syntax-highlighting plugin

    git clone --depth 1 https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting

  • zsh-completions plugin

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

  • 合并:

    git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions && \
    git clone --depth 1 https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting && \
    git clone --depth 1 https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions
    # github proxy加速
    git clone --depth 1 https://ghfast.top/https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions && \
    git clone --depth 1 https://ghfast.top/https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting && \
    git clone --depth 1 https://ghfast.top/https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions

Enable plugins by adding them to .zshrc.

  • Open .zshrc

    nvim ~/.zshrc

  • Find the line which says plugins=(git).

  • Replace that line with
    plugins=(git zsh-autosuggestions fast-syntax-highlighting zsh-completions)

  • 主题:

    • agnoster
    • alanpeabody
    • dpoggi
    • fishy
    • gianu
    • jonathan (双行)
    • kafeitu
    • lukerandall
    • maran
    • pygmalion
    • risto
    • headline (双行)
      git clone https://github.com/moarram/headline.git $ZSH_CUSTOM/themes/headline &&\
      ln -s $ZSH_CUSTOM/themes/headline/headline.zsh-theme $ZSH_CUSTOM/themes/headline.zsh-theme
    • powerlevel10k/powerlevel10k (双行)
      git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
    • antares (双行)
      https://github.com/elB4RTO/zsh-themes/tree/master/antares#ohmyzsh
    • 更多见:https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
  • 额外:

    • 常用alias和functions:

      # FUNCTIONS
      function quickpush()
      {
      git add -A && git commit -m "$1" && git push
      }
      function quickcommit()
      {
      git add -A && git commit -m "$1"
      }
       
      pyclean () {
      #find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
      find . | grep -E "(__pycache__|.pytest_cache|\.pyc|\.pyo$)" | xargs rm -rf
      }
      export TERM=xterm-256color
      alias cls='printf "\033c"'
      alias condaon="conda activate"
      alias condaoff="conda deactivate"
      alias dusort="du -hs * | sort -h"
      alias portls="netstat -lntp |grep"
      alias tmux-a='tmux attach 2>/dev/null || tmux new-session'
      tmux() {
          if [[ "$1" == "a" ]]; then
              command tmux attach 2>/dev/null || command tmux new-session
          else
              command tmux "$@"
          fi
      }

References

tmux的安装

apt install tmux

cd && \
git clone https://github.com/gpakosz/.tmux.git && \
ln -s -f .tmux/.tmux.conf && \
cp .tmux/.tmux.conf.local .

其他

  • 修改主机名:hostnamectl set-hostname shanhaiHK,还需要修改/etc/hosts中的旧主机名