Last active
September 4, 2015 10:08
-
-
Save yasuhito/e281d4f002a589254e55 to your computer and use it in GitHub Desktop.
https://gist.github.com/azu/d3fb5f970e4ff945ead4 を percol から peco にしただけのモノです
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# peco + git issue | |
function found_command { which $1 &> /dev/null } | |
function is_issued() { | |
ISSUE_TYPE=$(git config issue.type 2>/dev/null) | |
if [ "$ISSUE_TYPE" != "" ]; then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
function is_issueType_redmine { | |
ISSUE_TYPE=$(git config issue.type 2>/dev/null) | |
if [ "$ISSUE_TYPE" = "redmine" ]; then | |
return 1 | |
else | |
return 0 | |
fi | |
} | |
# git-issue listからチケットを選んでgit flowのfeatureブランチを作る | |
function peco_select_from_git_issue_list_to_git_flow_feature_start() { | |
if $(is_issued) ; then | |
echo "Loading..." | |
TICKET=$(git-issue --no-color list | peco | ssed -e 's/^#\([0-9]*\).*/\1/') | |
BUFFER="git flow feature start id/$TICKET" | |
CURSOR=$#BUFFER | |
zle -R -c | |
else | |
echo "issue.typeが設定されてません" | |
echo # 上記のechoが出ない | |
zle reset-prompt | |
fi | |
} | |
#git-issue listからチケットを選んで詳細情報の表示 | |
function peco_select_from_git_issue() { | |
if $(is_issued) ; then | |
echo "Loading..." | |
TICKET=$(git-issue --no-color list | peco | ssed -e 's/^#\([0-9]*\).*/\1/') | |
git-issue show $TICKET | |
else | |
echo "issue.typeが設定されてません" | |
echo # 上記のechoが出ない | |
zle reset-prompt | |
fi | |
} | |
#git-issue listからチケットを選んでブラウザで開く | |
function peco_select_from_git_issue_to_open() { | |
if $(is_issued) ; then | |
echo "Loading..." | |
is_issueType_redmine | |
_ret=$? | |
if [ $_ret -ne 0 ]; then | |
TICKET=$(git-issue --query='status_id=*&limit=50&sort=updated_on:desc' --no-color --oneline | peco | ssed -e 's/^#\([0-9]*\).*/\1/') | |
ISSUE_URL=$(git config issue.url) | |
open ${ISSUE_URL}issues/${TICKET} | |
else | |
GITHUB_USER_PROJECT="$(git config remote.origin.url|sed -E 's!^([^/]*/){3}!!'|sed -E 's!^([^:]*:)!!'|sed 's!\.git$!!')" | |
TICKET=$(git-issue list --sort=updated --no-color --oneline | peco | ssed -e 's/^#\([0-9]*\).*/\1/') | |
ISSUE_URL="https://github.com/${GITHUB_USER_PROJECT}/issues" | |
open ${ISSUE_URL}/${TICKET} | |
fi | |
zle reset-prompt | |
else | |
echo "issue.typeが設定されてません" | |
echo # 上記のechoが出ない | |
zle reset-prompt | |
fi | |
} | |
function gilist (){ | |
is_issueType_redmine | |
_ret=$? | |
if [ $_ret -ne 0 ]; then | |
git issue list --query='status_id=closed&limit=30&sort=updated_on:desc' --oneline | |
else | |
git issue list --state=closed --oneline | |
fi | |
} | |
zle -N peco-git-recent-branches | |
zle -N peco-git-recent-all-branches | |
zle -N peco_select_from_git_issue_list_to_git_flow_feature_start | |
bindkey '^B^F' peco_select_from_git_issue_list_to_git_flow_feature_start | |
zle -N peco_select_from_git_issue | |
bindkey '^B^I' peco_select_from_git_issue | |
zle -N peco_select_from_git_issue_to_open | |
bindkey '^B^O' peco_select_from_git_issue_to_open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment