2021-03-20 00:28:22 +00:00
|
|
|
-- Default Hilbish config
|
2023-07-10 23:03:30 +00:00
|
|
|
local hilbish = require 'hilbish'
|
2022-02-22 01:14:49 +00:00
|
|
|
local lunacolors = require 'lunacolors'
|
|
|
|
local bait = require 'bait'
|
2022-03-06 14:08:42 +00:00
|
|
|
local ansikit = require 'ansikit'
|
2021-03-20 22:51:51 +00:00
|
|
|
|
2023-07-10 23:03:30 +00:00
|
|
|
local unreadCount = 0
|
|
|
|
local running = false
|
2022-03-13 20:12:34 +00:00
|
|
|
local function doPrompt(fail)
|
2022-02-22 01:14:49 +00:00
|
|
|
hilbish.prompt(lunacolors.format(
|
2022-03-07 02:23:38 +00:00
|
|
|
'{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. '∆ '
|
2021-03-30 23:48:37 +00:00
|
|
|
))
|
|
|
|
end
|
|
|
|
|
2023-07-10 23:03:30 +00:00
|
|
|
local function doNotifyPrompt()
|
|
|
|
if running or unreadCount == hilbish.messages.unreadCount() then return end
|
|
|
|
|
|
|
|
local notifPrompt = string.format('• %s unread notification%s', hilbish.messages.unreadCount(), hilbish.messages.unreadCount() > 1 and 's' or '')
|
|
|
|
unreadCount = hilbish.messages.unreadCount()
|
|
|
|
hilbish.prompt(lunacolors.blue(notifPrompt), 'right')
|
|
|
|
|
|
|
|
hilbish.timeout(function()
|
|
|
|
hilbish.prompt('', 'right')
|
|
|
|
end, 3000)
|
|
|
|
end
|
|
|
|
|
2021-03-30 23:48:37 +00:00
|
|
|
doPrompt()
|
|
|
|
|
2023-07-10 23:03:30 +00:00
|
|
|
bait.catch('command.preexec', function()
|
|
|
|
running = true
|
|
|
|
end)
|
|
|
|
|
2021-04-05 21:27:55 +00:00
|
|
|
bait.catch('command.exit', function(code)
|
2023-07-10 23:03:30 +00:00
|
|
|
running = false
|
2021-04-05 21:27:55 +00:00
|
|
|
doPrompt(code ~= 0)
|
2023-07-10 23:03:30 +00:00
|
|
|
doNotifyPrompt()
|
2021-03-30 23:48:37 +00:00
|
|
|
end)
|
2021-03-20 22:51:51 +00:00
|
|
|
|
2022-03-06 14:08:42 +00:00
|
|
|
bait.catch('hilbish.vimMode', function(mode)
|
|
|
|
if mode ~= 'insert' then
|
|
|
|
ansikit.cursorStyle(ansikit.blockCursor)
|
|
|
|
else
|
|
|
|
ansikit.cursorStyle(ansikit.lineCursor)
|
|
|
|
end
|
|
|
|
end)
|
2023-07-10 23:03:30 +00:00
|
|
|
|
|
|
|
bait.catch('hilbish.notification', function(notif)
|
|
|
|
doNotifyPrompt()
|
|
|
|
end)
|