chiark / gitweb /
systemctl: highlight filenames in cat
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 17 Dec 2013 03:34:07 +0000 (22:34 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 17 Dec 2013 04:21:51 +0000 (23:21 -0500)
src/shared/util.h
src/systemctl/systemctl.c

index 57689e9cf3c0823866051f30f6875e7cb42ad0f1..dd51e8930639efe0993c098aecb3ee4009238b3c 100644 (file)
@@ -64,6 +64,7 @@ union dirent_storage {
 #define ANSI_GREEN_ON "\x1B[32m"
 #define ANSI_HIGHLIGHT_GREEN_ON "\x1B[1;32m"
 #define ANSI_HIGHLIGHT_YELLOW_ON "\x1B[1;33m"
+#define ANSI_HIGHLIGHT_BLUE_ON "\x1B[1;34m"
 #define ANSI_HIGHLIGHT_OFF "\x1B[0m"
 #define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
 
@@ -399,6 +400,10 @@ static inline const char *ansi_highlight_yellow(void) {
         return on_tty() ? ANSI_HIGHLIGHT_YELLOW_ON : "";
 }
 
+static inline const char *ansi_highlight_blue(void) {
+        return on_tty() ? ANSI_HIGHLIGHT_BLUE_ON : "";
+}
+
 static inline const char *ansi_highlight_off(void) {
         return on_tty() ? ANSI_HIGHLIGHT_OFF : "";
 }
index 327eb85ca1682fd4ee2989ba8b75fab4ddada4ac..aab92c466f2641e0d662ca7eab32acc1cc573914 100644 (file)
@@ -3797,7 +3797,10 @@ static int cat(sd_bus *bus, char **args) {
                 }
 
                 if (!isempty(fragment_path)) {
-                        fprintf(stdout, "# %s\n", fragment_path);
+                        fprintf(stdout, "%s# %s%s\n",
+                                ansi_highlight_blue(),
+                                fragment_path,
+                                ansi_highlight_off());
                         fflush(stdout);
 
                         r = sendfile_full(STDOUT_FILENO, fragment_path);