2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-07-01 08:42:04 +00:00

fix: add back %D, return path if it path isnt in home

This commit is contained in:
sammyette 2025-06-15 18:13:21 -04:00
parent e87136de7a
commit 91d7acf093
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD

View File

@ -14,12 +14,16 @@ local function abbrevHome(path)
if path:sub(1, hilbish.home:len()) == hilbish.home then
return fs.join('~', path:sub(hilbish.home:len() + 1))
end
return path
end
local function fmtPrompt(p)
return p:gsub('%%(%w)', function(c)
if c == 'd' then
return abbrevHome(hilbish.cwd())
elseif c == 'D' then
return fs.basename(abbrevHome(hilbish.cwd()))
elseif c == 'u' then
return hilbish.user
elseif c == 'h' then
@ -33,6 +37,7 @@ end
--- There are a few verbs that can be used in the prompt text.
--- These will be formatted and replaced with the appropriate values.
--- `%d` - Current working directory
--- `%D` - Basename of working directory ()
--- `%u` - Name of current user
--- `%h` - Hostname of device
--- #param str string