Rosettea / Hilbish

🌓 The Moon-powered shell! A comfy and extensible shell for Lua fans! 🌺 ✨
https://rosettea.github.io/Hilbish/
MIT License
500 stars 23 forks source link

hilbish.prompt: %d character isn't autorefreshing when go to another directory #175

Closed AlphaTechnolog closed 2 years ago

AlphaTechnolog commented 2 years ago

so if i use the next config:

local hilbish = require "hilbish"

hilbish.prompt('%d ')

it works, and it shows me the prompt correctly:

~

but if i go to ~/.config using cd, it don't autorefresh:

~ cd ~/.config
~ echo it keeps the ~
AlphaTechnolog commented 2 years ago

ok i fixed it using bait to catch the event command.exit and then update the prompt, so you can do something like this:

local hilbish = require "hilbish"
local bait = require "bait"

local function update_prompt ()
   hilbish.prompt("%d$ ")
end

update_prompt()

bait.catch("command.exit", function ()
   update_prompt()
end)

idk if this is the best way to do that, but that works lol

TorchedSammy commented 2 years ago

this would just be a matter of hilbish always setting the prompt with the line reader, and i think it makes sense

AlphaTechnolog commented 2 years ago

this would just be a matter of hilbish always setting the prompt with the line reader, and i think it makes sense

yep, but this is the right way to do this? or exists another better way? or i'm doing something wrong?

TorchedSammy commented 2 years ago

yep, but this is the right way to do this?

yes

AlphaTechnolog commented 2 years ago

oh ok

AlphaTechnolog commented 2 years ago

so, why is this opened? i solved this problem catching that event

TorchedSammy commented 2 years ago

hilbish itself should auto refresh prompt to not need the hook for basic prompts like that (i mentioned that in my opening comment)

AlphaTechnolog commented 2 years ago

oh ok, cool

TorchedSammy commented 2 years ago

actually i'll keep it to how it currently is