fzgit (1029B)
1#!/bin/env sh 2HEADER="[ENTER] Print selected [TAB] Toggle selection [ALT-F] View file [ALT-H] Commit log [ALT-L] Commit log (oneline)" 3: "${progname:="${0##*/}"}" 4: "${REPO:=./}" 5 6usage() { 7 cat <<_EOF 8Usage: $progname [options] 9 10Options: 11 -r <repo-dir> Set git repository to this directory 12 -h Show this page 13_EOF 14 exit 0 15} 16 17while getopts "r:h" opt; do 18 case $opt in 19 r) REPO="$OPTARG";; 20 h) usage;; 21 *) usage;; 22 esac 23done 24shift $((OPTIND - 1)) 25 26REPO_TL=$(git -C "$REPO" rev-parse --show-toplevel) || { echo "${REPO} is not a git repo"; exit 1; } 27git -C "$REPO_TL" ls-tree --full-tree -r --name-only HEAD \ 28 | sk --inline-info \ 29 --header="${HEADER}" \ 30 --prompt "File name > " \ 31 --layout=reverse-list \ 32 --preview="git -C \"${REPO_TL}\" show master:{1}" \ 33 --preview-window=up:40% \ 34 -m \ 35 --bind "alt-f:execute[ git -C \"${REPO_TL}\" show master:{} ]" \ 36 --bind "alt-l:execute[ git -C \"${REPO_TL}\" log --oneline -- {} ]" \ 37 --bind "alt-h:execute[ git -C \"${REPO_TL}\" log -p -- {} ]" \ 38 ${1:+--query "$@"} 39