Created
July 7, 2014 12:13
-
-
Save nocd5/f34b8c96b07ed13646a5 to your computer and use it in GitHub Desktop.
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
function nyaos.command.pcd() | |
local complst = nyaos.default_complete("", 1) | |
local buf = "" | |
for i, e in ipairs(complst) do | |
-- nyaos.statが通らないので、 | |
-- 末尾のスラッシュ、バックスラッシュを削除 | |
local f = e[2]:gsub('(.+)[\\/]$', '%1') | |
local stat = nyaos.stat(f) | |
if (stat and stat.directory) then | |
buf = buf .. '\n' .. e[2] | |
end | |
end | |
if (buf == "") then | |
print ("Directory not found.") | |
return | |
end | |
-- pecoはUTF-8じゃなきゃダメなので変換 | |
nyaos.chdir(nyaos.eval("echo " .. buf .. | |
" | iconv -f SJIS -t UTF-8 \ | |
| peco \ | |
| iconv -f UTF-8 -t SJIS")) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment