Allow overriding dir view with a variable

This commit is contained in:
sandroid 2024-04-13 21:21:38 +02:00
parent a5eaff2faa
commit e2b03ea7c0
No known key found for this signature in database
GPG key ID: 91418C9982B8B76E
2 changed files with 3 additions and 5 deletions

View file

@ -335,6 +335,7 @@ export FORGIT_LOG_FZF_OPTS='
| `FORGIT_LOG_FORMAT` | git log format | `%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset` |
| `FORGIT_PREVIEW_CONTEXT` | lines of diff context in preview mode | 3 |
| `FORGIT_FULLSCREEN_CONTEXT` | lines of diff context in fullscreen mode | 10 |
| `FORGIT_DIR_VIEW` | command used to preview directories | `tree` if available, otherwise `find` |
# 📦 Optional dependencies

View file

@ -132,6 +132,7 @@ _forgit_log_format=${FORGIT_LOG_FORMAT:-%C(auto)%h%d %s %C(black)%C(bold)%cr%Cre
_forgit_log_preview_options=("--graph" "--pretty=format:$_forgit_log_format" "--color=always" "--abbrev-commit" "--date=relative")
_forgit_fullscreen_context=${FORGIT_FULLSCREEN_CONTEXT:-10}
_forgit_preview_context=${FORGIT_PREVIEW_CONTEXT:-3}
_forgit_dir_view=${FORGIT_DIR_VIEW:-$(hash tree &> /dev/null && echo 'tree' || echo 'find')}
_forgit_pager() {
local pager
@ -474,11 +475,7 @@ _forgit_clean_preview() {
local path
path=$1
if [[ -d "$path" ]]; then
if hash tree &> /dev/null; then
tree "$path"
else
find "$path"
fi
eval "$_forgit_dir_view \"$path\""
else
git diff --color=always /dev/null "$path" | _forgit_pager diff
fi