diff --git a/.zshrc b/.zshrc index 469d76b..51c05e3 100644 --- a/.zshrc +++ b/.zshrc @@ -104,6 +104,9 @@ if [[ -f "$FZF/key-bindings.zsh" ]]; then source "$FZF/key-bindings.zsh" fi +zinit ice wait lucid depth"1" +zinit light wfxr/forgit + zinit ice wait lucid depth"1" atload"zicompinit; zicdreplay" blockf zinit light Aloxaf/fzf-tab @@ -160,100 +163,6 @@ export FZF_CTRL_T_OPTS="--preview '(bat --style=numbers --color=always {} || cat export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview' --exact" export FZF_ALT_C_OPTS="--preview '(eza --tree --icons --level 3 --color=always --group-directories-first {} || tree -NC {} || ls --color=always --group-directories-first {}) 2>/dev/null | head -200'" -# GIT heart FZF -# @see https://junegunn.kr/2016/07/fzf-git/ -is_in_git_repo() { - git rev-parse HEAD > /dev/null 2>&1 -} - -fzf-down() { - fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@" -} - -_gf() { - is_in_git_repo || return - git -c color.status=always status --short | - fzf-down -m --ansi --nth 2..,.. \ - --preview '(git diff --color=always -- {-1} | sed 1,4d; cat {-1})' | - cut -c4- | sed 's/.* -> //' -} - -_gb() { - is_in_git_repo || return - git branch -a --color=always | grep -v '/HEAD\s' | sort | - fzf-down --ansi --multi --tac --preview-window right:70% \ - --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1)' | - sed 's/^..//' | cut -d' ' -f1 | - sed 's#^remotes/##' -} - -_gt() { - is_in_git_repo || return - git tag --sort -version:refname | - fzf-down --multi --preview-window right:70% \ - --preview 'git show --color=always {}' -} - -_gh() { - is_in_git_repo || return - git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always | - fzf-down --ansi --no-sort --reverse --multi --bind 'ctrl-s:toggle-sort' \ - --header 'Press CTRL-S to toggle sort' \ - --preview 'grep -o "[a-f0-9]\{7,\}" <<< {} | xargs git show --color=always' | - grep -o "[a-f0-9]\{7,\}" -} - -_gr() { - is_in_git_repo || return - git remote -v | awk '{print $1 "\t" $2}' | uniq | - fzf-down --tac \ - --preview 'git log --oneline --graph --date=short --pretty="format:%C(auto)%cd %h%d %s" {1}' | - cut -d$'\t' -f1 -} - -_gs() { - is_in_git_repo || return - git stash list | fzf-down --reverse -d: --preview 'git show --color=always {1}' | - cut -d: -f1 -} - -join-lines() { - local item - while read item; do - echo -n "${(q)item} " - done -} - -() { - local c - for c in $@; do - eval "fzf-g$c-widget() { local result=\$(_g$c | join-lines); zle reset-prompt; LBUFFER+=\$result }" - eval "zle -N fzf-g$c-widget" - eval "bindkey '^g^$c' fzf-g$c-widget" - done -} f b t r h s - -# OS bundles -if [[ $OSTYPE == darwin* ]]; then - zinit snippet PZTM::osx - if (( $+commands[brew] )); then - alias bu='brew update; brew upgrade; brew cleanup' - alias bcu='brew cu --all --yes --cleanup' - alias bua='bu; bcu' - fi -elif [[ $OSTYPE == linux* ]]; then - if (( $+commands[apt-get] )); then - zinit snippet OMZP::ubuntu - alias agua='aguu -y && agar -y && aga -y' - alias kclean+='sudo aptitude remove -P "?and(~i~nlinux-(ima|hea),\ - ?not(?or(~n`uname -r | cut -d'\''-'\'' -f-2`,\ - ~nlinux-generic,\ - ~n(linux-(virtual|headers-virtual|headers-generic|image-virtual|image-generic|image-`dpkg --print-architecture`)))))"' - elif (( $+commands[pacman] )); then - zinit snippet OMZP::archlinux - fi -fi - # # Aliases #