blob: 9ec5ac7cbd9705dc2d63b2ea30a23984384dd2b4 (
plain)
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
|
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);
}
|