Last active
December 14, 2016 07:51
-
-
Save uekkie/13e7460af0f56beec809f3c082ba159c to your computer and use it in GitHub Desktop.
peco+cd=pcd コマンド。マルチバイト文字、空白文字含むディレクトリへの対応版
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 | |
) | |
notepad "%USERPROFILE%\.peco-cd" | |
goto end | |
:query | |
rem NOTE: | |
rem - http://mattn.kaoriya.net/software/peco.htm 参考 | |
rem - 文字コード変換は nkf32 を使用 | |
rem - "C:\Program Files" のような空白文字列への対応として "tokens=*" を使用 | |
rem | |
for /f "tokens=*" %%i in ('type ^"%USERPROFILE%\.peco-cd^" ^| nkf32 -w -Lw -c ^| peco ^| nkf32 -x') do ( | |
cd %%i | |
break | |
) | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment