Last active
June 17, 2016 17:12
-
-
Save DeaR/e4aa527f53470fcfdc82066ed71a5d76 to your computer and use it in GitHub Desktop.
IGNOREEOF support for NYAGOS
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
share._ignoreeof_now = 0 | |
share.org_ignoreeof_filter = nyagos.filter | |
nyagos.filter = function(args) | |
share._ignoreeof_now = 0 | |
if share.org_ignoreeof_filter then | |
return share.org_ignoreeof_filter(args) | |
end | |
end | |
nyagos.bindkey('C_D', function(this) | |
local max = share.ignoreeof or tonumber(nyagos.getenv('IGNOREEOF')) or -1 | |
if this.text:len() > 0 then | |
this:call('DELETE_OR_ABORT') | |
elseif max < 0 or share._ignoreeof_now < max then | |
share._ignoreeof_now = share._ignoreeof_now + 1 | |
nyagos.write('Use "exit" to leave the shell.') | |
return false | |
else | |
os.exit() | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
share.ignoreeof
もしくは%IGNOREEOF%
に回数を設定(Default:-1
)負数だと無制限
欠点としてexit
がhistoryに残る(終了させる他の方法が思いつかなかった)