Skip to content

Commit 392f0f3

Browse files
committed
Add fzf version check
We have a requirement for the fzf version now. The minimum required fzf version is currently 0.49.0. If the installed version is lower, forgit will exit with an error message.
1 parent 39ee4fe commit 392f0f3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ It's **lightweight** and **easy to use**.
2929

3030
# 📥 Installation
3131

32-
*Make sure you have [`fzf`](https://github.com/junegunn/fzf) installed.*
32+
## Requirements
33+
34+
- [`fzf`](https://github.com/junegunn/fzf) version `0.49.0` or higher
35+
36+
If your OS package manager bundles an older version of `fzf`, you might install it using [`fzf`'s own install script'](https://github.com/junegunn/fzf?tab=readme-ov-file#using-git).
37+
38+
## Shell package managers
3339

3440
``` zsh
3541
# for zplug

bin/git-forgit

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212
# This gives users the choice to set aliases inside of their git config instead
1313
# of their shell config if they prefer.
1414

15+
# Check if fzf is installed
16+
installed_fzf_version=$(fzf --version 2>/dev/null | awk '{print $1}')
17+
if [[ -z "$installed_fzf_version" ]]; then
18+
echo "fzf is not installed. Please install fzf first."
19+
exit 1
20+
fi
21+
22+
# Check fzf version
23+
required_fzf_version="0.49.0"
24+
higher_fzf_version=$(printf '%s\n' "$required_fzf_version" "$installed_fzf_version" | sort -V | head -n1)
25+
if [[ "$higher_fzf_version" != "$required_fzf_version" ]]; then
26+
echo "fzf version $required_fzf_version or higher is required. You have $installed_fzf_version."
27+
exit 1
28+
fi
29+
1530
# Set shell for fzf preview commands
1631
# Disable shellcheck for "which", because it suggests "command -v xxx" instead,
1732
# which is not a working replacement.

0 commit comments

Comments
 (0)