Skip to content

Instantly share code, notes, and snippets.

@petrosp
Forked from numToStr/.zshrc.zinit
Created February 21, 2025 21:20
Show Gist options
  • Select an option

  • Save petrosp/bf4f048f10ce3822fe7ac6ee3772a2d8 to your computer and use it in GitHub Desktop.

Select an option

Save petrosp/bf4f048f10ce3822fe7ac6ee3772a2d8 to your computer and use it in GitHub Desktop.
#!/bin/zsh
### 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/zinit%F{220})…%f"
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
command git clone https://github.com/zdharma/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
### End of Zinit's installer chunk
#####################
# PLUGINS #
#####################
# @source: https://github.com/crivotz/dot_files/blob/master/linux/zplugin/zshrc
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
zinit ice wait"0a" lucid atload"_zsh_autosuggest_start"
zinit light zsh-users/zsh-autosuggestions
zinit ice wait"0b" lucid atload'bindkey "$terminfo[kcuu1]" history-substring-search-up; bindkey "$terminfo[kcud1]" history-substring-search-down'
zinit light zsh-users/zsh-history-substring-search
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
# Find a way to change after syntax is loaded
# FAST_THEME_NAME=spa
# typeset -gA FAST_HIGHLIGHT
# FAST_HIGHLIGHT[git-cmsg-len]=120
zinit ice wait"0c" lucid atinit"typeset -gA FAST_HIGHLIGHT; FAST_HIGHLIGHT[git-cmsg-len]=100; zpcompinit; zpcdreplay"
zinit light zdharma/fast-syntax-highlighting
# TAB COMPLETIONS
zinit ice wait"0b" lucid blockf
zinit light zsh-users/zsh-completions
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 ':fzf-tab:complete:_zlua:*' query-string input
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd -w -w"
zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap
zstyle ':fzf-tab:complete:cd:*' extra-opts --preview=$extract'exa -1 --color=always ${~ctxt[hpre]}$in'
setopt promptsubst
zinit wait lucid for \
OMZL::git.zsh \
OMZL::clipboard.zsh \
OMZL::directories.zsh \
OMZL::grep.zsh \
OMZL::history.zsh \
OMZL::spectrum.zsh \
OMZL::termsupport.zsh \
OMZL::compfix.zsh \
OMZL::correction.zsh \
OMZL::completion.zsh \
OMZL::key-bindings.zsh \
OMZP::git \
OMZP::fzf \
OMZP::docker-compose \
svn atinit'ZSH_TMUX_FIXTERM=true; ZSH_TMUX_AUTOSTART=true; ZSH_TMUX_AUTOCONNECT=true;' \
OMZP::tmux \
as"completion" \
OMZP::docker/_docker
zinit ice from"gh-r" as"program" atload'eval "$(starship init zsh)"'
zinit load starship/starship
zinit ice wait"0c" lucid reset \
atclone"local P=${${(M)OSTYPE:#*darwin*}:+g}
\${P}sed -i \
'/DIR/c\DIR 38;5;63;1' LS_COLORS; \
\${P}dircolors -b LS_COLORS > c.zsh" \
atpull'%atclone' pick"c.zsh" nocompile'!' \
atload'zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS}”'
zinit light trapd00r/LS_COLORS
# A fork of `z' by rupa deadwyler with much improved zsh/bash completion and better results. The data file format and core algorithm are compatible with those of the original.
zinit ice src"z.sh"
zinit light knu/z
#####################
# HISTORY #
#####################
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
HISTSIZE=290000
SAVEHIST=$HISTSIZE
#####################
# SETOPT #
#####################
# set -o emacs
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 vi
#####################
# ENV VARIABLE #
#####################
ZSH_AUTOSUGGEST_MANUAL_REBIND=1 # make prompt faster
DISABLE_MAGIC_FUNCTIONS=true # make pasting into terminal faster
export EDITOR=nvim
export PAGER=bat
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
#####################
# ALIASES #
#####################
alias vim=$EDITOR
alias ..="cd .."
alias ...="cd ..."
alias cat=bat
alias tf=terraform
alias l="exa -abghHlS --git --group-directories-first"
alias myip=ipInternal
alias sysinfo="inxi -Fxxxz"
alias gcd="gco dev"
alias psqlstart="sudo systemctl start postgresql.service"
alias dcupb="docker-compose up --build"
alias h="http"
alias checkup="sudo pamac checkupdates -a"
alias up="pamac upgrade -a --no-confirm"
alias upnup="sudo pacman -Syyuu"
alias cleanup="sudo pacman -Rsn $(pacman -Qdtq)"
alias buildup="pamac build --no-confirm"
alias npmnuke="echo Deleting ^/node_modules/ && rm -rf ./**/node_modules"
alias myip=ipInternal
alias sysinfo="inxi -Fxxxz"
#####################
# FZF SETTINGS #
#####################
FD_OPTIONS="--hidden --follow"
export FZF_DEFAULT_OPTS="--prompt '⯈ ' --marker=+ --color=dark --layout=reverse --color=fg:250,fg+:15,hl:203,hl+:203 --color=info:100,pointer:15,marker:220,spinner:11,header:-1,gutter:-1,prompt:15"
export FZF_DEFAULT_COMMAND="fd --type f --type l $FD_OPTIONS || git ls-files --cached --others --exclude-standard"
export FZF_CTRL_T_COMMAND="fd $FD_OPTIONS"
export FZF_ALT_C_COMMAND="fd --type d $FD_OPTIONS"
export FZF_COMPLETION_OPTS="-x"
_fzf_compgen_path() {
fd --hidden --follow . "$1"
}
_fzf_compgen_dir() {
fd --type d --hidden --follow . "$1"
}
#####################
# GO SETTINGS #
#####################
export CGO_ENABLED=1
export CGO_CFLAGS="-g -O2 -Wno-return-local-addr"
export GOPATH="$HOME/go/"
export PATH="$GOPATH/bin:$PATH"
#####################
# Node and Yarn #
#####################
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin" # Added by n-install (see http://git.io/n-install-repo).
#####################
# Functions #
#####################
function ipInternal() {
# echo "Ethernet :: IP => $( ip -4 -o a show wlan1 | awk '{ print $4 }' )"
echo "Wireless :: IP => $( ip -4 -o a show wlo1 | awk '{ print $4 }' )"
}
function ipExternal() {
echo "External :: IP => $( curl --silent https://ifconfig.me )"
}
function ipinfo() {
ipInternal
ipExternal
}
prcreate() {
gh pr create -B "$1" -f
}
prmerge() {
gh pr merge --merge --delete-branch=false "$1"
}
prlist() {
gh pr list --state open
}
open_with_fzf() {
fd -t f -H -I | fzf -m --preview="xdg-mime query default {}" | xargs -ro -d "\n" xdg-open 2>&-
}
cd_with_fzf() {
cd $HOME && cd "$(fd -t d | fzf --preview="tree -L 1 {}" --bind="space:toggle-preview" --preview-window=:hidden)"
}
pacs() {
sudo pacman -Syy $(pacman -Ssq | fzf -m --preview="pacman -Si {}" --preview-window=:hidden --bind=space:toggle-preview)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment