module prompt.rps1; import std.conv; import std.regex; import std.array; import std.file : getcwd; import std.path : expandTilde; import std.algorithm : reverse; import prim.opt; import style; import style.color; import style.font; string rps1(Opts opt) { string ps; string home = expandTilde("~"); string path = replaceFirst(getcwd(), regex(home), "~"); string[] splitPath = path.split("/").reverse(); string[] revSplitPath; for (int i = 0; i < opt.pathlen; i++) { if (i >= splitPath.length) break; revSplitPath ~= splitPath[i]; } splitPath = revSplitPath.reverse(); ps ~= splitPath.join("/"); return ps.set(Font.italic).set(Color.yellow); }