Install Zinit
bash -c "$(curl --fail --show-error --silent --location https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/install.sh)"
Create a .zshrc
vim ~/.zshrc
Copy the next code to .zshrc file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. | |
# Initialization code that may require console input (password prompts, [y/n] | |
# confirmations, etc.) must go above this block; everything else may go below. | |
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then | |
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" | |
fi | |
### Added by Zinit's installer | |
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then | |
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f" | |
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit" | |
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.zinit/bin" && \ | |
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \ | |
print -P "%F{160}▓▒░ The clone has failed.%f%b" | |
fi | |
source "$HOME/.zinit/bin/zinit.zsh" | |
autoload -Uz _zinit | |
(( ${+_comps} )) && _comps[zinit]=_zinit | |
##################### | |
# PROMPT # | |
##################### | |
zinit ice from"gh-r" as"command" atload'eval "$(starship init zsh)"' | |
zinit load starship/starship | |
# Load a few important annexes, without Turbo | |
# (this is currently required for annexes) | |
zinit light-mode for \ | |
zdharma-continuum/zinit-annex-rust \ | |
zdharma-continuum/zinit-annex-as-monitor \ | |
zdharma-continuum/zinit-annex-patch-dl \ | |
zdharma-continuum/zinit-annex-bin-gem-node | |
### End of Zinit's installer chunk | |
########################## | |
# OMZ Libs and Plugins # | |
########################## | |
# IMPORTANT: | |
# Ohmyzsh plugins and libs are loaded first as some these sets some defaults which are required later on. | |
# Otherwise something will look messed up | |
# ie. some settings help zsh-autosuggestions to clear after tab completion | |
setopt promptsubst | |
# Loading tmux first, to prevent jumps when tmux is loaded after .zshrc | |
# It will only be loaded on first start | |
zinit wait lucid for \ | |
OMZL::clipboard.zsh \ | |
OMZL::compfix.zsh \ | |
OMZL::completion.zsh \ | |
OMZL::correction.zsh \ | |
atload" | |
alias ..='cd ..' | |
alias …='cd ../..' | |
alias ….='cd ../../..' | |
alias …..='cd ../../../..' | |
" \ | |
OMZL::directories.zsh \ | |
OMZL::git.zsh \ | |
OMZL::grep.zsh \ | |
OMZL::history.zsh \ | |
OMZL::key-bindings.zsh \ | |
OMZL::spectrum.zsh \ | |
OMZL::termsupport.zsh \ | |
atload" | |
alias gcd='gco dev' | |
" \ | |
OMZP::git \ | |
atload" | |
alias dcupb='docker-compose up –build' | |
" \ | |
OMZP::docker-compose \ | |
as"completion" \ | |
OMZP::docker/_docker \ | |
djui/alias-tips \ | |
# hlissner/zsh-autopair \ | |
# chriskempson/base16-shell \ | |
##################### | |
# PLUGINS # | |
##################### | |
# @source: https://github.com/crivotz/dot_files/blob/master/linux/zplugin/zshrc | |
# IMPORTANT: | |
# These plugins should be loaded after ohmyzsh plugins | |
zinit wait lucid for \ | |
zsh-users/zsh-history-substring-search \ | |
light-mode atinit"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20" atload"!_zsh_autosuggest_start" \ | |
zsh-users/zsh-autosuggestions \ | |
light-mode atinit"typeset -gA FAST_HIGHLIGHT; FAST_HIGHLIGHT[git-cmsg-len]=100; zpcompinit; zpcdreplay" \ | |
zdharma-continuum/fast-syntax-highlighting \ | |
light-mode blockf atpull'zinit creinstall -q .' \ | |
atinit" | |
zstyle ':completion:*' completer _expand _complete _ignored _approximate | |
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' | |
zstyle ':completion:*' menu select=2 | |
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s' | |
zstyle ':completion:*:descriptions' format '– %d –' | |
zstyle ':completion:*:processes' command 'ps -au$USER' | |
zstyle ':completion:complete:*:options' sort false | |
zstyle ':completion:*:*:*:*:processes' command 'ps -u $USER -o pid,user,comm,cmd -w -w' | |
" \ | |
zsh-users/zsh-completions \ | |
bindmap"^R -> ^H" atinit" | |
zstyle :history-search-multi-word page-size 10 | |
zstyle :history-search-multi-word highlight-color fg=red,bold | |
zstyle :plugin:history-search-multi-word reset-prompt-protect 1 | |
" \ | |
zdharma-continuum/history-search-multi-word \ | |
reset \ | |
atclone"dircolors -b LS_COLORS > clrs.zsh" \ | |
atpull'%atclone' pick"c.zsh" nocompile'!' \ | |
atload'zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS}”' \ | |
trapd00r/LS_COLORS | |
# Load powerlevel10k theme | |
zinit ice depth"1" # git clone depth | |
zinit light romkatv/powerlevel10k | |
# Load pure theme | |
zinit ice pick"async.zsh" src"pure.zsh" # with zsh-async library that's bundled with it. | |
zinit light sindresorhus/pure | |
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh | |
##################### | |
# HISTORY # | |
##################### | |
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history" | |
HISTSIZE=290000 | |
SAVEHIST=$HISTSIZE | |
##################### | |
# SETOPT # | |
##################### | |
# set -o emacs | |
# setopt vi | |
setopt extended_history # record timestamp of command in HISTFILE | |
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE | |
setopt hist_ignore_all_dups # ignore duplicated commands history list | |
setopt hist_ignore_space # ignore commands that start with space | |
setopt hist_verify # show command with history expansion to user before running it | |
setopt inc_append_history # add commands to HISTFILE in order of execution | |
setopt share_history # share command history data | |
setopt always_to_end # cursor moved to the end in full completion | |
setopt hash_list_all # hash everything before completion | |
setopt completealiases # complete alisases | |
setopt always_to_end # when completing from the middle of a word, move the cursor to the end of the word | |
setopt complete_in_word # allow completion from within a word/phrase | |
setopt nocorrect # spelling correction for commands | |
setopt list_ambiguous # complete as much of a completion until it gets ambiguous. | |
setopt nolisttypes | |
setopt listpacked | |
setopt automenu | |
setopt autocd | |
##################### | |
# ENV VARIABLE # | |
##################### | |
ZSH_AUTOSUGGEST_MANUAL_REBIND=1 # make prompt faster | |
DISABLE_MAGIC_FUNCTIONS=true # make pasting into terminal faster | |
export EDITOR=vim | |
export DOCKER_BUILDKIT=1 | |
export COMPOSE_DOCKER_CLI_BUILD=1 | |
export MANPAGER="sh -c 'col -bx | bat -l man -p'" | |
##################### | |
# ALIASES # | |
##################### | |
alias vim=$EDITOR | |
alias tf=terraform | |
alias l="exa -abghHlS –git –group-directories-first" | |
alias ipInternal=ip-internal | |
alias ipExternal=ip-external | |
alias ls='ls -G' | |
alias ll='ls -lG' | |
alias lsd='ls -haltr' | |
# Shell | |
alias reload!='exec "$SHELL" -l' | |
alias MyBook="cd /Volumes/MyBook" | |
# Docker | |
alias dk="docker-compose" | |
alias dkpurge="docker stop $(docker ps -aq) && docker rm $(docker ps -aq) && docker rmi $(docker images -q)" | |
# VSCode | |
alias code="code-insiders"; | |
# Tmux | |
alias stmx="tmux attach -t base || tmux new -s base" | |
# Aliases | |
alias zshrc="vim $HOME/.zshrc" | |
alias zshp="vim $HOME/.zsh_plugins.txt" | |
alias aliax="vim $HOME/.aliases" | |
alias vimx="vim $HOME/.vimrc" | |
alias desk="cd $HOME/Desktop" | |
alias tumx="vim $HOME/.tmux.conf" | |
alias dev="cd $HOME/Development/" | |
alias %dev='_dev_(){~/Volumes/MyBook/"$1".*}; _dev_' | |
# Tmux | |
alias %t='_tmux_(){tmux new -s "$1"}; _tmux_' | |
alias sshrc="vim $HOME/.ssh/config" | |
alias python=/opt/homebrew/bin/python3 | |
#npm | |
alias npmnuke="echo Deleting ^/node_modules/ && rm -rf ./**/node_modules" | |
##################### | |
# Functions # | |
##################### | |
# echo "Ethernet :: IP => $( ip -4 -o a show wlan1 | awk '{ print $4 }' )" | |
ip-internal() echo "Wireless :: IP => $( ipconfig getifaddr en0 )" | |
ip-external() echo "External :: IP => $( curl –silent https://ifconfig.me )" | |
ipinfo() { ipInternal && ipExternal } | |
##################### | |
# Misc Stuff # | |
##################### | |
# typeset -U config_files | |
# config_files=($HOME/.zsh/*.zsh) | |
# 1. Load anything which ends with e.zsh | |
# 2. Load anything except file ending with e.zsh | |
# zinit is-snippet for \ | |
# ${(M)config_files:#*/*e.zsh} \ | |
# ${config_files:#*/*e.zsh} \ | |
zinit is-snippet for \ | |
if"[[ -f $HOME/.localrc ]]" $HOME/.localrc | |
##################### | |
# Exports # | |
##################### | |
# https://blog.josephscott.org/2015/05/18/lscolors/ | |
export LSCOLORS=GxFxCxDxbxegedabagaced |
Before copy, make sure VIM is correctly configured
:set paste
CMD+V
Save the .zshrc file
:wq!
Close iterm2
CMD+Q
Open again iterm2
Follow the instructions on the terminal window, if everything went well you will see something like the next screenshot.
This is how my terminal looks:
Related
- DevTeam
- June 22, 2022
- Uncategorized
- Previous Post
- Next Post