mirror of
https://github.com/Matir/skel.git
synced 2026-09-23 05:16:57 -07:00
Compare commits
2 Commits
4f24a0734f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2743349bf6 | ||
|
|
22dd533926 |
@@ -599,6 +599,43 @@ EOF
|
|||||||
go install github.com/fullstorydev/grpcui/cmd/grpcui@latest
|
go install github.com/fullstorydev/grpcui/cmd/grpcui@latest
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
difftastic)
|
||||||
|
if command -v brew >/dev/null 2>&1; then
|
||||||
|
brew install difftastic
|
||||||
|
else
|
||||||
|
makedest_or_die
|
||||||
|
case "$(uname -s)" in
|
||||||
|
Linux)
|
||||||
|
target_os="unknown-linux-gnu"
|
||||||
|
;;
|
||||||
|
Darwin)
|
||||||
|
target_os="apple-darwin"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unsupported OS: $(uname -s)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case "$(uname -m)" in
|
||||||
|
x86_64|amd64)
|
||||||
|
arch="x86_64"
|
||||||
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
arch="aarch64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unsupported architecture: $(uname -m)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
tar_url=$(get_latest_github_release_url "Wilfred/difftastic" "^difft-${arch}-${target_os}\\.tar\\.gz$")
|
||||||
|
if [ -z "${tar_url}" ]; then
|
||||||
|
die "Could not find difftastic release for ${arch}-${target_os}"
|
||||||
|
fi
|
||||||
|
download "${tar_url}" "${TMPDIR}/difftastic.tar.gz"
|
||||||
|
tar zxf "${TMPDIR}/difftastic.tar.gz" -C "${DESTDIR}"
|
||||||
|
chmod +x "${DESTDIR}/difft"
|
||||||
|
add_bin_symlink difft
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown tool: ${TOOL}" >/dev/stderr
|
echo "Unknown tool: ${TOOL}" >/dev/stderr
|
||||||
list_tools
|
list_tools
|
||||||
|
|||||||
49
dotfiles/local/bin/git-diff-smart-pager
Executable file
49
dotfiles/local/bin/git-diff-smart-pager
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Detect installed binaries
|
||||||
|
HAS_DELTA=$(command -v delta 2>/dev/null || true)
|
||||||
|
HAS_DIFFT=$(command -v difft 2>/dev/null || true)
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# MODE 1: GIT_EXTERNAL_DIFF / diff.external
|
||||||
|
# Git passes exactly 7 arguments:
|
||||||
|
# $1: path $2: old-file $3: old-hex $4: old-mode $5: new-file $6: new-hex $7: new-mode
|
||||||
|
# ==============================================================================
|
||||||
|
if [ "$#" -eq 7 ]; then
|
||||||
|
DISPLAY_PATH="$1"
|
||||||
|
OLD_FILE="$2"
|
||||||
|
NEW_FILE="$5"
|
||||||
|
|
||||||
|
# 1. Difftastic installed -> Native AST structural file comparison
|
||||||
|
if [ -n "$HAS_DIFFT" ]; then
|
||||||
|
# Pass file metadata and display path to difft
|
||||||
|
exec difft --display=side-by-side-show-both "$OLD_FILE" "$NEW_FILE"
|
||||||
|
|
||||||
|
# 2. Delta installed (Difftastic missing) -> Standard diff piped into delta
|
||||||
|
elif [ -n "$HAS_DELTA" ]; then
|
||||||
|
diff -u -p --label "a/$DISPLAY_PATH" "$OLD_FILE" --label "b/$DISPLAY_PATH" "$NEW_FILE" | delta
|
||||||
|
|
||||||
|
# 3. Neither installed -> Standard unified diff
|
||||||
|
else
|
||||||
|
diff -u -p --label "a/$DISPLAY_PATH" "$OLD_FILE" --label "b/$DISPLAY_PATH" "$NEW_FILE" || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# MODE 2: GIT_PAGER / core.pager
|
||||||
|
# Invoked as a downstream filter/pager for stdout (stdin contains diff/log output)
|
||||||
|
# ==============================================================================
|
||||||
|
else
|
||||||
|
# 1. Delta installed -> Rich pager for git log, git show, git diff, etc.
|
||||||
|
if [ -n "$HAS_DELTA" ]; then
|
||||||
|
exec delta "$@"
|
||||||
|
|
||||||
|
# 2. Difftastic installed (Delta missing) -> Read unified diff from stdin
|
||||||
|
elif [ -n "$HAS_DIFFT" ]; then
|
||||||
|
exec difft "$@"
|
||||||
|
|
||||||
|
# 3. Neither installed -> Fall back to system pager
|
||||||
|
else
|
||||||
|
exec "${PAGER:-less}" ${LESS:--FRX} "$@"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user