I have a lot of projects of the form:
/home/karl/source/project-name/further/hierarchy/...
I would like to extract just the project-name
to put into my statusline. I use autochdir
, so I know I can create a function that calls getcwd()
and extracts that part. However, I haven't been able to figure out how to do the parsing after that point.
function ProjectName()
return ???getcwd()???
endfunc
set statusline=%t\ %m%r%{ProjectName()}%{fugitive#statusline()}%=%l,%c\ [0x%B]\ %P
If I edit something outside that folder, I'd like to leave the project blank. Can someone fill in the ???
for me?
:help fnamemodify