Skip to content

Instantly share code, notes, and snippets.

@cbaconnier
Created July 4, 2024 17:30
Show Gist options
  • Save cbaconnier/08b5edfc6c87aba5489d0dab56c0df59 to your computer and use it in GitHub Desktop.
Save cbaconnier/08b5edfc6c87aba5489d0dab56c0df59 to your computer and use it in GitHub Desktop.
git del
[user]
email = clement@baconnier.ch
name = Clément Baconnier
[alias]
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
recent-branches = "!git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)' | nl -w2 -s'> ' "
r = "!f() { git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)' | awk -v var=\"$1\" 'NR==var' | xargs git checkout ; }; f"
pushf = push --force-with-lease
recent-branches = "!git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)' | nl -w2 -s'> ' "
r = "!f() { if [ -z \"$1\" ]; then git recent-branches; else git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)' | awk -v var=\"$1\" 'NR==var' | xargs git checkout ; fi ; }; f"
go = "!git for-each-ref --count=50 --sort=-committerdate refs/heads/ --format='%(refname:short)' | fzf | xargs -o git checkout"
del = "!git for-each-ref --count=50 --sort=-committerdate refs/heads/ --format='%(refname:short)' | fzf -m |confirm-list | while read -r branch; do git branch -D "$branch"; done"
f = "!git log -n 50 --pretty=format:'%h %s' --no-merges | fzf | cut -c -7 | xargs -o git fixup"
fixup = "!f() { \
if [ -z \"$1\" ]; then \
git f; \
else \
git diff-files --quiet || (echo Unstaged changes, please commit or stash with --keep-index; exit 1); \
COMMIT=$(git rev-parse $1) && git commit --fixup=$COMMIT && git rebase -i --autosquash $COMMIT~1 ; \
fi ; }; f"
[color]
diff = auto
status = auto
branch = auto
[init]
defaultBranch = main
[push]
autoSetupRemote = true
[cor]
editor = vim
[core]
editor = vim
#!/bin/bash
input=()
while IFS= read -r line; do
input+=("$line")
done
if [ ${#input[@]} -eq 0 ]; then
echo "No items to confirm. Exiting." >/dev/tty
exit 0
fi
echo "Items to process:" >/dev/tty
for item in "${input[@]}"; do
echo "$item" >/dev/tty
done
echo >/dev/tty
read -p "Are you sure you want to proceed with these items? (y/n): " confirm </dev/tty
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then
for item in "${input[@]}"; do
echo "$item"
done
else
echo "Operation aborted." >/dev/tty
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment