summaryrefslogtreecommitdiff
path: root/source/prompt
diff options
context:
space:
mode:
Diffstat (limited to 'source/prompt')
-rw-r--r--source/prompt/rps1.d27
1 files changed, 23 insertions, 4 deletions
diff --git a/source/prompt/rps1.d b/source/prompt/rps1.d
index 5ee5d2c..9ec5ac7 100644
--- a/source/prompt/rps1.d
+++ b/source/prompt/rps1.d
@@ -1,6 +1,12 @@
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;
@@ -11,9 +17,22 @@ import style.font;
string rps1(Opts opt) {
string ps;
- // previous command status
- ps ~= ("(" ~ to!string(opt.status) ~ ") ").set(Color.black);
+ string home = expandTilde("~");
+ string path = replaceFirst(getcwd(), regex(home), "~");
- return ps;
-}
+ 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);
+}