fi; \
fi; \
done; \
}; f'';
r = ''
!f() { \
if [ $# -eq 0 ]; then \
git restore .; \
echo "restored all files"; \
return; \
fi; \
for pattern in "$@"; do \
matches=$(git ls-files | grep -i "$pattern"); \
if [ -z "$matches" ]; then \
echo "no files found matching \"$pattern\""; \
continue; \
fi; \
if [ $(echo "$matches" | wc -l) -eq 1 ]; then \
git restore "$matches"; \
echo "restored: $matches"; \
else \
echo "multiple matches for \"$pattern\":"; \
echo "$matches"; \
printf "restore all? (y/n): "; \
read response; \
if echo "$response" | grep -q "^[Yy]"; then \
echo "$matches" | xargs git restore; \
echo "restored all matches"; \
fi; \
fi; \
done; \
}; f'';
rs = ''
!f() { \
if [ $# -eq 0 ]; then \
git restore --staged .; \
echo "unstaged all files"; \
return; \
fi; \
for pattern in "$@"; do \
matches=$(git ls-files | grep -i "$pattern"); \
if [ -z "$matches" ]; then \
echo "no files found matching \"$pattern\""; \
continue; \
fi; \
if [ $(echo "$matches" | wc -l) -eq 1 ]; then \
git restore --staged "$matches"; \
echo "unstaged: $matches"; \
else \
echo "multiple matches for \"$pattern\":"; \
echo "$matches"; \
printf "unstage all? (y/n): "; \
read response; \
if echo "$response" | grep -q "^[Yy]"; then \
echo "$matches" | xargs git restore --staged; \
echo "unstaged all matches"; \
fi; \
fi; \
done; \
}; f'';
d = ''
!f() { \
if [ $# -eq 0 ]; then \
git diff; \
return; \
fi; \
for pattern in "$@"; do \
matches=$(git ls-files | grep -i "$pattern"); \
if [ -z "$matches" ]; then \
echo "no files found matching \"$pattern\""; \
continue; \
fi; \
if [ $(echo "$matches" | wc -l) -eq 1 ]; then \
git diff "$matches"; \
else \
echo "multiple matches for \"$pattern\":"; \
echo "$matches"; \
printf "diff all? (y/n): "; \
read response; \
if echo "$response" | grep -q "^[Yy]"; then \
echo "$matches" | xargs git diff; \