Last active
August 29, 2015 14:03
-
-
Save yuratomo/e471f727586de86cefd7 to your computer and use it in GitHub Desktop.
c.bat
This file contains 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
# my git log | |
alias gitl='git log --date=short --pretty=format:"%h [%ad] : %s <%an>"' | |
# ディレクトリをpecoで選択 | |
_ll() { | |
echo .. ; find . -maxdepth 1 -type d | |
} | |
ll() { | |
local DIR=$(_ll | peco | head -n 1) | |
if [ -n "$DIR" ] ; then | |
case $DIR in | |
".") ;; | |
*) cd "$DIR" ; ll ;; | |
esac | |
fi | |
} | |
# git addをpecoで選択 | |
gita() { | |
local res=$(git status -s | peco | awk '{ print $2 }') | |
if [ "$res" != "" ] ; then | |
git add ${res} | |
fi | |
} | |
# gitブランチ切り替えをpecoで選択 | |
gitb() { | |
local res=$(git branch | peco | head -n 1) | |
if [ "$res" != "" ] ; then | |
if [ "${res:0:1}" != "*" ] ; then | |
echo checkout $res ... | |
git checkout $res | |
fi | |
fi | |
} | |
# git diffをpecoで選択 | |
gitd() { | |
local res=$(gitl | peco | awk '{ print $1 }') | |
if [ "$res" != "" ] ; then | |
alias _gitd='git diff --no-prefix $res | grep ^---\ ' | |
local file=$(_gitd | peco | awk '{ print $2 }') | |
if [ "$file" != "" ] ; then | |
git diff --no-prefix $res $file | |
fi | |
unalias _gitd | |
fi | |
} | |
This file contains 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
@echo off | |
if "%1" equ "dir" ( | |
echo . | |
echo .. | |
dir /ADH-H /B | |
) | |
if "%1" equ "" ( | |
for /f "delims=" %%i in ('c.bat dir ^| peco') do ( | |
if "%%i" equ "." ( | |
goto end | |
) | |
cd "%%i" | |
c | |
break | |
) | |
) | |
:end |
This file contains 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
@echo off | |
if "%1" equ "add" ( | |
if "%2" neq "" ( | |
echo %2 >> "%USERPROFILE%\.peco-cd" | |
goto end | |
) | |
goto usage | |
) | |
if "%1" equ "edit" ( | |
goto edit | |
) | |
if "%1" neq "" ( | |
goto usage | |
) | |
goto query | |
:usage | |
echo %0 [add PATH ^| edit] | |
goto end | |
:edit | |
if "%EDITOR%" neq "" ( | |
"%EDITOR%" "%USERPROFILE%\.peco-cd" | |
goto end | |
) | |
gvim "%USERPROFILE%\.peco-cd" | |
goto end | |
:query | |
for /f "delims=" %%i in ('type ^"%USERPROFILE%\.peco-cd^" ^| peco') do ( | |
cd %%i | |
break | |
) | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment