diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 3b378a6a04..08deda1f4d 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -92,7 +92,7 @@ target_link_libraries(disasm PRIVATE LibX86) target_link_libraries(expr PRIVATE LibRegex) target_link_libraries(fdtdump PRIVATE LibDeviceTree) target_link_libraries(file PRIVATE LibGfx LibIPC LibArchive LibCompress LibAudio) -target_link_libraries(find PRIVATE LibRegex) +target_link_libraries(find PRIVATE LibFileSystem LibRegex) target_link_libraries(functrace PRIVATE LibDebug LibX86) target_link_libraries(glsl-compiler PRIVATE LibGLSL) target_link_libraries(gml-format PRIVATE LibGUI) diff --git a/Userland/Utilities/find.cpp b/Userland/Utilities/find.cpp index 1d446716c5..c646a60f98 100644 --- a/Userland/Utilities/find.cpp +++ b/Userland/Utilities/find.cpp @@ -10,9 +10,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -30,6 +32,7 @@ bool g_follow_symlinks = false; bool g_there_was_an_error = false; bool g_have_seen_action_command = false; +bool g_print_hyperlinks = false; template [[noreturn]] static void fatal_error(CheckedFormatString&& fmtstr, Parameters const&... parameters) @@ -409,7 +412,20 @@ public: private: virtual bool evaluate(FileData& file_data) const override { - out("{}{}", file_data.full_path, m_terminator); + auto printed = false; + if (g_print_hyperlinks) { + auto full_path_or_error = FileSystem::real_path(file_data.full_path.string()); + if (!full_path_or_error.is_error()) { + auto fullpath = full_path_or_error.release_value(); + auto url = URL::create_with_file_scheme(fullpath.to_deprecated_string()); + out("\033]8;;{}\033\\{}{}\033]8;;\033\\", url.serialize(), file_data.full_path, m_terminator); + printed = true; + } + } + + if (!printed) + out("{}{}", file_data.full_path, m_terminator); + return true; } @@ -739,6 +755,8 @@ ErrorOr serenity_main(Main::Arguments arguments) } } + g_print_hyperlinks = TRY(Core::System::isatty(STDOUT_FILENO)); + if (!command) command = make();