Skip to content

Instantly share code, notes, and snippets.

@shuuji3
Last active December 24, 2024 07:01
Show Gist options
  • Select an option

  • Save shuuji3/c4eaecb3b6d86bb41474375bcecf0bca to your computer and use it in GitHub Desktop.

Select an option

Save shuuji3/c4eaecb3b6d86bb41474375bcecf0bca to your computer and use it in GitHub Desktop.
fish shell script for contributing Vite documentation Japanese translation https://github.com/vitejs/docs-ja
#!/usr/bin/env fish
# Parse args
if count $argv > /dev/null
set issue $argv[1]
else
read -p 'set_color green; echo -n "Issue number"; set_color normal; echo "> "' issue
end
# Create a new branch
git branch -D $issue
git stash
git switch main
git pull --rebase
git switch -c $issue
git rebase --onto remotes/docs-ja/main
git stash pop
# Get commit URL
set commit (gh issue view $issue | grep /commit/)
# Get original commit title
set title (gh issue view $issue --json title -q .title | tr -d '\n' | sed -E 's/^[[:blank:]]*(.+\S)[[:blank:]]*$/\1/')
# Show issue description
gh issue view $issue
# Copy PR description
set description "$title
resolve #$issue
$commit の反映です。"
echo $description | xsel --clipboard
echo "---
$description
---"
open $commit
# Open changed files under docs/
set commit_hash (echo $commit | cut -d '/' -f 7)
set files (git show $commit_hash --name-only --pretty= | grep -E '^docs/')
for file in $files
echo $file
idea (echo $file | cut -d '/' -f 2-)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment