From ef577177747fd0a4778b92f762e0964d0ba3aafc Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 22 Sep 2019 15:58:00 -0700 Subject: Per-ASK() history for `ask` using the __COUNTER__ macro --- Makefile | 2 +- config.def.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d9a1585..c72bf46 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ CFLAGS += $(PICKER_FLAG) ifneq (, $(ASKER)) ifeq ($(shell which $(ASKER)),$(shell which ask 2>/dev/null || echo '')) - CFLAGS += -D'ASK(var, prompt, initial)=var "=\"$$(ask --history=bb --prompt=\"" prompt "\" --query=\"" initial "\")\""' + CFLAGS += -D'ASK(var, prompt, initial)=var "=\"$$(ask --history=bb."STRINGIFY(__COUNTER__)".hist --prompt=\"" prompt "\" --query=\"" initial "\")\""' endif ifeq ($(shell which $(ASKER)),$(shell which dmenu 2>/dev/null || echo '')) CFLAGS += -D'ASK(var, prompt, initial)=var "=\"$$(printf \"" initial "\" | dmenu -p \"" prompt "\")\""' diff --git a/config.def.h b/config.def.h index 6ee1c3f..59723a8 100644 --- a/config.def.h +++ b/config.def.h @@ -95,8 +95,12 @@ typedef struct { #define SH "sh" #endif -// Some handy macros for common shell script behaviors: +// Used for STRINGIFY(__COUNTER__) to embed the line number as a string +// (as in "ask --history=bb."STRINGIFY(__COUNTER__)") +#define STRINGIFY2(x) #x +#define STRINGIFY(x) STRINGIFY2(x) +// Some handy macros for common shell script behaviors: // Bold text: #define B(s) "\033[1m" s "\033[22m" -- cgit v1.2.3