-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprompt.lua
More file actions
47 lines (40 loc) · 1.38 KB
/
Copy pathprompt.lua
File metadata and controls
47 lines (40 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-- Only one of the following should be set to `true`, otherwise `false`
local starship_enabled = true
local ohmyposh_enabled = false
-- Ensure only one of the options is enabled
if starship_enabled and ohmyposh_enabled then
error("Only one of 'starship_enabled' or 'ohmyposh_enabled' can be set to true.")
return
end
-- Load the appropriate prompt based on the enabled option
if starship_enabled then
-- Initialize Starship prompt
local starship_init = io.popen("starship init cmd")
if not starship_init then
error("Failed to initialize Starship prompt.")
return
end
load(starship_init:read("*a"))()
starship_init:close()
elseif ohmyposh_enabled then
-- Ensure POSH_THEMES_PATH is set
local posh_themes_path = os.getenv("POSH_THEMES_PATH")
if not posh_themes_path then
error("Environment variable 'POSH_THEMES_PATH' is not set.")
return
end
-- Construct the full path to the Oh My Posh theme file
local ohmyposh_theme_file = posh_themes_path .. "/catppuccin_mocha.omp.json"
local ohmyposh_theme = string.gsub(ohmyposh_theme_file, "\\", "/")
-- Initialize Oh My Posh prompt
local ohmyposh_init = io.popen("oh-my-posh init cmd --config " .. ohmyposh_theme)
if not ohmyposh_init then
error("Failed to initialize Oh My Posh prompt.")
return
end
load(ohmyposh_init:read("*a"))()
ohmyposh_init:close()
else
-- Return if no `oh-my-posh` or `starship` prompt is enabled
return
end