Creating a shell script to manage Git LFS extensions, allowing users to enable, disable, or update the extension for different Git repositories can be a helpful utility. Here's a sample shell script that provides a user-friendly menu for these actions [1][2]:
```shell
#!/bin/bash
# Function to enable Git LFS for a repository
enable_git_lfs() {
git lfs install
git lfs track "*.extension" # Customize the file extensions you want to track
echo "Git LFS is enabled for this repository."
}
# Function to disable Git LFS for a repository
disable_git_lfs() {
git lfs uninstall
echo "Git LFS is disabled for this repository."
}
# Function to update Git LFS
update_git_lfs() {
git lfs update
echo "Git LFS is updated."
}
# Main menu
while true; do
echo "Git LFS Extension Manager"
echo "1. Enable Git LFS for the current repository"
echo "2. Disable Git LFS for the current repository"
echo "3. Update Git LFS"
echo "4. Quit"
read -p "Select an option: " choice
case $choice in
1)
enable_git_lfs
;;
2)
disable_git_lfs
;;
3)
update_git_lfs
;;
4)
echo "Exiting Git LFS Extension Manager."
exit 0
;;
*)
echo "Invalid option. Please select a valid option."
;;
esac
done
```
Here's how the script works:
* The script defines three functions to enable, disable, and update Git LFS for a specific repository.
* The main menu is presented to the user with options to enable, disable, or update Git LFS, as well as an option to quit the script.
* Depending on the user's choice, the corresponding function is called to perform the Git LFS operation.
* The script continues to display the main menu until the user selects the `Quit` option.
This script provides a user-friendly way to manage Git LFS extensions for different repositories on your Linux system. You can customize the file extensions you want to track by modifying the git lfs track command in the enable_git_lfs function to suit your specific needs.