diff --git a/doc/sdcv.1 b/doc/sdcv.1 index 86351b7..d0700e1 100644 --- a/doc/sdcv.1 +++ b/doc/sdcv.1 @@ -89,9 +89,12 @@ If set, sdcv uses this variable as the data directory, this means that sdcv searches dictionaries in $\fBSTARDICT_DATA_DIR\fR\\dic .TP 20 .B SDCV_HISTSIZE -If set, sdcv writes in $(HOME)/.sdcv_history the last $(SDCV_HISTSIZE) words, +If set, sdcv writes in $(HOME)/.sdcv_history (or $(SDCV_HISTFILE)) the last $(SDCV_HISTSIZE) words, which you look up using sdcv. If it is not set, then the last 2000 words are saved in $(HOME)/.sdcv_history. .TP 20 +.B SDCV_HISTFILE +If set, sdcv writes it's history to $(SDCV_HISTFILE). If it is not set, then the default $(HOME)/.sdcv_history path will be used. +.TP 20 .B SDCV_PAGER If SDCV_PAGER is set, its value is used as the name of the program to use to display the dictionary article. diff --git a/src/readline.cpp b/src/readline.cpp index ab443ff..f4539b9 100644 --- a/src/readline.cpp +++ b/src/readline.cpp @@ -62,6 +62,16 @@ public: namespace { +std::string get_hist_file_path() +{ + const gchar *hist_file_str = g_getenv("SDCV_HISTFILE"); + + if (hist_file_str != nullptr) + return std::string(hist_file_str); + else + return std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history"; +} + class real_readline : public IReadLine { @@ -70,13 +80,13 @@ public: { rl_readline_name = "sdcv"; using_history(); - const std::string histname = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history"; + const std::string histname = get_hist_file_path(); read_history(histname.c_str()); } ~real_readline() { - const std::string histname = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history"; + const std::string histname = get_hist_file_path(); write_history(histname.c_str()); const gchar *hist_size_str = g_getenv("SDCV_HISTSIZE"); int hist_size;