fix ln local bin
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
/Users/syui/dotfiles/.local/bin/git-ci
|
|
||||||
10
.local/bin/git-ci
Executable file
10
.local/bin/git-ci
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
git commit -v
|
||||||
|
else
|
||||||
|
if [ "$1" = "--amend" ]; then
|
||||||
|
git commit -v --amend
|
||||||
|
else
|
||||||
|
git commit -m "$*"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@@ -1 +0,0 @@
|
|||||||
/Users/syui/dotfiles/.local/bin/git-orphan
|
|
||||||
7
.local/bin/git-orphan
Executable file
7
.local/bin/git-orphan
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
git checkout --orphan temp
|
||||||
|
git add -A
|
||||||
|
git commit -m "init"
|
||||||
|
git branch -D main
|
||||||
|
git branch -m temp main
|
||||||
|
# git push -f origin main
|
||||||
@@ -1 +0,0 @@
|
|||||||
/Users/syui/dotfiles/.local/bin/vren
|
|
||||||
63
.local/bin/vren
Executable file
63
.local/bin/vren
Executable file
@@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
# vren - rename files with vim
|
||||||
|
# usage: vren [dir]
|
||||||
|
|
||||||
|
dir="${1:-.}"
|
||||||
|
cd "$dir" || exit 1
|
||||||
|
|
||||||
|
# git init if no .git
|
||||||
|
has_git=0
|
||||||
|
if [ -d .git ]; then
|
||||||
|
has_git=1
|
||||||
|
else
|
||||||
|
git init -q
|
||||||
|
git add -A
|
||||||
|
git commit -q -m "before rename"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# list files
|
||||||
|
old=$(mktemp)
|
||||||
|
new=$(mktemp)
|
||||||
|
ls -1 > "$old"
|
||||||
|
cp "$old" "$new"
|
||||||
|
|
||||||
|
# edit
|
||||||
|
vim "$new"
|
||||||
|
|
||||||
|
# check
|
||||||
|
old_count=$(wc -l < "$old")
|
||||||
|
new_count=$(wc -l < "$new")
|
||||||
|
if [ "$old_count" -ne "$new_count" ]; then
|
||||||
|
echo "error: line count mismatch ($old_count -> $new_count)"
|
||||||
|
rm "$old" "$new"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# diff
|
||||||
|
paste "$old" "$new" | while IFS=$'\t' read -r o n; do
|
||||||
|
[ "$o" != "$n" ] && echo " $o -> $n"
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! diff -q "$old" "$new" >/dev/null 2>&1; then
|
||||||
|
echo ""
|
||||||
|
printf "apply? (y/n): "
|
||||||
|
read -q ans
|
||||||
|
echo ""
|
||||||
|
if [ "$ans" = "y" ]; then
|
||||||
|
paste "$old" "$new" | while IFS=$'\t' read -r o n; do
|
||||||
|
[ "$o" != "$n" ] && mv -- "$o" "$n"
|
||||||
|
done
|
||||||
|
echo "done"
|
||||||
|
if [ "$has_git" -eq 0 ]; then
|
||||||
|
git add -A
|
||||||
|
git commit -q -m "after rename"
|
||||||
|
echo "restore: git log / git checkout HEAD~1 -- ."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "cancelled"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "no changes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm "$old" "$new"
|
||||||
Reference in New Issue
Block a user