Skip to content

Instantly share code, notes, and snippets.

@DeaR
Last active June 17, 2016 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeaR/e4aa527f53470fcfdc82066ed71a5d76 to your computer and use it in GitHub Desktop.
Save DeaR/e4aa527f53470fcfdc82066ed71a5d76 to your computer and use it in GitHub Desktop.
IGNOREEOF support for NYAGOS
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)
@DeaR
Copy link
Author

DeaR commented Jun 13, 2016

share.ignoreeofもしくは%IGNOREEOF%に回数を設定(Default:-1)
負数だと無制限

欠点としてexitがhistoryに残る
(終了させる他の方法が思いつかなかった)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment