summaryrefslogtreecommitdiff
path: root/config/essentials/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'config/essentials/zsh')
-rw-r--r--config/essentials/zsh/aliases.zsh291
-rw-r--r--config/essentials/zsh/functions.zsh79
-rw-r--r--config/essentials/zsh/variables.zsh27
3 files changed, 397 insertions, 0 deletions
diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh
new file mode 100644
index 0000000..1904c78
--- /dev/null
+++ b/config/essentials/zsh/aliases.zsh
@@ -0,0 +1,291 @@
+#!/bin/zsh
+# s/alias \([^-]\)/alias -g \1
+
+if [ -x /usr/bin/dircolors ]; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ # alias ls='ls -h --color --group-directories-first'
+ #alias dir='dir --color=auto'
+ #alias vdir='vdir --color=auto'
+
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+ alias ip='ip -color=auto'
+fi
+
+alias -g l='ls -l'
+alias -g ll='ls -la'
+alias -g la='ls -aF'
+alias -g lst='ls --tree'
+alias -g lst1='ls --tree -L1'
+alias -g lst2='ls --tree -L2'
+alias -g lst3='ls --tree -L3'
+alias ls.='ls -dl .*'
+alias ls='exa --icons --sort extension --group-directories-first'
+
+alias nv='nvim'
+alias -g vimp="vim -c 'PlugInstall'"
+alias yay='pikaur'
+alias dopac='doas pacman'
+alias orpac='pacman -Qtdq | dopac -Rns - 2> /dev/null || echo "No orphans."'
+alias pacup='dopac -Syu'
+alias pacsi='pacman -Si'
+alias pacss='pacman -Ss'
+alias pacqs='pacman -Qs'
+alias pacql='pacman -Ql'
+alias dopacs='dopac -S'
+#
+#
+# -----------------------------------------------------------
+
+alias grub-update='doas grub-mkconfig -o /boot/grub/grub.cfg'
+
+alias -g xclipp='xclip -selection clipboard -r'
+alias -g xclipo='xclip -o -selection clipboard -r'
+alias -g xclippc='xclip -o -selection primary | xclip -selection clipboard -r'
+alias -g xclipcp='xclip -o -selection clipboard | xclip'
+
+alias -g xrandr-rpgmaker='xrandr --auto --output VGA-1 --mode 1024x768 --left-of HDMI-1 && ~/.fehbg'
+alias -g xrandr-default='xrandr --auto --output VGA-1 --mode 1920x1080 --left-of HDMI-1 --output HDMI-1 --mode 1920x1080 && ~/.fehbg'
+
+alias mv='mv -i'
+alias df='df -h'
+alias -g dud='du -d 1 -h | sort -h'
+alias -g d='du --max-depth=0 -h'
+alias df='df -h'
+alias shred='shred -uz'
+alias lsblk='lsblk -o name,type,fsused,size,fstype,label,mountpoint'
+alias -g floc='doas find / -type "f" 2> /dev/null | grep'
+alias -g dloc='doas find / -type "d" 2> /dev/null | grep'
+alias lsblk='lsblk -o name,type,fsused,size,fstype,label,mountpoint'
+alias -g fif='find . -type "f" | grep'
+alias -g fid='find . -type "d" | grep'
+alias scr='nv "${vimf:=/tmp/$(uuidgen)}" ; rm -f "$vimf"'
+alias vidlen='ffprobe -show_entries format=duration -v quiet -of csv="p=0" -i'
+alias whatsmyip='curl "ifconfig.me"'
+alias icognito='unset HISTFILE'
+alias penv='python -m venv'
+alias ytclipo='yt-dlp "$(xclip -sel c -o)"'
+
+alias -g '...'='../..'
+alias -g '....'='../../..'
+alias -g bg='&; disown'
+alias -g cx='chmod +x'
+alias -g ch='chown ${USER}:${USER} -R'
+alias -g hl='--help |& less -r'
+alias -g pi='ping archlinux.org -c4'
+alias -g sba='source bin/activate'
+alias -g smc='systemctl'
+alias -g smcu='systemctl --user'
+alias -g sr='source ~/.zshrc && rehash'
+alias -g wf='doas wipefs -a'
+
+# quick config
+alias -g ez='$EDITOR ~/.zshrc'
+alias -g eza='$EDITOR ~/.config/zsh/aliases.zsh'
+alias -g eto='$EDITOR ~/sync/TODO'
+
+alias -g ff='`fzffile`'
+alias -g fd='`fzfdir`'
+alias -g fdf='`fzfdirfile`'
+
+alias -s conf="$EDITOR"
+alias -s txt="$EDITOR"
+alias -s c="$EDITOR"
+alias -s z80="$EDITOR"
+alias -s zip='unzip -l'
+alias -s tar='tar tf'
+
+# oh-my-zsh git aliases
+alias g='git'
+
+alias ga='git add'
+alias gaa='git add --all'
+alias gapa='git add --patch'
+alias gau='git add --update'
+alias gav='git add --verbose'
+alias gap='git apply'
+alias gapt='git apply --3way'
+
+alias gb='git branch'
+alias gba='git branch --all'
+alias gbd='git branch --delete'
+alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null'
+alias gbD='git branch --delete --force'
+alias gbl='git blame -b -w'
+alias gbnm='git branch --no-merged'
+alias gbr='git branch --remote'
+alias gbs='git bisect'
+alias gbsb='git bisect bad'
+alias gbsg='git bisect good'
+alias gbsr='git bisect reset'
+alias gbss='git bisect start'
+
+alias gc='git commit --verbose'
+alias gc!='git commit --verbose --amend'
+alias gcn!='git commit --verbose --no-edit --amend'
+alias gca='git commit --verbose --all'
+alias gca!='git commit --verbose --all --amend'
+alias gcan!='git commit --verbose --all --no-edit --amend'
+alias gcans!='git commit --verbose --all --signoff --no-edit --amend'
+alias gcam='git commit --all --message'
+alias gcsm='git commit --signoff --message'
+alias gcas='git commit --all --signoff'
+alias gcasm='git commit --all --signoff --message'
+alias gcb='git checkout -b'
+alias gcf='git config --list'
+
+alias gcl='git clone --recurse-submodules'
+alias gclean='git clean --interactive -d'
+alias gpristine='git reset --hard && git clean --force -dx'
+alias gcm='git checkout $(git_main_branch)'
+alias gcd='git checkout $(git_develop_branch)'
+alias gcmsg='git commit --message'
+alias gco='git checkout'
+alias gcor='git checkout --recurse-submodules'
+alias gcount='git shortlog --summary --numbered'
+alias gcp='git cherry-pick'
+alias gcpa='git cherry-pick --abort'
+alias gcpc='git cherry-pick --continue'
+alias gcs='git commit --gpg-sign'
+alias gcss='git commit --gpg-sign --signoff'
+alias gcssm='git commit --gpg-sign --signoff --message'
+
+alias gd='git diff'
+alias gdca='git diff --cached'
+alias gdcw='git diff --cached --word-diff'
+alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
+alias gds='git diff --staged'
+alias gdt='git diff-tree --no-commit-id --name-only -r'
+alias gdup='git diff @{upstream}'
+alias gdw='git diff --word-diff'
+
+alias ggpur='ggu'
+alias ggpull='git pull origin "$(git_current_branch)"'
+alias ggpush='git push origin "$(git_current_branch)"'
+
+alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
+alias gpsup='git push --set-upstream origin $(git_current_branch)'
+
+alias ghh='git help'
+
+alias gignore='git update-index --assume-unchanged'
+alias gignored='git ls-files -v | grep "^[[:lower:]]"'
+alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
+
+alias gk='\gitk --all --branches &!'
+alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
+
+alias gl='git pull'
+alias glg='git log --stat'
+alias glgp='git log --stat --patch'
+alias glgg='git log --graph'
+alias glgga='git log --graph --decorate --all'
+alias glgm='git log --graph --max-count=10'
+alias glo='git log --oneline --decorate'
+alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'"
+alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat"
+alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
+alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
+alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all"
+alias glog='git log --oneline --decorate --graph'
+alias gloga='git log --oneline --decorate --graph --all'
+alias glp="_git_log_prettily"
+
+alias gm='git merge'
+alias gmom='git merge origin/$(git_main_branch)'
+alias gmtl='git mergetool --no-prompt'
+alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
+alias gmum='git merge upstream/$(git_main_branch)'
+alias gma='git merge --abort'
+
+alias gp='git push'
+alias gpd='git push --dry-run'
+alias gpf='git push --force-with-lease'
+alias gpf!='git push --force'
+alias gpoat='git push origin --all && git push origin --tags'
+alias gpr='git pull --rebase'
+alias gpu='git push upstream'
+alias gpv='git push --verbose'
+
+alias gr='git remote'
+alias gra='git remote add'
+alias grb='git rebase'
+alias grba='git rebase --abort'
+alias grbc='git rebase --continue'
+alias grbd='git rebase $(git_develop_branch)'
+alias grbi='git rebase --interactive'
+alias grbm='git rebase $(git_main_branch)'
+alias grbom='git rebase origin/$(git_main_branch)'
+alias grbo='git rebase --onto'
+alias grbs='git rebase --skip'
+alias grev='git revert'
+alias grh='git reset'
+alias grhh='git reset --hard'
+alias groh='git reset origin/$(git_current_branch) --hard'
+alias grm='git rm'
+alias grmc='git rm --cached'
+alias grmv='git remote rename'
+alias grrm='git remote remove'
+alias grs='git restore'
+alias grset='git remote set-url'
+alias grss='git restore --source'
+alias grst='git restore --staged'
+alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
+alias gru='git reset --'
+alias grup='git remote update'
+alias grv='git remote --verbose'
+
+alias gsb='git status --short --branch'
+alias gsd='git svn dcommit'
+alias gsh='git show'
+alias gsi='git submodule init'
+alias gsps='git show --pretty=short --show-signature'
+alias gsr='git svn rebase'
+alias gss='git status --short'
+alias gst='git status'
+
+alias gsta='git stash push'
+alias gstaa='git stash apply'
+alias gstc='git stash clear'
+alias gstd='git stash drop'
+alias gstl='git stash list'
+alias gstp='git stash pop'
+alias gsts='git stash show --text'
+alias gstu='gsta --include-untracked'
+alias gstall='git stash --all'
+alias gsu='git submodule update'
+alias gsw='git switch'
+alias gswc='git switch --create'
+alias gswm='git switch $(git_main_branch)'
+alias gswd='git switch $(git_develop_branch)'
+
+alias gts='git tag --sign'
+alias gtv='git tag | sort -V'
+alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl'
+
+alias gunignore='git update-index --no-assume-unchanged'
+alias gunwip='git log --max-count=1 | grep -q -c "\--wip--" && git reset HEAD~1'
+alias gup='git pull --rebase'
+alias gupv='git pull --rebase --verbose'
+alias gupa='git pull --rebase --autostash'
+alias gupav='git pull --rebase --autostash --verbose'
+alias gupom='git pull --rebase origin $(git_main_branch)'
+alias gupomi='git pull --rebase=interactive origin $(git_main_branch)'
+alias glum='git pull upstream $(git_main_branch)'
+alias gluc='git pull upstream $(git_current_branch)'
+
+alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
+alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
+
+alias gwt='git worktree'
+alias gwta='git worktree add'
+alias gwtls='git worktree list'
+alias gwtmv='git worktree move'
+alias gwtrm='git worktree remove'
+
+alias gam='git am'
+alias gamc='git am --continue'
+alias gams='git am --skip'
+alias gama='git am --abort'
+alias gamscp='git am --show-current-patch'
diff --git a/config/essentials/zsh/functions.zsh b/config/essentials/zsh/functions.zsh
new file mode 100644
index 0000000..a73ea15
--- /dev/null
+++ b/config/essentials/zsh/functions.zsh
@@ -0,0 +1,79 @@
+#!/bin/zsh
+
+vmp() {
+ col -b | \
+ vim -MR \
+ -c 'set ft=man nolist nonu nornu'
+}
+vimh() { vim -c "help $1" -c 'call feedkeys("\<c-w>o")' }
+
+nnn() { test -z "$NNNLVL" && /usr/bin/nnn "$@" || exit }
+ranger() { test -z "$RANGER_LEVEL" && /usr/bin/ranger "$@" || exit }
+
+# googoo
+o ()
+{
+ f="$(fzffile $1)"
+ test "$#" -gt 0 && shift
+ test -n "$f" && $EDITOR $@ "$f"
+}
+go ()
+{
+ d="$(fzfdir $1)"
+ test -d "$d" && cd "$d"
+}
+ogo ()
+{
+ d="$(fzfdirfile $1)"
+ test -d "$d" && cd "$d"
+}
+
+ipc ()
+{
+ if [[ "$(ip link show eno1 | awk -F, 'NR=1 {print $3}')" == "UP" ]]
+ then
+ doas ip link set eno1 down
+ else
+ doas ip link set eno1 up
+ fi
+}
+
+calc () { echo "$@" | bc -l }
+
+unique () {
+ f="/tmp/$(uuidgen)"
+ awk '!x[$0]++' "$1" > "$f"
+ mv "$f" "$1"
+}
+
+clip () { echo -n "$@" | xclip -selection clipboard -rmlastnl }
+
+fzh () {
+ choice="$(tac $HOME/.config/zsh/histfile | fzf)"
+ test -z "${choice}" && return
+ echo "${choice}" >> "${HOME}/.config/zsh/histfile"
+ eval "${choice}"
+}
+
+unzipp () {
+ file=$1
+ shift
+ unzip $file $@ || exit 1
+ rm $file
+}
+
+# fix long waiting time
+__git_files () {
+ _wanted files expl 'local files' _files
+}
+
+# allows changing to parent dir of file
+function cd () {
+ if (( ${#argv} == 1 )) && [[ -f ${1} ]]; then
+ [[ ! -e ${1:h} ]] && return 1
+ print "Correcting ${1} to ${1:h}"
+ builtin cd ${1:h}
+ else
+ builtin cd "$@"
+ fi
+}
diff --git a/config/essentials/zsh/variables.zsh b/config/essentials/zsh/variables.zsh
new file mode 100644
index 0000000..fd8099a
--- /dev/null
+++ b/config/essentials/zsh/variables.zsh
@@ -0,0 +1,27 @@
+#!/bin/zsh
+# VARIABLES
+export ZOT="${HOME}/zot"
+
+export EDITOR="nvim"
+export VISUAL="nvim"
+
+# colored GCC warnings and errors
+export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+
+# Prevent ranger from loading config twice
+export RANGER_LOAD_DEFAULT_RC=FALSE
+
+# Color of zsh-suggestion
+export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10'
+export STARSHIP_CONFIG="${HOME}/.config/starship/starship.toml"
+export FUNCNEST=10000
+export fpath=($HOME/.config/zsh/completion/ $fpath)
+
+# Config files from .config
+export XINITRC="$HOME/.config/x11/xinitrc"
+export GNUPGHOME="$HOME/.config/gnupg"
+export GTK2_RC_FILES="$HOME/.config/gtk-2.0/gtkrc-2.0"
+# export VIMINIT="source ~/.config/vim/vimrc"
+
+export PASSWORD_STORE_CLIP_TIME=5
+export DISPLAY=:0