From 09a48d89ccb39a3daae40688cf724b450df42c47 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 20 May 2019 14:18:32 +0100 Subject: [PATCH 1/3] add an env var that themes can save history immediately --- themes/powerline-plain/powerline-plain.base.bash | 2 ++ themes/powerline-plain/powerline-plain.theme.bash | 2 ++ 2 files changed, 4 insertions(+) diff --git a/themes/powerline-plain/powerline-plain.base.bash b/themes/powerline-plain/powerline-plain.base.bash index 8b881d7e..239ed3ea 100644 --- a/themes/powerline-plain/powerline-plain.base.bash +++ b/themes/powerline-plain/powerline-plain.base.bash @@ -14,6 +14,8 @@ function __powerline_prompt_command { LEFT_PROMPT="" + [[ $HISTORY_AUTOSAVE -eq 1 ]] && history -a && history -c && history -r + ## left prompt ## for segment in $POWERLINE_PROMPT; do local info="$(__powerline_${segment}_prompt)" diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index bddb6450..59ae7b79 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -56,3 +56,5 @@ POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} safe_append_prompt_command __powerline_prompt_command + +HISTORY_AUTOSAVE=${HISTORY_AUTOSAVE:-0} From 23fab13d859acce83d5fb9b2876ec3530afd82a2 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 10 Jun 2019 10:57:52 +0100 Subject: [PATCH 2/3] requested changes has been made. --- themes/powerline-plain/powerline-plain.theme.bash | 5 +---- themes/powerline/powerline.theme.bash | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index 59ae7b79..f9538c2a 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -54,7 +54,4 @@ HOST_THEME_PROMPT_COLOR=0 POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} -safe_append_prompt_command __powerline_prompt_command - - -HISTORY_AUTOSAVE=${HISTORY_AUTOSAVE:-0} +safe_append_prompt_command __powerline_prompt_command \ No newline at end of file diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 482b3464..377e6f8e 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -57,4 +57,6 @@ HOST_THEME_PROMPT_COLOR=0 POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} +HISTORY_AUTOSAVE=${HISTORY_AUTOSAVE:-0} + safe_append_prompt_command __powerline_prompt_command From e93cc67bcd3dd527f733c0eac4da64c7b5cb0110 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 10 Jun 2019 13:39:35 +0100 Subject: [PATCH 3/3] added a function instead running the same check and commands in every theme --- themes/base.theme.bash | 5 +++++ themes/powerline-plain/powerline-plain.base.bash | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 2761b632..c58aca82 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -497,3 +497,8 @@ function safe_append_prompt_command { fi fi } + +function _save-and-reload-history() { + local autosave=${1:-0} + [[ $autosave -eq 1 ]] && history -a && history -c && history -r +} \ No newline at end of file diff --git a/themes/powerline-plain/powerline-plain.base.bash b/themes/powerline-plain/powerline-plain.base.bash index 239ed3ea..5558e0eb 100644 --- a/themes/powerline-plain/powerline-plain.base.bash +++ b/themes/powerline-plain/powerline-plain.base.bash @@ -14,7 +14,7 @@ function __powerline_prompt_command { LEFT_PROMPT="" - [[ $HISTORY_AUTOSAVE -eq 1 ]] && history -a && history -c && history -r + _save-and-reload-history "${HISTORY_AUTOSAVE:-0}" ## left prompt ## for segment in $POWERLINE_PROMPT; do