From 37a4f2d8aedefbd3a09761e0dedfb6d114f23a97 Mon Sep 17 00:00:00 2001 From: hophacker Date: Thu, 21 Feb 2019 14:42:19 +0800 Subject: [PATCH] githublog -> gitcopy, add arguments [-c commit] [-n count] --- zsh/functions.zsh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/zsh/functions.zsh b/zsh/functions.zsh index 9c237f6..74bfd2b 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -130,8 +130,22 @@ function init_db() { dc exec $1 rails db:drop db:create db:migrate db:seed } -function githublog() { +function gitcopy() { + n=1 + while getopts "c:n:" o; do + case "${o}" in + c) + commit=${OPTARG} + ;; + n) + n=${OPTARG} + ;; + *) + usage + ;; + esac + done repo=`git remote get-url origin | sed -E 's/.*:(.*)\.git/\1/'` project_name=`echo $repo | sed -E 's/.*\/(.*)/\1/'` - git log --pretty="* [$project_name](https://github.com/$repo/commit/%H) %an: **%s**" + git log $commit --pretty="* [$project_name](https://github.com/$repo/commit/%H) %an: **%s**" | head -n $n | tee | pbcopy }