summaryrefslogtreecommitdiff
path: root/source/prompt
diff options
context:
space:
mode:
Diffstat (limited to 'source/prompt')
-rw-r--r--source/prompt/preexec.d5
-rw-r--r--source/prompt/ps1.d13
-rw-r--r--source/prompt/rps1.d31
3 files changed, 16 insertions, 33 deletions
diff --git a/source/prompt/preexec.d b/source/prompt/preexec.d
index 3904a2b..52a5cb2 100644
--- a/source/prompt/preexec.d
+++ b/source/prompt/preexec.d
@@ -1,10 +1,11 @@
module prompt.preexec;
+import prim.opt;
import comp.hr;
import style;
import style.color;
-string preexec(int col) {
- return hr(col).set(Color.black);
+string preexec(Opts opt) {
+ return "";
}
diff --git a/source/prompt/ps1.d b/source/prompt/ps1.d
index 5b8bafa..d1bc1b3 100644
--- a/source/prompt/ps1.d
+++ b/source/prompt/ps1.d
@@ -3,7 +3,9 @@ module prompt.ps1;
import std.conv;
import prim.opt;
+
import comp.hr;
+import comp.path;
import style;
import style.color;
@@ -12,14 +14,13 @@ import style.font;
string ps1(Opts opt) {
string ps;
- // divider
- ps ~= hr(opt.col).set(Color.black);
+ string pathstr = path(opt.pathlen);
- // previous command status
- ps ~= ("(" ~ to!string(opt.status) ~ ") ").set(Color.black);
+ ps ~= "\n";
+ ps ~= (",-(" ~ pathstr ~ ")").set(Color.black);
+ ps ~= "\n";
- // prompt char
+ ps ~= ("'-(" ~ to!string(opt.status) ~ ") ").set(Color.black); // prompt char
ps ~= "|> ".set(Font.bold).set(opt.status == 0 ? Color.green : Color.red);
-
return ps;
}
diff --git a/source/prompt/rps1.d b/source/prompt/rps1.d
index 9ec5ac7..075707e 100644
--- a/source/prompt/rps1.d
+++ b/source/prompt/rps1.d
@@ -1,15 +1,10 @@
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 comp.path;
+import comp.git;
+
import style;
import style.color;
import style.font;
@@ -17,22 +12,8 @@ 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("/");
+ ps ~= (gitBranch()).set(Font.bold).set(Color.cyan);
+ ps ~= (gitStatus());
- return ps.set(Font.italic).set(Color.yellow);
+ return ps;
}