feat: support tools like diff-so-fancy and delta for pretty diff preview

pull/17/head
kevin zhuang 4 years ago
parent 9353df5552
commit 12765d9b02

@ -10,6 +10,8 @@ Noteble changes are documentated in this file.
- Custom preview ENV (DOTBARE_PREVIEW)
Note: has to be this format `export DOTBARE_PREVIEW='cat {}'`, the `{}` is
used for fzf to subsitute for the filepath.
- Added support for external diff tools like "diff-so-fancy" or "delta"
This is optional, only takes effect if installed and set as `git config core.pager`
## 1.2.0 (01/07/2020)

@ -25,7 +25,8 @@ function get_commit() {
--preview "echo {} \
| awk '{print \$1}' \
| xargs -I __ /usr/bin/git --git-dir=${DOTBARE_DIR} --work-tree=${DOTBARE_TREE} \
show --color=always __" \
show --color=always __ \
| ${DOTBARE_DIFF_PAGER}" \
| awk '{print $1}'
else
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
@ -33,7 +34,8 @@ function get_commit() {
| fzf --no-multi --header="${header}" --preview "echo {} \
| awk '{print \$1}' \
| xargs -I __ /usr/bin/git --git-dir=${DOTBARE_DIR} --work-tree=${DOTBARE_TREE} \
diff --color=always __ ${files[*]}" \
diff --color=always __ ${files[*]} \
| ${DOTBARE_DIFF_PAGER}" \
| awk '{print $1}'
fi
}
@ -146,7 +148,8 @@ function get_modified_file() {
| fzf --header="${header}" --preview "echo {} \
| awk '{sub(\$1 FS,\"\");print \$0}' \
| xargs -I __ /usr/bin/git --git-dir=${DOTBARE_DIR} --work-tree=${DOTBARE_TREE} \
diff HEAD --color=always -- ${DOTBARE_TREE}/__" \
diff HEAD --color=always -- ${DOTBARE_TREE}/__ \
| ${DOTBARE_DIFF_PAGER}" \
| awk -v home="${DOTBARE_TREE}" -v format="${output_format}" '{
if (format == "name") {
$1=""
@ -179,7 +182,8 @@ function get_stash() {
print \$1
}' \
| xargs -I __ /usr/bin/git --git-dir=${DOTBARE_DIR} --work-tree=${DOTBARE_TREE} \
show -p __ --color=always" \
stash show -p __ --color=always \
| ${DOTBARE_DIFF_PAGER}" \
| awk '{
gsub(/:/, "", $1)
print $1

@ -16,6 +16,7 @@ export DOTBARE_DIR="${DOTBARE_DIR:-$HOME/.cfg/}"
export DOTBARE_TREE="${DOTBARE_TREE:-$HOME}"
export DOTBARE_BACKUP="${DOTBARE_BACKUP:-${XDG_DATA_HOME:-$HOME/.local/share}/dotbare}"
export DOTBARE_VERSION="v1.2.0"
export DOTBARE_DIFF_PAGER=$(git config core.pager || echo 'cat')
export EDITOR="${EDITOR:-vim}"
if [[ -z "${DOTBARE_KEY}" ]]; then

Loading…
Cancel
Save