For my Haskell programs, I know that the executable's name in the path is the same as my current directory's name. Now I want to create a mapping like so:
:map <leader>rr :!curdir()<cr>
However, the only command I know of is getcwd()
, which gives me the whole path instead of just the directory's name.
Is there an easy way to extract only the directory's name?
:!
typeC-R=
followed by one of the vimscript solutions below./
being a path separator is wrong. Anybody assuming/
and\
are both path separators is just as wrong. More, anybody assuming\
is always path separator on windows is also wrong. I also have no idea under which circumstances path separator will be:
, but it may be it. Most *nix systems can have\
and:
in file names.