Feature: allow configuring arguments of git ls-files in forgit clean (#481)

This commit is contained in:
sandr01d 2025-12-08 20:24:11 +01:00 committed by GitHub
parent 9167c65714
commit 779b59690f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View file

@ -384,12 +384,13 @@ export FORGIT_LOG_FZF_OPTS='
## other options
| Option | Description | Default |
|-----------------------------|-------------------------------------------|-----------------------------------------------|
| `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 full-screen mode | 10 |
| `FORGIT_DIR_VIEW` | command used to preview directories | `tree` if available, otherwise `find` |
| Option | Description | Default |
|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
| `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 full-screen mode | 10 |
| `FORGIT_DIR_VIEW` | command used to preview directories | `tree` if available, otherwise `find` |
| `FORGIT_CLEAN_LIST_FILES_OPTS` | arguments passed to `git ls-files` together with `--others` to determine which files are shown when invoking `forgit clean` | |
# 📦 Optional dependencies

View file

@ -616,8 +616,10 @@ _forgit_clean_select_files() {
-m -0
$FORGIT_CLEAN_FZF_OPTS
"
_forgit_clean_list_files_opts=()
_forgit_parse_array _forgit_clean_list_files_opts "$FORGIT_CLEAN_LIST_FILES_OPTS"
# Note: Postfix '/' in directory path should be removed. Otherwise the directory itself will not be removed.
_forgit_list_files --others "$@" | FZF_DEFAULT_OPTS="$opts" fzf | sed 's#/$##'
_forgit_list_files --others "${_forgit_clean_list_files_opts[@]}" "$@" | FZF_DEFAULT_OPTS="$opts" fzf | sed 's#/$##'
}
# git clean selector