Skip to content

Instantly share code, notes, and snippets.

@lengocthuong15
Created September 7, 2021 03:56
Show Gist options
  • Save lengocthuong15/1b46d848fff9798711669ff85f2353dc to your computer and use it in GitHub Desktop.
Save lengocthuong15/1b46d848fff9798711669ff85f2353dc to your computer and use it in GitHub Desktop.
Setup ohmyzsh and all needed plugins for dummies

Setup ohmyzsh and all needed plugins for dummies

Install zsh, ohmyzsh

Install git, wget, curl

$ sudo apt install curl wget git

Install zsh

$ sudo apt install zsh

Install ohmyzsh

$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install plugins: Powerlevel10k, zsh-autosuggestions, zsh-syntax-highlighting

Install zsh-autosuggestions, zsh-syntax-highlighting

$ git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

Open ~/.zshrc, add those plugins to the line plugins

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

Source again to apply

source ~/.zshrc

Fix slow paste

If you have any problem with pasting (slowing) try this solution.

Open ~/.zshrc, adding those lines below the line plugins

...
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl)
...

### Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
  OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
  zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
}

pastefinish() {
  zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish
### Fix slowness of pastes

source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Ref: https://gist.github.com/magicdude4eva/2d4748f8ef3e6bf7b1591964c201c1ab

Install theme: Powerlevel10k

  1. Clone the repo
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
  1. Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc
  2. Source again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment