1
0
Fork 0
dotfiles/.config/zsh/.zshrc
2025-11-11 01:41:13 +03:00

208 lines
5.8 KiB
Bash

. ~/.config/zsh/modes.sh
fpath=($HOME/.local/share/completions $fpath)
# ls colors
eval "$(dircolors -b)"
# history
HISTSIZE=10000000
SAVEHIST=10000000
HISTFILE="${HOME}/.cache/zsh_history"
setopt hist_expire_dups_first
setopt hist_ignore_dups
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt hist_find_no_dups
setopt hist_save_no_dups
setopt inc_append_history
# change word-style
autoload -U select-word-style
select-word-style b
# options
setopt auto_pushd
# keybinds
bindkey -e
bindkey '^[[Z' reverse-menu-complete
bindkey "^[[1;3C" forward-word
bindkey "^[[1;5C" forward-word
bindkey "^[[1;3D" backward-word
bindkey "^[[1;5D" backward-word
bindkey "^[[3~" delete-char
bindkey "^[n" backward-word
bindkey "^[m" forward-word
# completions
autoload -Uz compinit
compinit
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}:ma=48;5;8;38;5;15"
# prompt
autoload -U colors && colors
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}wzray%{$fg[green]%}@%{$fg[blue]%}phone %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
# ls aliases
alias ls="/usr/bin/lsd --color=always --icon=always"
alias lsd='/usr/bin/ls'
alias l="ls -lh"
alias la="ls -lah"
alias ll="ls -lh"
alias ltr='ls -lt'
alias lt="ls -ltr"
alias lss='ls -lS'
alias lsr='ls -lSr'
# set bat as help pager
alias -g -- --help='--help 2>&1 | bat --language=help --style=plain --theme Monokai\ Extended'
# useful cd aliases
alias ..="cd ../"
alias ...="cd ../../"
alias ....="cd ../../../"
alias .....="cd ../../../../"
alias ......="cd ../../../../../"
alias .......="cd ../../../../../../"
alias ........="cd ../../../../../../../"
alias .........="cd ../../../../../../../../"
alias ..........="cd ../../../../../../../../../"
alias ...........="cd ../../../../../../../../../../"
alias ............="cd ../../../../../../../../../../../"
alias .............="cd ../../../../../../../../../../../../"
alias ..............="cd ../../../../../../../../../../../../../"
alias ...............="cd ../../../../../../../../../../../../../../"
# aliases
alias sudo='sudo ' # allow aliases with sudo
alias rz='exec zsh'
alias venv='source src_venv'
alias ex='source src_example'
alias pa='source src_add_path'
alias info='pinfo'
alias bat='bat '
alias img='nsxiv'
alias xclip='xclip -selection clipboard'
alias xcp='perl -pe "chomp if eof" | xclip -selection clipboard'
alias rgf='rg --files | rg'
alias wt='watch --color -d -cn 0.1 '
alias .e='set -a && source .env && set +a'
alias vimu='vim -u /dev/null'
alias reswap="sudo bash -c 'echo Working...; swapoff /swapfile && sudo swapon /swapfile'"
alias make="make -j$(nproc)"
alias py='python3'
alias q='qalc'
alias neofetch='fastfetch'
alias open='xdg-open'
alias m.='if mount | grep -q "$(pwd)"; then umount -l .; cd .; else mount .; cd .; fi'
alias rs='stow -R .'
alias sst='ssh -t'
alias rdj='rmdir ./*'
alias qr='qrencode -t ansiutf8'
# function aliases
bl() { brightnessctl set "$1"% > /dev/null; }
nosw() { alacritty --class 'noswallow' -e "$@"; }; compdef _command nosw
vims() { filepath="$(type "$1" | rev | cut -d ' ' -f 1 | rev)"; [ $? -eq 0 ] && vim "${filepath}"; }; compdef _command vims
tl() { tree -C "$@" | bat }; compdef _tree tl
diff() { /usr/bin/diff --color -u "$@" | delta; }; compdef _files di;
# compdef
compdef -a '_git; _git-commit' gdc # todo
compdef '_files -g "*.md"' md
# ansible
alias ap='ansible-playbook'
alias ag='ansible-galaxy'
# git aliases
gl() { git log --decorate "$@" | bat }; compdef '_git; _git-log' gl
gus() { git branch --set-upstream-to="${1:?}/${2:?}" "${2:?}" }; compdef '_git; _git-push' gus
gpo() { git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)" "$@" }
gru() { git remote get-url "${1-origin}" }; compdef '_gor' gru
alias ga="git add"
alias ga.="git add ." # always fatfinger this
alias gb="git branch"
alias gc="git commit"
alias gca="git commit --allow-empty-message --amend --no-edit"
alias gcad='gca --no-gpg-sign'
alias gck="git checkout"
alias gcl="git clone"
alias gcls="git clone --depth=1"
alias gcm="git commit --allow-empty-message -m ''"
alias gcd='git commit --no-gpg-sign'
alias gcmd="git commit --allow-empty-message -m '' --no-gpg-sign"
alias gcn="git clean -nfd"
alias gcn!="git clean -fd"
alias gcp="git cherry-pick"
alias gd="git diff"
alias gds="gd --staged"
alias gf="git fetch"
alias gi="git init"
alias gla="gl --all"
alias gm="git merge"
alias gp="git push"
alias gpu="git pull"
alias gr="git restore"
alias grj="git rebase"
alias grjc="git rebase --continue"
alias grjs="git rebase --cancel"
alias grm="git remote"
alias grs="git restore --staged"
alias grt="git reset"
alias grt!="git reset --hard"
alias gsm='git submodule'
alias grc='git rm --cached'
alias gs="git status"
alias gs.='git status .'
alias gsc="git switch -C"
alias gsh="git show"
alias gsj="git stash"
alias gsp="git stash pop"
alias gt="git tag"
alias gus="git fetch --unshallow"
alias gdj='DELTA_FEATURES="+side-by-side" gd'
alias gdsj='DELTA_FEATURES="+side-by-side" gds'
alias gshj='DELTA_FEATURES="+side-by-side" gsh'
alias gcln='git clean -nxfd'
alias gcln!='git clean -xfd'
alias gct="gc -am 'Add files via upload :trollface:'"
# docker aliases
alias d='docker'
alias dc='docker compose'
alias d!='/usr/bin/docker'
alias dc!='d! compose'
alias di='d image'
alias dj='dc up -d --force-recreate'
alias djb='dj --build'
alias djbl='djb && dl'
alias djl='dj && dl'
alias dk='dc down'
alias dl='dc logs -f'
alias dr='d run --rm -it'
alias drs='dc restart'
alias drsl='dc restart && dl'
alias dv='d volume'
# tmux stuff
tn() { tmux new-session -s "${1-"$(basename "$(pwd)")"}" }
alias ta='tmux a -t'
# ta() { tmux a -t "$1" }; compdef '_tmux; _tmux-attach-session' ta
# disable xon control chars
stty -ixon
# print tasks on startup
_ZSH_TODO_FILE="${HOME}/todo.md"
[ -f "$_ZSH_TODO_FILE" ] && { cat "$_ZSH_TODO_FILE" | grep -v '>.*'; }
unset _ZSH_TODO_FILE