Skip to content

Commit

Permalink
prompt: display context if one is present
Browse files Browse the repository at this point in the history
The documentation for tasksh currently says that the tasksh prompt will
display the context if there is one.  This adds the context to the
prompt.

Fixes GH issue GothenburgBitFactory#37
  • Loading branch information
ThomasAdam committed Jun 14, 2018
1 parent 908d2cc commit 51dbcbb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/prompt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <vector>
#include <string>
#include <Color.h>
#include <Lexer.h>
#include <shared.h>

static std::vector <std::string> contextColors = {
"bold white on red",
Expand Down Expand Up @@ -93,11 +95,22 @@ std::string promptCompose ()
// TODO - The accumulated context, as colored tokens.
// TODO - sync status
// TODO - time
std::string prompt = "tasksh";
auto decoration = composeContexts (true);
if (decoration.length ())
return "task " + decoration + "> ";

return "tasksh> ";
// For now, display the context (if any).
std::string dummy;;
std::string output;
execute ("task", {"_get", "rc.context"}, dummy, output);
output = Lexer::trimRight (output, "\n");

if (output != "")
prompt += " (" + output + ")";
prompt += "> ";

return prompt;
}

////////////////////////////////////////////////////////////////////////////////

0 comments on commit 51dbcbb

Please sign in to comment.