Skip to content

Instantly share code, notes, and snippets.

@BornPsych
Forked from minhanhhere/Instruction.md
Created December 30, 2024 06:39
Show Gist options
  • Select an option

  • Save BornPsych/6c748f9ad2a019ff8afb4a638a76d866 to your computer and use it in GitHub Desktop.

Select an option

Save BornPsych/6c748f9ad2a019ff8afb4a638a76d866 to your computer and use it in GitHub Desktop.
Customise Your Terminal Using Zsh & powerlevel10k

What we will setup

1. ZSH

ZSH, also called the Z shell, is an extended version of the Bourne Shell (sh), with plenty of new features, and support for plugins and themes.

2. oh-my-zsh

This is a framework for zsh

3. Powerlevel 10k

Powerlevel10k is a theme for Zsh. It emphasizes speed, flexibility and out-of-the-box experience.

4. Zsh-syntax-highlighting

This package provides syntax highlighting for the shell zsh. It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors.

5. Zsh-autosuggestions

As you type commands, you will see a completion offered after the cursor in a muted gray color. If you press the → key (forward-char widget) or End (end-of-line widget) with the cursor at the end of the buffer, it will accept the suggestion, replacing the contents of the command line buffer with the suggestion.

6. Git-completion

1. Install ZSH

# ZSH is installed by default in MacOs.
# To make it the default shell run this
chsh -s $(which zsh)

2. Install oh-my-zsh

Follow the instruction here https://ohmyz.sh/ Or use this snippet:

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

3. Install and Cofigure powerlevel10k

i. Fonts

Install the fonts:

https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf

cd ~/Library/Fonts && {
    curl 'https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Regular.ttf' --output 'MesloLGS NF Regular.ttf'
    curl 'https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold.ttf' --output 'MesloLGS NF Bold.ttf'
    curl 'https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Italic.ttf' --output 'MesloLGS NF Italic.ttf'
    curl 'https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold%20Italic.ttf' --output 'MesloLGS NF Bold Italic.ttf'
    cd -; }

Open Terminal → Preferences → Profiles → Text, click Change beside Font and select MesloLGS NF family

ii. Installation

mkdir -p ~/.zsh
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.zsh/powerlevel10k
echo 'source ~/.zsh/powerlevel10k/powerlevel10k.zsh-theme'>>~/.zshrc

iii. Configure

Exit the Terminal. Open it again and follow the wizard to configure the theme. Refer to the new zshrc file for the final configuration.

iv. Custom color

We can change the .p10k.zsh at POWERLEVEL9K_DIR_BACKGROUND:

typeset -g POWERLEVEL9K_DIR_BACKGROUND=5

4. Install Zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
echo 'source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh'>>~/.zshrc

5. Install Zsh-syntax-highlighting

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting
echo 'source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh'>>~/.zshrc

6. Install git-completion

Download this file. Move it to ~/.zsh/. https://github.com/minhanhhere/developer-tools/raw/main/powerlevel10k/git-completion.bash

mkdir -p ~/.zsh && cd ~/.zsh && {
    curl -O 'https://raw.githubusercontent.com/minhanhhere/developer-tools/main/powerlevel10k/git-completion.bash'
    cd -; }

echo "

# Load Git completion
zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
fpath=(~/.zsh \$fpath)
autoload -Uz compinit && compinit
">>~/.zshrc

7. Recommended zshrc

Recommended: Download this and replace with your .zshrc

https://github.com/minhanhhere/developer-tools/raw/main/powerlevel10k/.zshrc

@BornPsych
Copy link
Author

BornPsych commented Dec 30, 2024

for permanent removing the login message in terminal: https://www.youtube.com/watch?v=R_xUKSAS0TU

@BornPsych
Copy link
Author

BornPsych commented Jan 1, 2025

replace with cd - https://github.com/ajeetdsouza/zoxide

https://www.youtube.com/watch?v=aghxkpyRVDY

change in .zsh config

eval "$(zoxide init --cmd cd zsh)"

@BornPsych
Copy link
Author

use this to manage the dotfiles - https://www.youtube.com/watch?v=y6XCebnB9gs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment