File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -67,8 +67,9 @@ prompt.prompts = { prompt_style.generate_ps1(), " " }
6767
6868## Customization
6969
70- By default, It uses the base name of current working directory as your project
71- name. You can call ` (require "prompt-style").wakatime("wakatime-cli XXX") ` to
70+ If there is a git repository, the project name can be achieved by git. Else use
71+ the base name of current working directory.
72+ You can call ` (require "prompt-style").wakatime("wakatime-cli XXX") ` to
7273customize it.
7374
7475See
Original file line number Diff line number Diff line change @@ -16,9 +16,11 @@ local function wakatime(cmd)
1616 " --entity-type=app --entity=lua --alternate-language=lua --project=%s"
1717 local s , _ = string.find (cmd , " %s" )
1818 if s ~= nil then
19- cmd = string.format (cmd ,
20- string.match (lfs .currentdir (), " [^/]+$" )
21- )
19+ local project = io.popen (" git rev-parse --show-toplevel 2> /dev/null" ):read ()
20+ if project == nil then
21+ project = string.match (lfs .currentdir (), " [^/]+$" )
22+ end
23+ cmd = string.format (cmd , project )
2224 end
2325 io.popen (cmd )
2426 return " "
2729--- get distribution
2830--- @return string
2931local function get_distribution ()
30- local line = io.popen (" lsb_release -i 2>/dev/null" , " r " ):read ()
32+ local line = io.popen (" lsb_release -i 2>/dev/null" ):read ()
3133 if line == nil then return " linux" end
3234 return string.lower (string.gsub (line , " .*:%s*" , " " ))
3335end
You can’t perform that action at this time.
0 commit comments