summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x.bin/xx.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/.bin/xx.c b/.bin/xx.c
index f0bc15af..ad71ac98 100755
--- a/.bin/xx.c
+++ b/.bin/xx.c
@@ -2,24 +2,28 @@
 exec cc -Weverything -Wno-vla -o ~/.bin/xx $0
 #endif
 
+#include <ctype.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
 enum {
-    OFFSETS = 1,
+    ASCII = 1,
+    OFFSETS = 2,
 };
 
 int main(int argc, char **argv)
 {
     size_t cols = 16;
     size_t group = 8;
-    uint8_t flags = OFFSETS;
+    uint8_t flags = ASCII | OFFSETS;
     char *path = NULL;
 
-    while (getopt(argc, argv, "c:g:o") > 0)
-        if (optopt == 'c') {
+    while (getopt(argc, argv, "ac:g:o") > 0)
+        if (optopt == 'a') {
+            flags ^= ASCII;
+        } else if (optopt == 'c') {
             cols = (size_t) strtol(optarg, NULL, 10);
             if (!cols) return EXIT_FAILURE;
         } else if (optopt == 'g') {
@@ -48,6 +52,14 @@ int main(int argc, char **argv)
             printf("%02x ", buf[i]);
         }
 
+        if (flags & ASCII) {
+            for (i = n; i < cols; ++i)
+                printf("   ");
+            printf(" ");
+            for (i = 0; i < n; ++i)
+                printf("%c", isprint(buf[i]) ? buf[i] : '.');
+        }
+
         printf("\n");
         offset += n;
         if (n < sizeof(buf)) break;
p;follow=1'>Remove psql format wrappedJune McEnroe 2016-01-25Wow, that is so annoying, gitJune McEnroe 2016-01-25Clean up .gitconfigJune McEnroe 2016-01-15Remove gitignoreJune McEnroe 2016-01-15Eliminate escape key delay in zshJune McEnroe 2016-01-15Move pretty git log format to .gitconfigJune McEnroe 2016-01-14Remove unused git aliasesJune McEnroe 2016-01-06Hash SSH known hostsJune McEnroe 2015-12-30Ignore directory .swp filesJune McEnroe 2015-12-16Color prompt yellow in vi normal modeJune McEnroe 2015-11-23Remove colorcolumn at 120June McEnroe 2015-11-23Always git rebase --autosquashJune McEnroe 2015-11-18Add inverted shift to KarabinerJune McEnroe 2015-11-06Clean up git configsJune McEnroe 2015-11-06Add prune scriptJune McEnroe 2015-11-03Update vendored Gruvbox colorschemeJune McEnroe 2015-11-02Redefine _newline_precmd in _newline_precmdJune McEnroe 2015-11-02Print newline before every prompt after firstJune McEnroe 2015-11-02Remove first prompt placementJune McEnroe 2015-11-02Newline before prompt and start at bottom of terminalJune McEnroe 2015-10-27Add chruby to zshrcJune McEnroe