Created
August 19, 2012 12:33
-
-
Save mugyu/3394632 to your computer and use it in GitHub Desktop.
nyaos3kの動的プロンプトでsvnのurlやgitのbranch名をプロンプトに出力
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
-- svnの作業dirでurlを、そしてgitの作業dirでbranch名をプロンプトに出力 | |
function nyaos.prompt(prompt) | |
local current = nyaos.eval('__pwd__') | |
if nyaos.access(current .. '/.svn/entries', 0) then | |
local svn_url = string.match(nyaos.eval('svn info --xml'), '<url>(.*)</url>', 1) | |
return true, '$e[36;40;1mSVN[' .. svn_url .. ']' .. prompt | |
else | |
local git_path = current | |
repeat | |
if nyaos.access(git_path .. '/.git', 0) then | |
local git_branch = string.match(nyaos.eval('git branch'), '* (%S*)', 1) | |
if git_branch then | |
return true, '$e[33;40;1mGIT[' .. git_branch .. ']' .. prompt | |
end | |
break | |
end | |
git_path = string.match(git_path, '^(.+)\\', 1) | |
until not git_path | |
end | |
return nil, prompt | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment