dotfiles

Dash Eclipse's dotfiles
git clone git://ezup.dev/dotfiles.git
Log | Files | Refs | README | LICENSE

commit e0cb5605c9fffd6f1fe1911b063555dd3138da69
parent bede317a4a47487c153bc33c2280ba737e2fdeb6
Author: Dash Eclipse <dash@ezup.dev>
Date:   Tue, 13 Oct 2020 02:00:57 +0000

Add fzgit and fxls()

Diffstat:
A.local/bin/fzgit | 39+++++++++++++++++++++++++++++++++++++++
M.zshrc.local | 18++++++++++++++++++
2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/.local/bin/fzgit b/.local/bin/fzgit @@ -0,0 +1,39 @@ +#!/bin/env sh +HEADER="[ENTER] Print selected [TAB] Toggle selection [ALT-F] View file [ALT-H] Commit log [ALT-L] Commit log (oneline)" +: "${progname:="${0##*/}"}" +: "${REPO:=./}" + +usage() { + cat <<_EOF +Usage: $progname [options] + +Options: + -r <repo-dir> Set git repository to this directory + -h Show this page +_EOF + exit 0 +} + +while getopts "r:h" opt; do + case $opt in + r) REPO="$OPTARG";; + h) usage;; + *) usage;; + esac +done +shift $((OPTIND - 1)) + +REPO_TL=$(git -C "$REPO" rev-parse --show-toplevel) || { echo "${REPO} is not a git repo"; exit 1; } +git -C "$REPO_TL" ls-tree --full-tree -r --name-only HEAD \ + | sk --inline-info \ + --header="${HEADER}" \ + --prompt "File name > " \ + --layout=reverse-list \ + --preview="git -C \"${REPO_TL}\" show master:{1}" \ + --preview-window=up:40% \ + -m \ + --bind "alt-f:execute[ git -C \"${REPO_TL}\" show master:{} ]" \ + --bind "alt-l:execute[ git -C \"${REPO_TL}\" log --oneline -- {} ]" \ + --bind "alt-h:execute[ git -C \"${REPO_TL}\" log -p -- {} ]" \ + ${1:+--query "$@"} + diff --git a/.zshrc.local b/.zshrc.local @@ -68,3 +68,21 @@ mat() { fi rm -f /tmp/cw.wav } + +# xbps +#git -C ~/.cache/xlocate.git ls-tree --full-tree -r --name-only HEAD | rev | sed 's/_/ /; s/-/ /' | rev | column -t -R3 | sk --inline-info --layout=reverse-list --preview="git -C \"$HOME/.cache/xlocate.git\" show master:$(echo {1}-{2}_{3})" --preview-window=up:50% -m +fxls() { + local HEADER="[Enter] Print selected [TAB] Toggle selection [ALT-F] View file [ALT-I] Info [ALT+H] Homepage" + local REPO="$HOME/.cache/xlocate.git" + git -C "$REPO" ls-tree --full-tree -r --name-only HEAD | rev | sed 's/_/ /; s/-/ /' | rev | column -t -R3 \ + | sk --inline-info \ + --prompt "pkg > " \ + --layout=reverse-list \ + --preview="git -C \"$REPO\" show master:$(echo {1}-{2}_{3})" \ + --preview-window=up:50% \ + -m \ + --bind "alt-f:execute[ git -C \"$REPO\" show master:$(echo {1}-{2}_{3}) | sk --layout=reverse-list --prompt '{1} > ' ]" \ + --bind "alt-i:execute[ xbps-query -v -R {1} | sk --layout=reverse-list --prompt '{1} > ' ]" \ + --bind 'alt-h:execute-silent[ xdg-open "$(xbps-query -p homepage -R {1})" & ]' \ + ${1:+--query "$@"} +}