mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 20:15:07 +00:00
Shell: Hyperlink output from "pwd" and "dirs" built-ins :^)
This commit is contained in:
parent
8af3af137e
commit
c50672a19d
1 changed files with 24 additions and 7 deletions
|
@ -55,6 +55,16 @@ static Line::Editor editor { Line::Configuration { Line::Configuration::Unescape
|
||||||
// FIXME: We do not expand variables inside strings
|
// FIXME: We do not expand variables inside strings
|
||||||
// if we want to be more sh-like, we should do that some day
|
// if we want to be more sh-like, we should do that some day
|
||||||
static constexpr bool HighlightVariablesInsideStrings = false;
|
static constexpr bool HighlightVariablesInsideStrings = false;
|
||||||
|
static bool s_disable_hyperlinks = false;
|
||||||
|
|
||||||
|
static void print_path(const String& path)
|
||||||
|
{
|
||||||
|
if (s_disable_hyperlinks) {
|
||||||
|
printf("%s", path.characters());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("\033]8;;file://%s%s\033\\%s\033]8;;\033\\", g.hostname, path.characters(), path.characters());
|
||||||
|
}
|
||||||
|
|
||||||
struct ExitCodeOrContinuationRequest {
|
struct ExitCodeOrContinuationRequest {
|
||||||
enum ContinuationRequest {
|
enum ContinuationRequest {
|
||||||
|
@ -167,7 +177,8 @@ static String prompt()
|
||||||
|
|
||||||
static int sh_pwd(int, const char**)
|
static int sh_pwd(int, const char**)
|
||||||
{
|
{
|
||||||
printf("%s\n", g.cwd.characters());
|
print_path(g.cwd);
|
||||||
|
fputc('\n', stdout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,8 +554,10 @@ static int sh_dirs(int argc, const char** argv)
|
||||||
g.directory_stack.at(0) = g.cwd.characters();
|
g.directory_stack.at(0) = g.cwd.characters();
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
for (String dir : g.directory_stack)
|
for (auto& directory : g.directory_stack) {
|
||||||
printf("%s ", dir.characters());
|
print_path(directory);
|
||||||
|
fputc(' ', stdout);
|
||||||
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -561,8 +574,10 @@ static int sh_dirs(int argc, const char** argv)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "-p") && !printed) {
|
if (!strcmp(arg, "-p") && !printed) {
|
||||||
for (auto& directory : g.directory_stack)
|
for (auto& directory : g.directory_stack) {
|
||||||
printf("%s\n", directory.characters());
|
print_path(directory);
|
||||||
|
fputc('\n', stdout);
|
||||||
|
}
|
||||||
|
|
||||||
printed = true;
|
printed = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -570,7 +585,9 @@ static int sh_dirs(int argc, const char** argv)
|
||||||
if (!strcmp(arg, "-v") && !printed) {
|
if (!strcmp(arg, "-v") && !printed) {
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (auto& directory : g.directory_stack) {
|
for (auto& directory : g.directory_stack) {
|
||||||
printf("%d %s\n", idx++, directory.characters());
|
printf("%d ", idx++);
|
||||||
|
print_path(directory);
|
||||||
|
fputc('\n', stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
printed = true;
|
printed = true;
|
||||||
|
@ -638,7 +655,7 @@ static bool handle_builtin(int argc, const char** argv, int& retval)
|
||||||
|
|
||||||
class FileDescriptionCollector {
|
class FileDescriptionCollector {
|
||||||
public:
|
public:
|
||||||
FileDescriptionCollector() { }
|
FileDescriptionCollector() {}
|
||||||
~FileDescriptionCollector() { collect(); }
|
~FileDescriptionCollector() { collect(); }
|
||||||
|
|
||||||
void collect()
|
void collect()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue